Class: AWS::SimpleWorkflow::WorkflowExecutionCollection
- Inherits:
-
Object
- Object
- AWS::SimpleWorkflow::WorkflowExecutionCollection
- Includes:
- Core::Collection::Limitable
- Defined in:
- lib/aws/simple_workflow/workflow_execution_collection.rb
Overview
A collection that enumerates workflow executions.
domain.workflow_executions.each do |execution|
# ...
end
Filtering Executions
By default, all open workflow executions are enumerated.
Instance Attribute Summary collapse
-
#domain ⇒ Domain
readonly
Returns the domain this execution was started in.
Instance Method Summary collapse
-
#at(workflow_id, run_id) ⇒ WorkflowExecution
(also: #[])
Returns the workflow execution with the given
workflow_id
andrun_id
. -
#closed_after(time) ⇒ WorkflowExecutionCollection
Filters workflow executions by their close date.
-
#closed_before(time) ⇒ WorkflowExecutionCollection
Filters workflow executions by their close date.
-
#closed_between(oldest_time, latest_time) ⇒ WorkflowExecutionCollection
Filters workflow executions by their close date.
-
#count(options = {}) ⇒ Count
Returns the number of workflow executions within the domain that meet the specified filtering criteria.
-
#each(options = {}) ⇒ nil_or_next_token
Enumerates workflow executions.
-
#request_cancel(workflow_id, options = {}) ⇒ nil
Records a WorkflowExecutionCancelRequested event in the currently running workflow execution identified.
-
#reverse_order ⇒ WorkflowExecutionCollection
Returns a collection that enumerates workflow executions in reverse chronological order.
-
#signal(workflow_id, signal_name, options = {}) ⇒ nil
Records a WorkflowExecutionSignaled event in the workflow execution history and creates a decision task for the workflow execution.
-
#started_after(time) ⇒ WorkflowExecutionCollection
Filters workflow executions by their start date.
-
#started_before(time) ⇒ WorkflowExecutionCollection
Filters workflow executions by their start date.
-
#started_between(oldest_time, latest_time) ⇒ WorkflowExecutionCollection
Filters workflow executions by their start date.
-
#tagged(tag) ⇒ WorkflowExecutionCollection
Returns a collection that will only enumerate or count executions that have the given
tag
. -
#terminate(workflow_id, options = {}) ⇒ nil
Records a WorkflowExecutionTerminated event and forces closure of the workflow execution identified.
-
#with_status(status) ⇒ WorkflowExecutionCollection
Returns a collection that will only enumerate or count executions of the given status.
-
#with_workflow_id(workflow_id) ⇒ WorkflowExecutionCollection
Returns a collection that will only enumerate or count executions that have the given
workflow_id
. -
#with_workflow_type(workflow_type) ⇒ WorkflowExecutionCollection
Returns a collection that will only enumerate or count executions that have the given
workflow_type
.
Methods included from Core::Collection::Limitable
Methods included from Core::Collection
#each_batch, #enum, #first, #in_groups_of, #page
Instance Attribute Details
#domain ⇒ Domain (readonly)
Returns the domain this execution was started in.
63 64 65 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 63 def domain @domain end |
Instance Method Details
#at(workflow_id, run_id) ⇒ WorkflowExecution Also known as: []
Returns the workflow execution with the given workflow_id
and run_id
.
# get a reference to a single workflow execution
domain.workflow_executions['workflow-id', 'run-id']
domain.workflow_executions.at('workflow-id', 'run-id')
78 79 80 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 78 def at workflow_id, run_id WorkflowExecution.new(domain, workflow_id, run_id) end |
#closed_after(time) ⇒ WorkflowExecutionCollection
It is not possible to filter by both start time and close time.
Filters workflow executions by their close date.
# executions that closed within the last hour
domain.workflow_executions.closed_after(Time.now - 3600)
373 374 375 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 373 def closed_after time collection_with(:closed_after => time) end |
#closed_before(time) ⇒ WorkflowExecutionCollection
It is not possible to filter by both start time and close time.
Filters workflow executions by their close date.
# executions that closed more than an hour ago
domain.workflow_executions.closed_before(Time.now - 3600)
354 355 356 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 354 def closed_before time collection_with(:closed_before => time) end |
#closed_between(oldest_time, latest_time) ⇒ WorkflowExecutionCollection
It is not possible to filter by both start time and close time.
Filters workflow executions by their close date.
335 336 337 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 335 def closed_between oldest_time, latest_time closed_after(oldest_time).closed_before(latest_time) end |
#count(options = {}) ⇒ Count
You may only pass one of the following options: :workflow_id
, :workflow_type
, :tagged
or :status
with a “closed” value (:status
with :open
is okay).
This operation is eventually consistent. The results are best effort and may not exactly reflect recent updates and changes.
Returns the number of workflow executions within the domain that meet the specified filtering criteria. Counts can be truncated so you should check the return value.
count = domain.workflow_executions.count
puts(count.truncated? ? "#{count.to_i}+" : count.to_i)
470 471 472 473 474 475 476 477 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 470 def count = {} open_or_closed, client_opts = () client_method = :"count_#{open_or_closed}_workflow_executions" response = client.send(client_method, client_opts) Count.new(response.data['count'], response.data['truncated']) end |
#each(options = {}) ⇒ nil_or_next_token
You may only pass one of the following options: :workflow_id
, :workflow_type
, :tagged
or :status
with a “closed” value (:status
with :open
is okay).
This operation is eventually consistent. The results are best effort and may not exactly reflect recent updates and changes.
Enumerates workflow executions.
489 490 491 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 489 def each = {} super end |
#request_cancel(workflow_id, options = {}) ⇒ nil
If the :run_id
is not specified, the WorkflowExecutionCancelRequested event is recorded in the history of the current open workflow execution with the specified workflow_id
in the domain.
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 identified. 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.
140 141 142 143 144 145 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 140 def request_cancel workflow_id, = {} [:domain] = domain.name [:workflow_id] = workflow_id client.request_cancel_workflow_execution() nil end |
#reverse_order ⇒ WorkflowExecutionCollection
Returns a collection that enumerates workflow executions in reverse chronological order. By default exeuctions are enumerated in ascending order of their start or close time (ordered by close time when filtered by #closed_between).
# get the latest execution
execution = domain.workflow_executions.reverse_order.first
388 389 390 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 388 def reverse_order collection_with(:reverse_order => true) end |
#signal(workflow_id, signal_name, options = {}) ⇒ nil
Records a WorkflowExecutionSignaled event in the workflow execution history and creates a decision task for the workflow execution.
domain.signal_workflow_execution('workflowid', 'newdata', :input => '...')
108 109 110 111 112 113 114 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 108 def signal workflow_id, signal_name, = {} [:domain] = domain.name [:workflow_id] = workflow_id [:signal_name] = signal_name client.signal_workflow_execution() nil end |
#started_after(time) ⇒ WorkflowExecutionCollection
It is not possible to filter by both start time and close time.
Filters workflow executions by their start date.
# executions that started within the last hour
domain.workflow_executions.started_after(Time.now - 3600)
315 316 317 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 315 def started_after time collection_with(:started_after => time) end |
#started_before(time) ⇒ WorkflowExecutionCollection
It is not possible to filter by both start time and close time.
Filters workflow executions by their start date.
# executions that started at least an hour ago
domain.workflow_executions.started_before(Time.now - 3600)
296 297 298 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 296 def started_before time collection_with(:started_before => time) end |
#started_between(oldest_time, latest_time) ⇒ WorkflowExecutionCollection
It is not possible to filter by both start time and close time.
Filters workflow executions by their start date.
277 278 279 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 277 def started_between oldest_time, latest_time started_after(oldest_time).started_before(latest_time) end |
#tagged(tag) ⇒ WorkflowExecutionCollection
Returns a collection that will only enumerate or count executions that have the given tag
.
257 258 259 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 257 def tagged tag collection_with(:tagged => tag) end |
#terminate(workflow_id, options = {}) ⇒ nil
If the workflow execution was in progress, it is terminated immediately.
If a :run_id
is not specified, then the WorkflowExecutionTerminated event is recorded in the history of the current open workflow with the matching workflowId in the domain.
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 identified. 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.
198 199 200 201 202 203 204 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 198 def terminate workflow_id, = {} [:domain] = domain.name [:workflow_id] = workflow_id upcase_opts(, :child_policy) client.terminate_workflow_execution() nil end |
#with_status(status) ⇒ WorkflowExecutionCollection
Returns a collection that will only enumerate or count executions of the given status.
226 227 228 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 226 def with_status status collection_with(:status => status) end |
#with_workflow_id(workflow_id) ⇒ WorkflowExecutionCollection
Returns a collection that will only enumerate or count executions that have the given workflow_id
.
236 237 238 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 236 def with_workflow_id workflow_id collection_with(:workflow_id => workflow_id) end |
#with_workflow_type(workflow_type) ⇒ WorkflowExecutionCollection
Returns a collection that will only enumerate or count executions that have the given workflow_type
.
247 248 249 |
# File 'lib/aws/simple_workflow/workflow_execution_collection.rb', line 247 def with_workflow_type workflow_type collection_with(:workflow_type => workflow_type) end |