You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
Class: AWS::SimpleWorkflow::WorkflowExecution
- Inherits:
-
Resource
- Object
- Core::Resource
- Resource
- AWS::SimpleWorkflow::WorkflowExecution
- Defined in:
- lib/aws/simple_workflow/workflow_execution.rb
Instance Attribute Summary collapse
-
#child_policy ⇒ Symbol
readonly
The policy to use for the child workflow executions if this workflow execution is terminated.
-
#closed_at ⇒ Time?
readonly
The time when the workflow execution was closed.
-
#domain ⇒ Domain
readonly
The domain this workflow execution was started in.
-
#latest_activity_task_scheduled_at ⇒ Time?
readonly
The time when the last activity task was scheduled for this workflow execution.
-
#latest_execution_context ⇒ String?
readonly
The latest execution context provided by the decider for this workflow execution.
-
#open_counts ⇒ Hash
readonly
Returns a hash of counts, including:
:open_timers
,:open_child_workflow_executions
,:open_decision_tasks
, and:open_activity_tasks
. -
#run_id ⇒ String
readonly
The run id of this execution.
-
#start_to_close_timeout ⇒ String
readonly
The total allowed duration for this workflow execution.
-
#started_at ⇒ Time
readonly
The time when the execution was started.
-
#task_list ⇒ String
readonly
The task list used for the decision tasks generated for this workflow execution.
-
#task_priority ⇒ String
readonly
The task priority used for the decision tasks generated for this workflow execution.
-
#task_start_to_close_timeout ⇒ String
readonly
The maximum duration allowed for decision tasks for this workflow execution.
-
#workflow_id ⇒ String
readonly
The workflow id of this execution.
Instance Method Summary collapse
-
#cancel_requested? ⇒ Boolean
Returns true if a request was made to cancel this workflow execution.
-
#closed? ⇒ Boolean
Returns true if the workflow execution is closed.
-
#count_executions(options = {}) ⇒ Integer
Counts the number of executions that share the same workflow id.
-
#history_events ⇒ HistoryEventCollection
(also: #events)
Returns a collection that enumerates history events for this workflow execution.
-
#initialize(domain, workflow_id, run_id, options = {}) ⇒ WorkflowExecution
constructor
A new instance of WorkflowExecution.
-
#open? ⇒ Boolean
Returns true if the workflow execution is still open.
-
#open_activity_task_count ⇒ Integer
Returns the number of open activity tasks.
-
#open_child_workflow_execution_count ⇒ Boolean
Returns true if this workflow execution has an open decision task.
-
#open_decision_task_count ⇒ Integer
Returns the number of closed activity tasks.
-
#open_timer_count ⇒ Integer
Returns the number of open timers.
-
#parent ⇒ WorkflowExecution?
Returns the parent workflow execution (if there is one).
-
#request_cancel ⇒ nil
Records a WorkflowExecutionCancelRequested event in the currently running workflow execution.
-
#signal(signal_name, options = {}) ⇒ nil
Records a WorkflowExecutionSignaled event in the workflow execution history and creates a decision task for the workflow execution.
-
#status ⇒ Symbol
Returns the status of this execution.
-
#tags ⇒ Array<String>
Returns an array of tags assigned to this execution.
-
#terminate(options = {}) ⇒ nil
Records a WorkflowExecutionTerminated event and forces closure of the workflow execution.
-
#workflow_type ⇒ WorkflowType
Returns the type of this workflow execution.
Constructor Details
#initialize(domain, workflow_id, run_id, options = {}) ⇒ WorkflowExecution
Returns a new instance of WorkflowExecution
69 70 71 72 73 74 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 69 def initialize domain, workflow_id, run_id, = {} @domain = domain @workflow_id = workflow_id @run_id = run_id super end |
Instance Attribute Details
#child_policy ⇒ Symbol (readonly)
The policy to use for the child workflow executions if this workflow execution is terminated. The return value will be one of the following values:
:terminate
- the child executions will be terminated.:request_cancel
- a request to cancel will be attempted for each child execution by recording a WorkflowExecutionCancelRequested event in its history. It is up to the decider to take appropriate actions when it receives an execution history with this event.:abandon
- no action will be taken. The child executions will continue to run.
67 68 69 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 67 def child_policy @child_policy end |
#closed_at ⇒ Time? (readonly)
The time when the workflow execution was closed. Returns nil if this execution is not closed.
67 68 69 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 67 def closed_at @closed_at end |
#domain ⇒ Domain (readonly)
Returns The domain this workflow execution was started in.
77 78 79 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 77 def domain @domain end |
#latest_activity_task_scheduled_at ⇒ Time? (readonly)
The time when the last activity task was scheduled for this workflow execution. You can use this information to determine if the workflow has not made progress for an unusually long period of time and might require a corrective action.
67 68 69 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 67 def latest_activity_task_scheduled_at @latest_activity_task_scheduled_at end |
#latest_execution_context ⇒ String? (readonly)
The latest execution context provided by the decider for this workflow execution. A decider can provide an execution context, which is a free form string, when closing a decision task.
67 68 69 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 67 def latest_execution_context @latest_execution_context end |
#open_counts ⇒ Hash (readonly)
Returns a hash of counts, including:
:open_timers
, :open_child_workflow_executions
, :open_decision_tasks
,
and :open_activity_tasks
.
67 68 69 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 67 def open_counts @open_counts end |
#run_id ⇒ String (readonly)
Returns The run id of this execution.
83 84 85 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 83 def run_id @run_id end |
#start_to_close_timeout ⇒ String (readonly)
The total allowed duration for this workflow execution.
The return value will be formatted as an ISO 8601 duration (e.g. 'PnYnMnDTnHnMnS').
67 68 69 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 67 def start_to_close_timeout @start_to_close_timeout end |
#started_at ⇒ Time (readonly)
The time when the execution was started.
67 68 69 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 67 def started_at @started_at end |
#task_list ⇒ String (readonly)
The task list used for the decision tasks generated for this workflow execution.
67 68 69 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 67 def task_list @task_list end |
#task_priority ⇒ String (readonly)
The task priority used for the decision tasks generated for this workflow execution.
67 68 69 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 67 def task_priority @task_priority end |
#task_start_to_close_timeout ⇒ String (readonly)
The maximum duration allowed for decision tasks for this workflow execution.
The return value will be formatted as an ISO 8601 duration (e.g. 'PnYnMnDTnHnMnS').
67 68 69 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 67 def task_start_to_close_timeout @task_start_to_close_timeout end |
#workflow_id ⇒ String (readonly)
Returns The workflow id of this execution.
80 81 82 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 80 def workflow_id @workflow_id end |
Instance Method Details
#cancel_requested? ⇒ Boolean
Returns true if a request was made to cancel this workflow execution.
190 191 192 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 190 def cancel_requested? cancel_requested end |
#closed? ⇒ Boolean
Returns true if the workflow execution is closed.
200 201 202 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 200 def closed? !open? end |
#count_executions(options = {}) ⇒ Integer
See AWS::SimpleWorkflow::WorkflowExecutionCollection#count for a broader count.
This operation is eventually consistent. The results are best effort and may not exactly reflect recent updates and changes.
Counts the number of executions that share the same workflow id.
371 372 373 374 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 371 def count_executions = {} [:workflow_id] = workflow_id domain.workflow_executions.count() end |
#history_events ⇒ HistoryEventCollection Also known as: events
Returns a collection that enumerates history events for this workflow execution.
233 234 235 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 233 def history_events HistoryEventCollection.new(self) end |
#open? ⇒ Boolean
Returns true if the workflow execution is still open.
195 196 197 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 195 def open? status == :open end |
#open_activity_task_count ⇒ Integer
Returns the number of open activity tasks.
211 212 213 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 211 def open_activity_task_count open_counts[:open_activity_tasks] end |
#open_child_workflow_execution_count ⇒ Boolean
Returns true if this workflow execution has an open decision task.
206 207 208 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 206 def open_child_workflow_execution_count open_counts[:open_child_workflow_executions] end |
#open_decision_task_count ⇒ Integer
Returns the number of closed activity tasks.
221 222 223 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 221 def open_decision_task_count open_counts[:open_decision_tasks] end |
#open_timer_count ⇒ Integer
Returns the number of open timers.
216 217 218 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 216 def open_timer_count open_counts[:open_timers] end |
#parent ⇒ WorkflowExecution?
Returns the parent workflow execution (if there is one).
246 247 248 249 250 251 252 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 246 def parent if parent = self.parent_details domain.workflow_executions[parent['workflowId'],parent['runId']] else nil end end |
#request_cancel ⇒ nil
Because this action allows the workflow to properly clean up and gracefully close, it should be used instead of #terminate when possible.
Records a WorkflowExecutionCancelRequested event in the currently running workflow execution. This logically requests the cancellation of the workflow execution as a whole. It is up to the decider to take appropriate actions when it receives an execution history with this event.
287 288 289 290 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 287 def request_cancel = { :run_id => run_id } domain.workflow_executions.request_cancel(workflow_id, ) end |
#signal(signal_name, options = {}) ⇒ nil
Records a WorkflowExecutionSignaled event in the workflow execution history and creates a decision task for the workflow execution.
workflow_execution.signal('signal_name', :input => '...')
270 271 272 273 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 270 def signal signal_name, = {} [:run_id] = run_id domain.workflow_executions.signal(workflow_id, signal_name, ) end |
#status ⇒ Symbol
Returns the status of this execution. Possible return values are:
:open
- The execution is still running.:completed
- The execution was successfully completed.:canceled
- The execution was canceled, cancellation allows the implementation to gracefully clean up before the execution is closed.:failed
- The execution failed to complete. and was automatically timed out.:continued_as_new
- The execution is logically continued. This means the current execution was completed and a new execution was started to carry on the workflow.:terminated
- The execution was force terminated.:timed_out
- The execution did not complete in the allotted time and was automatically timed out.
182 183 184 185 186 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 182 def status AWS.memoize do execution_status == :open ? :open : (close_status || :closed) end end |
#tags ⇒ Array<String>
Returns an array of tags assigned to this execution.
227 228 229 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 227 def tag_list || [] end |
#terminate(options = {}) ⇒ nil
If the workflow execution was in progress, it is terminated immediately.
You should consider canceling the workflow execution instead because it allows the workflow to gracefully close while terminate does not.
Records a WorkflowExecutionTerminated event and forces closure of the workflow execution. The child policy, registered with the workflow type or specified when starting this execution, is applied to any open child workflow executions of this workflow execution.
329 330 331 332 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 329 def terminate = {} [:run_id] = run_id domain.workflow_executions.terminate(workflow_id, ) end |
#workflow_type ⇒ WorkflowType
Returns the type of this workflow execution.
239 240 241 242 |
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 239 def workflow_type type = self.type_details WorkflowType.new(domain, type['name'], type['version']) end |