Exemple #1
0
    def history(self, *args, **kwargs):
        """Returns workflow execution history report

        :returns: The workflow execution complete events history
        :rtype: swf.models.event.History
        """
        domain = kwargs.pop('domain', self.domain)
        if not isinstance(domain, compat.basestring):
            domain = domain.name

        response = self.connection.get_workflow_execution_history(
            domain,
            self.run_id,
            self.workflow_id,
            **kwargs
        )

        events = response['events']
        next_page = response.get('nextPageToken')
        while next_page is not None:
            response = self.connection.get_workflow_execution_history(
                domain,
                self.run_id,
                self.workflow_id,
                next_page_token=next_page,
                **kwargs
            )

            events.extend(response['events'])
            next_page = response.get('nextPageToken')

        return History.from_event_list(events)
Exemple #2
0
    def history(self, *args, **kwargs):
        """Returns workflow execution history report

        :returns: The workflow execution complete events history
        :rtype: swf.models.event.History
        """
        domain = kwargs.pop('domain', self.domain)
        if not isinstance(domain, compat.basestring):
            domain = domain.name

        response = self.connection.get_workflow_execution_history(
            domain,
            self.run_id,
            self.workflow_id,
            **kwargs
        )

        events = response['events']
        next_page = response.get('nextPageToken')
        while next_page is not None:
            response = self.connection.get_workflow_execution_history(
                domain,
                self.run_id,
                self.workflow_id,
                next_page_token=next_page,
                **kwargs
            )

            events.extend(response['events'])
            next_page = response.get('nextPageToken')

        return History.from_event_list(events)
    def poll(self, task_list=None, identity=None, **kwargs):
        """
        Polls a decision task and returns the token and the full history of the
        workflow's events.

        :param task_list: task list to poll for decision tasks from.
        :type task_list: string

        :param identity: Identity of the decider making the request,
        which is recorded in the DecisionTaskStarted event in the
        workflow history.
        :type identity: string

        :returns: (token, history)
        :type: swf.models.History

        """
        task_list = task_list or self.task_list

        task = self.connection.poll_for_decision_task(
            self.domain.name, task_list=task_list, identity=identity, **kwargs
        )
        token = task.get("taskToken")
        if token is None:
            raise PollTimeout("Decider poll timed out")

        events = task["events"]

        next_page = task.get("nextPageToken")
        while next_page:
            try:
                task = self.connection.poll_for_decision_task(
                    self.domain.name, task_list=task_list, identity=identity, next_page_token=next_page, **kwargs
                )
            except boto.exception.SWFResponseError as e:
                if e.error_code == "UnknownResourceFault":
                    raise DoesNotExistError("Unable to poll decision task.\n", e.body["message"])

                raise ResponseError(e.body["Message"])

            token = task.get("taskToken")
            if token is None:
                raise PollTimeout("Decider poll timed out")

            events.extend(task["events"])
            next_page = task.get("nextPageToken")

        history = History.from_event_list(events)

        return token, history
 def setUp(self):
     self.event_list = mock_get_workflow_execution_history()
     self.history = History.from_event_list(self.event_list['events'])
 def setUp(self):
     self.event_list = mock_get_workflow_execution_history()
     self.history = History.from_event_list(self.event_list['events'])
Exemple #6
0
    def poll(self, task_list=None, identity=None, **kwargs):
        """
        Polls a decision task and returns the token and the full history of the
        workflow's events.

        :param task_list: task list to poll for decision tasks from.
        :type task_list: str

        :param identity: Identity of the decider making the request,
        which is recorded in the DecisionTaskStarted event in the
        workflow history.
        :type identity: str

        :returns: a Response object with history, token, and execution set
        :rtype: swf.responses.Response

        """
        task_list = task_list or self.task_list

        task = self.connection.poll_for_decision_task(self.domain.name,
                                                      task_list=task_list,
                                                      identity=identity,
                                                      **kwargs)
        token = task.get('taskToken')
        if token is None:
            raise PollTimeout("Decider poll timed out")

        events = task['events']

        next_page = task.get('nextPageToken')
        while next_page:
            try:
                task = self.connection.poll_for_decision_task(
                    self.domain.name,
                    task_list=task_list,
                    identity=identity,
                    next_page_token=next_page,
                    **kwargs)
            except boto.exception.SWFResponseError as e:
                if e.error_code == 'UnknownResourceFault':
                    raise DoesNotExistError(
                        "Unable to poll decision task",
                        e.body['message'],
                    )

                raise ResponseError(e.body['message'])

            token = task.get('taskToken')
            if token is None:
                raise PollTimeout("Decider poll timed out")

            events.extend(task['events'])
            next_page = task.get('nextPageToken')

        history = History.from_event_list(events)

        workflow_type = WorkflowType(
            domain=self.domain,
            name=task['workflowType']['name'],
            version=task['workflowType']['version'],
        )
        execution = WorkflowExecution(
            domain=self.domain,
            workflow_id=task['workflowExecution']['workflowId'],
            run_id=task['workflowExecution']['runId'],
            workflow_type=workflow_type,
        )

        # TODO: move history into execution (needs refactoring on WorkflowExecution.history())
        return Response(token=token, history=history, execution=execution)
    def poll_for_task(self, task_list=None,
             identity=None,
             **kwargs):
        """
        Polls a decision task and returns the token and the full history of the
        workflow's events.

        :param task_list: task list to poll for decision tasks from.
        :type task_list: string

        :param identity: Identity of the decider making the request,
        which is recorded in the DecisionTaskStarted event in the
        workflow history.
        :type identity: string

        :returns: a Response object with history, token, and execution set
        :rtype: swf.responses.Response(token, history, execution)

        """
        task_list = task_list or self.task_list

        task = self.connection.poll_for_decision_task(
            self.domain.name,
            task_list=task_list,
            identity=identity,
            **kwargs
        )
        token = task.get('taskToken')
        if token is None:
            raise PollTimeout("Decider poll timed out")

        events = task['events']

        next_page = task.get('nextPageToken')
        while next_page:
            try:
                task = self.connection.poll_for_decision_task(
                    self.domain.name,
                    task_list=task_list,
                    identity=identity,
                    next_page_token=next_page,
                    **kwargs
                )
            except boto.exception.SWFResponseError as e:
                if e.error_code == 'UnknownResourceFault':
                    raise DoesNotExistError(
                        "Unable to poll decision task.\n",
                        e.body['message'],
                    )

                raise ResponseError(e.body['message'])

            token = task.get('taskToken')
            if token is None:
                raise PollTimeout("Decider poll timed out")

            events.extend(task['events'])
            next_page = task.get('nextPageToken')

        history = History.from_event_list(events)

        workflow_type = WorkflowType(
            domain=self.domain,
            name=task['workflowType']['name'],
            version=task['workflowType']['version'],
        )
        execution = WorkflowExecution(
            domain=self.domain,
            workflow_id=task['workflowExecution']['workflowId'],
            run_id=task['workflowExecution']['runId'],
            workflow_type=workflow_type,
        )

        # TODO: move history into execution (needs refactoring on WorkflowExecution.history())
        return Response(token=token, history=history, execution=execution)
