Class AWS::SimpleWorkflow::WorkflowExecutionCollection
In: lib/aws/simple_workflow/workflow_execution_collection.rb
Parent: Object

A collection that enumerates workflow executions.

    domain.workflow_executions.each do |execution|
      # ...
    end

## Filtering Executions

By default, all open workflow executions are enumerated.

Methods

Included Modules

Core::Collection::WithLimitAndNextToken OptionFormatters

Constants

FILTERS = [ :status, :workflow_type, :workflow_id, :tagged, :started_before, :started_after, :closed_before, :closed_after, ]   @api private

Attributes

domain  [R]  @return [Domain] Returns the domain this execution was started in.

Public Class methods

Public Instance methods

[](workflow_id, run_id)

Alias for at

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')

@param [String] workflow_id The workflow execution id.

@param [String] run_id The workflow execution run id.

@return [WorkflowExecution

Filters workflow executions by their close date.

    # executions that closed within the last hour
    domain.workflow_executions.closed_after(Time.now - 3600)

@note It is not possible to filter by both start time and close time.

@param [Time,DateTime,Date,Integer,String] time Should

  be one of the listed types.  Integers are treated as timestamps
  and strings are parsed by DateTime.

@return [WorkflowExecutionCollection] Returns a collection

  that will only enumerate or count executions that closed
  after the given time.

Filters workflow executions by their close date.

    # executions that closed more than an hour ago
    domain.workflow_executions.closed_before(Time.now - 3600)

@note It is not possible to filter by both start time and close time.

@param [Time,DateTime,Date,Integer,String] time Should

  be one of the listed types.  Integers are treated as timestamps
  and strings are parsed by DateTime.

@return [WorkflowExecutionCollection] Returns a collection

  that will only enumerate or count executions that closed
  before the given time.

Filters workflow executions by their close date.

@note It is not possible to filter by both start time and close time.

@param [Time,DateTime,Date,Integer,String] oldest_time Should

  be one of the listed types.  Integers are treated as timestamps
  and strings are parsed by DateTime.

@param [Time,DateTime,Date,Integer,String] latest_time Should

  be one of the listed types.  Integers are treated as timestamps
  and strings are parsed by DateTime.

@return [WorkflowExecutionCollection] Returns a collection

  that will only enumerate or count executions that closed
  between the given times.

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)

@note 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).

@note This operation is eventually consistent. The results are best

  effort and may not exactly reflect recent updates and changes.

@param [Hash] options

@option options [Symbol] :status Filters workflow executions by the

  given status.  If status is not provided then it defaults to
  `:open` unless you pass `:closed_between` (then it defaults to
  `:closed`).

  If `:status` is anything besides `:open` or `:closed` then
  it may not be passed with `:workflow_id`, `:workflow_type` or
  `:tagged`.

  Accepted values for `:status` include:

  * `:open`
  * `:closed`
  * `:completed`
  * `:failed`
  * `:canceled`
  * `:terminated`
  * `:continued`
  * `:timed_out`

@option options [Time] :started_after Filters workflow executions

  down to those started after the given time.

  You may pass `:started_after` with `:started_before`, but not with
  `:closed_after` or `:closed_before`.

@option options [Time] :started_before Filters workflow executions

  down to those started before the given time.

  You may pass `:started_after` with `:started_before`, but not with
  `:closed_after` or `:closed_before`.

@option options [Time] :closed_after Filters workflow executions

  to those closed after the given time.

  * You may pass `:closed_after` with `:closed_before`, but not with
    `:started_after` or `:started_before`.

  * This option is invalid when counting or listing open executions.

@option options [Time] :closed_before Filters workflow executions

  to those closed before the given time.

  * You may pass `:closed_after` with `:closed_before`, but not with
    `:started_after` or `:started_before`.

  * This option is invalid when counting or listing open executions.

@option options [String] :workflow_id (nil) If specified, workflow

  executions are filtered by the provided workflow id.

@option options [String] :tagged (nil) Filters workflow executions

  by the given tag.

@option options [WorkflowType,Hash] :workflow_type (nil)

  Filters workflow executions with the given workflow type.
  `:workflow_type` can be a {WorkflowType} object or a hash with
  a workflow type `:name` and `:version`.

@return [Count] Returns a possibly truncated count of

  workflow executions.

