class AWS::SimpleWorkflow


See {HistoryEvent} and {HistoryEvent::Attributes} for more information.
end
puts event.attributes.to_h.inspect
execution.events.each do |event|
execution = domain.workflow_executions[‘workflow-id’]

id (you may optionally provide the run id as well).
execution. You can get a workflow execution by its workflow
You might want to view the event history for a running workflow
= History Events
end of a poll block.
Like decision tasks, activity tasks are auto-completed at the
end
end
activity_task.cancel!
# cleanup after ourselves
rescue ActivityTask::CancelRequestedError
# do more stuff …
activity_task.record_heartbeat! :details => ‘75%’
# do more stuff …
activity_task.record_heartbeat! :details => ‘50%’
# do more stuff …
activity_task.record_heartbeat! :details => ‘25%’
# do stuff …
begin
domain.activity_tasks.poll(‘my-task-list’) do |activity_task|
# poll ‘my-task-list’ for activities
cancel! when you are finished.
should be canceled. You can cleanup the task and then call
{ActivityTask::CancelRequestedError}. These are thrown when a task
When you call record_heartbeat you should rescue
To record a heartbeat, just call {ActivityTask#record_heartbeat!}.
with status messages. This is called recording a heartbeat.#
When you receive an activity task, you need to update the service
== Activity Task Heartbeats
end
end
activity_task.fail! :reason => ‘unknown activity task type’
else
# …
when ‘do-something’
case activity_task.activity_type.name
domain.activity_tasks.poll(‘my-task-list’) do |activity_task|
# poll ‘my-task-list’ for activities
poll for activity tasks.
on a decision task. Scheduled activity tasks are returned when you
The only way to spawn activity tasks is to call schedule_activity_task
= Activity Tasks
poll or poll_for_single_task.
decision task. This is done by default if you pass a block to
When you are done calling decision methods, you need to complete the
end # decision task is completed here
end
end
task.complete_workflow_execution :result => event.attributes.result
when ‘ActivityTaskCompleted’
task.schedule_activity_task ‘do-something’, :input => ‘abc xyz’
when ‘WorkflowExecutionStarted’
case event.event_type
task.new_events.each do |event|
# invesitate new events and make decisions
domain.decision_tasks.poll(‘my-task-list’) do |task|
# poll for decision tasks from ‘my-task-list’
by scheduling an activity task or completing the workflow execution.
This sample gets a decision task and responds based on the events
* start_child_workflow_execution workflow_type, options = {}
* request_cancel_external_workflow_execution workflow_execution, options = {}
* signal_external_workflow_execution
* cancel_timer
* start_timer
* record_marker
* continue_as_new_workflow_execution
* cancel_workflow_execution
* fail_workflow_execution
* complete_workflow_execution
* request_cancel_activity_task
* schedule_activity_task
any number of decision methods any number of times.
To make decisions you call methods from the list below. You can call
events since the last decision.
for the workflow execution. You can also enumerate only new
Yielded decsion tasks provide access to the history of events
decision tasks. You poll for decision tasks from a task list.
Once a workflow execution has been started, it will start to generte
= Decision Tasks
workflow_execution.run_id #=> “325a8c34-d133-479e-9ecf-5a61286d165f”
workflow_execution.workflow_id #=> “5abbdd75-70c7-4af3-a324-742cd29267c2”
workflow_execution = workflow_type.start_execution :input => ‘…’
workflow type.
input and override any of the defaults registered with the
random one will be generated. You may also provide optional
start a workflow execution. You may provide a workflow id, or a
Once you have a domain and at least one workflow type you can
= Starting a Workflow Execution
:default_task_start_to_close_timeout => 3600)
:default_task_schedule_to_close_timeout => 3660,
:default_task_schedule_to_start_timeout => 60,
:default_task_heartbeat_timeout => 900,
:default_task_list => ‘my-task-list’,
activity_type = domain.activity_types.create(‘do-something’, ‘1’,
# register an activity type, with the version id ‘1’
:default_execution_start_to_close_timeout => 24 * 3600)
:default_task_start_to_close_timeout => 3600,
:default_child_policy => :request_cancel,
:default_task_list => ‘my-task-list’,
workflow_type = domain.workflow_types.create(‘my-long-processes’, ‘1’,
# register an workflow type with the version id ‘1’
== Sample Workflow type and activity type
an activity task.
the actual values when starting a workflow execution or scheduling
optional default values when creating the type, you MUST specify
(e.g. default task list, timeouts, etc). If you do not specify these
Workflow and Acitivity types both have a number of default values
can be used to start workflow executions or schedule activity tasks.
activity types. Both types (workflow and activity) are templates that
Once you have a domain you can create a workflow and
= Workflow and Activity Types
domain = swf.domains[‘my-domain’]

You can reference existin domains as well.
domain = swf.domains.create(‘my-domain’, 10)
# name the domain and specify the retention period (in days)
swf = AWS::SimpleWorkflow.new
organize related tasks and activities.
To get started, you need to first create a domain. Domains are used to
= Domains
This is the starting point for working with Amazon Simple Workflow Service.

def domains

Returns:
  • (DomainCollection) -
def domains
  DomainCollection.new(:config => config)
end