Exemple #8
0
    def poll(self, task_list=None,
             identity=None,
             **kwargs):
        """
        Polls a decision task and returns the token and the full history of the
        workflow's events.

        :param task_list: task list to poll for decision tasks from.
        :type task_list: string

        :param identity: Identity of the decider making the request,
        which is recorded in the DecisionTaskStarted event in the
        workflow history.
        :type identity: string

        :returns: (token, history)
        :type: swf.models.History

        """
        task_list = task_list or self.task_list

        task = self.connection.poll_for_decision_task(
            self.domain.name,
            task_list=task_list,
            identity=identity,
            **kwargs
        )
        token = task.get('taskToken')
        if token is None:
            raise PollTimeout("Decider poll timed out")

        events = task['events']

        next_page = task.get('nextPageToken')
        while next_page:
            try:
                task = self.connection.poll_for_decision_task(
                    self.domain.name,
                    task_list=task_list,
                    identity=identity,
                    next_page_token=next_page,
                    **kwargs
                )
            except boto.exception.SWFResponseError as e:
                if e.error_code == 'UnknownResourceFault':
                    raise DoesNotExistError(
                        "Unable to poll decision task.\n",
                        e.body['message'],
                    )

                raise ResponseError(e.body['message'])

            token = task.get('taskToken')
            if token is None:
                raise PollTimeout("Decider poll timed out")

            events.extend(task['events'])
            next_page = task.get('nextPageToken')

        history = History.from_event_list(events)

        return token, history
Exemple #9
0
    def poll(self, task_list=None, identity=None, **kwargs):
        """
        Polls a decision task and returns the token and the full history of the
        workflow's events.

        :param task_list: task list to poll for decision tasks from.
        :type task_list: str

        :param identity: Identity of the decider making the request,
        which is recorded in the DecisionTaskStarted event in the
        workflow history.
        :type identity: str

        :returns: a Response object with history, token, and execution set
        :rtype: swf.responses.Response

        """
        logging_context.reset()
        task_list = task_list or self.task_list

        task = self.connection.poll_for_decision_task(
            self.domain.name,
            task_list=task_list,
            identity=format.identity(identity),
            **kwargs)
        token = task.get("taskToken")
        if not token:
            raise PollTimeout("Decider poll timed out")

        events = task["events"]
        logging_context.set("workflow_id",
                            task["workflowExecution"]["workflowId"])
        logging_context.set("task_type", "decision")
        logging_context.set("event_id", task["startedEventId"])

        next_page = task.get("nextPageToken")
        while next_page:
            try:
                task = self.connection.poll_for_decision_task(
                    self.domain.name,
                    task_list=task_list,
                    identity=format.identity(identity),
                    next_page_token=next_page,
                    **kwargs)
            except boto.exception.SWFResponseError as e:
                message = self.get_error_message(e)
                if e.error_code == "UnknownResourceFault":
                    raise DoesNotExistError(
                        "Unable to poll decision task",
                        message,
                    )

                raise ResponseError(message)

            token = task.get("taskToken")
            if not token:
                raise PollTimeout("Decider poll timed out")

            events.extend(task["events"])
            next_page = task.get("nextPageToken")

        history = History.from_event_list(events)

        workflow_type = WorkflowType(
            domain=self.domain,
            name=task["workflowType"]["name"],
            version=task["workflowType"]["version"],
        )
        execution = WorkflowExecution(
            domain=self.domain,
            workflow_id=task["workflowExecution"]["workflowId"],
            run_id=task["workflowExecution"]["runId"],
            workflow_type=workflow_type,
        )

        # TODO: move history into execution (needs refactoring on WorkflowExecution.history())
        return Response(token=token, history=history, execution=execution)