Enumerates workflow executions. @note (see count) @param (see count) @option (see count) @option (see Core::Collection#each) @option options [Boolean] :reverse_order Enumerates the workflow

  execution in reverse chronological order if `true`.  The date
  used will be the execution start time unless filtering by
  closed before/after (then it will sort by the closed time).

@return (see Core::Collection#each)

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.

@note 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.

@note Because this action allows the workflow to properly clean up

  and gracefully close, it should be used instead of {#terminate}
  when possible.

@param [String] workflow_id The id of the workflow execution to cancel.

@param [Hash] options

@option options [String] :run_id (nil) The run id of the workflow

  execution to cancel.

@return [nil]

Returns a collection that enumerates workflow executions in reverse chronological order. By default executions 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

@return [WorkflowExecutionCollection] Returns a collection

  that enumerates workflow executions in reverse order.

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 => '...')

@param [String] workflow_id The id of the workflow execution to signal.

@param [String] signal_name The name of the signal. This name must be

  meaningful to the target workflow.

@param [Hash] options

@option options [String] :input (nil) Data to attach to the

  WorkflowExecutionSignaled event in the target workflow
  execution's history.

@option options [String] :run_id (nil) The run id of the workflow

  execution to signal.

  If `:run_id` is not specified, then the WorkflowExecutionSignaled
  event is recorded in the history of the current open workflow
  with the matching workflow_id in the domain.

@return [nil]

Filters workflow executions by their start date.

    # executions that started within the last hour
    domain.workflow_executions.started_after(Time.now - 3600)

@note It is not possible to filter by both start time and close time.

@param [Time,DateTime,Date,Integer,String] time Should

  be one of the listed types.  Integers are treated as timestamps
  and strings are parsed by DateTime.

@return [WorkflowExecutionCollection] Returns a collection

  that will only enumerate or count executions that started
  after the given time.

Filters workflow executions by their start date.

    # executions that started at least an hour ago
    domain.workflow_executions.started_before(Time.now - 3600)

@note It is not possible to filter by both start time and close time.

@param [Time,DateTime,Date,Integer,String] time Should

  be one of the listed types.  Integers are treated as timestamps
  and strings are parsed by DateTime.

@return [WorkflowExecutionCollection] Returns a collection

  that will only enumerate or count executions that started
  before the given time.

Filters workflow executions by their start date.

@note It is not possible to filter by both start time and close time.

@param [Time,DateTime,Date,Integer,String] oldest_time Should

  be one of the listed types.  Integers are treated as timestamps
  and strings are parsed by DateTime.

@param [Time,DateTime,Date,Integer,String] latest_time Should

  be one of the listed types.  Integers are treated as timestamps
  and strings are parsed by DateTime.

@return [WorkflowExecutionCollection] Returns a collection

  that will only enumerate or count executions that have start
  times that fall within the given range.

@param [String] tag A tag to filter workflow executions with.

@return [WorkflowExecutionCollection] Returns a collection

  that will only enumerate or count executions that have
  the given `tag`.

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.

@note If the workflow execution was in progress, it is terminated

  immediately.

@note 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.

@note You should consider canceling the workflow execution

  instead because it allows the workflow to gracefully close
  while terminate does not.

@param [String] workflow_id

@param [Hash] options

@option options [Symbol] :child_policy (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.

@option options [String] :details Optional details for

  terminating the workflow execution.

@option options [String] :reason An optional descriptive

  reason for terminating the workflow execution.

@option options [String] :run_id The run id of the workflow

  execution to terminate. If a `:run_id` is not provided, then a
  WorkflowExecutionTerminated event is recorded in the history of
  the current open workflow with the matching workflow id in the
  domain.

@return [nil]

@param [Symbol] status Causes the returned collection to filter

  executions by the given status. Accepted statuses include:

  * `:open`
  * `:closed`
  * `:completed`
  * `:failed`
  * `:canceled`
  * `:terminated`
  * `:continued`
  * `:timed_out`

  If `:status` is anything besides `:open` or `:closed` then
  it may not be used in combination with `workflow_id`,
  `workflow_type` or `tagged`.

@return [WorkflowExecutionCollection] Returns a collection

  that will only enumerate or count executions of the given
  status.

@param [String] workflow_id

@return [WorkflowExecutionCollection] Returns a collection

  that will only enumerate or count executions that have
  the given `workflow_id`.

@param [WorkflowType,Hash] workflow_type Should be a {WorkflowType}

  object or a hash with `:name` and `:version` keys.

@return [WorkflowExecutionCollection] Returns a collection

  that will only enumerate or count executions that have
  the given `workflow_type`.

Protected Instance methods

[Validate]