Class: AWS::SimpleWorkflow::WorkflowExecution

Inherits:
Resource
  • Object
show all
Defined in:
lib/aws/simple_workflow/workflow_execution.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain, workflow_id, run_id, options = {}) ⇒ WorkflowExecution



66
67
68
69
70
71
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 66

def initialize domain, workflow_id, run_id, options = {}
  @domain = domain
  @workflow_id = workflow_id
  @run_id = run_id
  super
end

Instance Attribute Details

#child_policySymbol (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.


64
65
66
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 64

def child_policy
  @child_policy
end

#closed_atTime? (readonly)

The time when the workflow execution was closed. Returns nil if this execution is not closed.



64
65
66
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 64

def closed_at
  @closed_at
end

#domainDomain (readonly)



74
75
76
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 74

def domain
  @domain
end

#latest_activity_task_scheduled_atTime? (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.



64
65
66
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 64

def latest_activity_task_scheduled_at
  @latest_activity_task_scheduled_at
end

#latest_execution_contextString? (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.



64
65
66
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 64

def latest_execution_context
  @latest_execution_context
end

#open_countsHash (readonly)

Returns a hash of counts, including: :open_timers, :open_child_workflow_executions, :open_decision_tasks, and :open_activity_tasks.



64
65
66
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 64

def open_counts
  @open_counts
end

#run_idString (readonly)



80
81
82
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 80

def run_id
  @run_id
end

#start_to_close_timeoutString (readonly)

The total allowed duration for this workflow execution.

The return value will be formatted as an ISO 8601 duration (e.g. 'PnYnMnDTnHnMnS').



64
65
66
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 64

def start_to_close_timeout
  @start_to_close_timeout
end

#started_atTime (readonly)

The time when the execution was started.



64
65
66
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 64

def started_at
  @started_at
end

#task_listString (readonly)

The task list used for the decision tasks generated for this workflow execution.



64
65
66
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 64

def task_list
  @task_list
end

#task_start_to_close_timeoutString (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').



64
65
66
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 64

def task_start_to_close_timeout
  @task_start_to_close_timeout
end

#workflow_idString (readonly)



77
78
79
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 77

def workflow_id
  @workflow_id
end

Instance Method Details

#cancel_requested?Boolean



183
184
185
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 183

def cancel_requested?
  cancel_requested
end

#closed?Boolean



193
194
195
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 193

def closed?
  !open?
end

#count_executions(options = {}) ⇒ Integer

Note:

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.

Options Hash (options):

  • :status (Symbol) — default: :open

    Specifies that status of the workflow executions to count. Defaults to open workflows.

    • :open
    • :closed
  • :started_between (Array<Time>)

    A start and end time to filter workflow execution start times by. You may pass an array with two time values or a range. Times should be timestamps (integers), Time, Date, DateTime or parseable time strings.

    You may not pass both :started_between and :closed_between.

  • :closed_between (Array<Time>)

    A start and end time to filter workflow execution closed times by. You may pass an array with two time values or a range. Times should be timestamps (integers), Time, Date, DateTime or parseable time strings.

    You may not pass both :started_between and :closed_between. You may also not pass :closed_between if the :status is :open.



364
365
366
367
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 364

def count_executions options = {}
  options[:workflow_id] = workflow_id
  domain.workflow_executions.count(options)
end

#history_eventsHistoryEventCollection Also known as: events



226
227
228
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 226

def history_events
  HistoryEventCollection.new(self)
end

#open?Boolean



188
189
190
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 188

def open?
  status == :open
end

#open_activity_task_countInteger



204
205
206
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 204

def open_activity_task_count
  open_counts[:open_activity_tasks]
end

#open_child_workflow_execution_countBoolean



199
200
201
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 199

def open_child_workflow_execution_count
  open_counts[:open_child_workflow_executions]
end

#open_decision_task_countInteger



214
215
216
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 214

def open_decision_task_count
  open_counts[:open_decision_tasks]
end

#open_timer_countInteger



209
210
211
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 209

def open_timer_count
  open_counts[:open_timers]
end

#parentWorkflowExecution?



239
240
241
242
243
244
245
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 239

def parent
  if parent = self.parent_details
    domain.workflow_executions[parent['workflowId'],parent['runId']]
  else
    nil
  end
end

#request_cancelnil

Note:

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.



280
281
282
283
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 280

def request_cancel
  options = { :run_id => run_id }
  domain.workflow_executions.request_cancel(workflow_id, options)
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 => '...')

Options Hash (options):

  • :input (String) — default: nil

    Data to attach to the WorkflowExecutionSignaled event in the target workflow execution's history.



263
264
265
266
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 263

def signal signal_name, options = {}
  options[:run_id] = run_id
  domain.workflow_executions.signal(workflow_id, signal_name, options)
end

#statusSymbol



175
176
177
178
179
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 175

def status
  AWS.memoize do
    execution_status == :open ? :open : (close_status || :closed)
  end
end

#tagsArray<String>



220
221
222
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 220

def tags
  tag_list || []
end

#terminate(options = {}) ⇒ nil

Note:

If the workflow execution was in progress, it is terminated immediately.

Note:

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.

Options Hash (options):

  • :child_policy (Symbol) — default: nil

    If set, specifies the policy to use for the child workflow executions of the workflow execution being terminated. This policy overrides the default child policy. Valid policies include:

    • :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.

  • :details (String) — default: nil

    Optional details for terminating the workflow execution.

  • :reason (String) — default: nil

    An optional descriptive reason for terminating the workflow execution.



322
323
324
325
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 322

def terminate options = {}
  options[:run_id] = run_id
  domain.workflow_executions.terminate(workflow_id, options)
end

#workflow_typeWorkflowType



232
233
234
235
# File 'lib/aws/simple_workflow/workflow_execution.rb', line 232

def workflow_type
  type = self.type_details
  WorkflowType.new(domain, type['name'], type['version'])
end