Class: AWS::SimpleWorkflow::ActivityTask
- Inherits:
-
Object
- Object
- AWS::SimpleWorkflow::ActivityTask
- Defined in:
- lib/aws/simple_workflow/activity_task.rb
Defined Under Namespace
Classes: CancelRequestedError
Instance Attribute Summary collapse
-
#activity_id ⇒ String
readonly
The unique identifier of this task.
- #activity_type ⇒ ActivityType readonly
-
#domain ⇒ Domain
readonly
The domain this task was scheduled in.
-
#input ⇒ String?
readonly
The input provided when the activity task was scheduled.
-
#started_event_id ⇒ Integer
readonly
The id of the ActivityTaskStarted event recorded in the history.
-
#task_token ⇒ String
readonly
The opaque string used as a handle on the task.
- #workflow_execution ⇒ WorkflowExecution readonly
Instance Method Summary collapse
- #cancel!(options = {}) ⇒ nil
- #complete!(options = {}) ⇒ nil
- #fail!(options = {}) ⇒ nil
-
#record_heartbeat!(options = {}) ⇒ Object
Reports to the service that the activity task is progressing.
- #responded? ⇒ Boolean
Instance Attribute Details
#activity_id ⇒ String (readonly)
Returns The unique identifier of this task.
50 51 52 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 50 def activity_id @activity_id end |
#activity_type ⇒ ActivityType (readonly)
64 65 66 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 64 def activity_type @activity_type end |
#domain ⇒ Domain (readonly)
Returns The domain this task was scheduled in.
53 54 55 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 53 def domain @domain end |
#input ⇒ String? (readonly)
Returns The input provided when the activity task was scheduled.
61 62 63 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 61 def input @input end |
#started_event_id ⇒ Integer (readonly)
Returns The id of the ActivityTaskStarted event recorded in the history.
57 58 59 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 57 def started_event_id @started_event_id end |
#task_token ⇒ String (readonly)
Returns The opaque string used as a handle on the task.
47 48 49 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 47 def task_token @task_token end |
#workflow_execution ⇒ WorkflowExecution (readonly)
67 68 69 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 67 def workflow_execution @workflow_execution end |
Instance Method Details
#cancel!(options = {}) ⇒ nil
142 143 144 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 142 def cancel! = {} respond :canceled, end |
#complete!(options = {}) ⇒ nil
132 133 134 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 132 def complete! = {} respond :completed, end |
#fail!(options = {}) ⇒ nil
154 155 156 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 154 def fail! = {} respond :failed, end |
#record_heartbeat!(options = {}) ⇒ Object
Reports to the service that the activity task is progressing.
You can optionally specify :details
that describe the progress. This might be a percentage competition, step number, etc.
activity_task.record_heartbeat! :details => '.75' # 75% complete
If the activity task has been canceled since it was received or since the last recorded heartbeat, this method will raise a CancelRequestedError.
If you are processing the activity task inside a block passed to one of the polling methods in AWS::SimpleWorkflow::ActivityTaskCollection then untrapped CancelRequestedErrors are caught and responded to automatically.
domain.activity_tasks.poll('task-list') do |task|
task.record_heartbeat! # raises CancelRequestedError
end # traps the error and responds activity task canceled.
If you need to cleanup or provide additional details in the cancellation response, you can trap the error and respond manually.
domain.activity_tasks.poll('task-list') do |task|
task.record_heartbeat! # raises CancelRequestedError
rescue CancelRequestedError => e
# cleanup
task.respond_canceled! :details => '...'
end
112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 112 def record_heartbeat! = {} client_opts = {} client_opts[:task_token] = task_token client_opts[:details] = [:details] if [:details] response = client.record_activity_task_heartbeat(client_opts) raise CancelRequestedError if response.data['cancelRequested'] nil end |
#responded? ⇒ Boolean
158 159 160 |
# File 'lib/aws/simple_workflow/activity_task.rb', line 158 def responded? !!@responded end |