Class: AWS::SimpleWorkflow::WorkflowType

Inherits:
Type show all
Includes:
OptionFormatters
Defined in:
lib/aws/simple_workflow/workflow_type.rb

Overview

Registering a WorkflowType

To register a workflow type you should use the #workflow_types method on the domain:

domain.workflow_types.register('name', 'version', { ... })

See AWS::SimpleWorkflow::WorkflowTypeCollection#register for a complete list of options.

Deprecating a workflwo type

WorkflowType inherits from the generic Type base class. Defined in Type are a few useful methods including:

You can use these to deprecate a workflow type:

domain.workflow_types['name','version'].deprecate

Instance Attribute Summary collapse

Attributes inherited from Type

#domain, #name, #version

Attributes included from Core::Model

#config

Instance Method Summary collapse

Methods inherited from Type

#deprecate, #deprecated?, #initialize

Methods inherited from Resource

attribute, #exists?

Methods inherited from Core::Resource

attribute_providers, attribute_providers_for, attributes, #attributes_from_response, define_attribute_type, #eql?, #initialize, #inspect, new_from

Methods included from Core::Cacheable

included, #retrieve_attribute

Methods included from Core::Model

#client, #config_prefix, #initialize, #inspect

Constructor Details

This class inherits a constructor from AWS::SimpleWorkflow::Type

Instance Attribute Details

#creation_dateTime (readonly)

When the workflow type was registered.

Returns:

  • (Time)

    the current value of creation_date



82
83
84
# File 'lib/aws/simple_workflow/workflow_type.rb', line 82

def creation_date
  @creation_date
end

#default_child_policySymbol? (readonly)

Specifies the default policy to use for the child workflow executions when a workflow execution of this type is terminated. Values may be one of the following (or nil):

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

Returns:

  • (Symbol, nil)

    the current value of default_child_policy



82
83
84
# File 'lib/aws/simple_workflow/workflow_type.rb', line 82

def default_child_policy
  @default_child_policy
end

#default_execution_start_to_close_timeoutInteger, ... (readonly)

The default maximum duration for executions of this workflow type.

The return value may be an integer (number of seconds), the symbol :none (implying no timeout) or nil (not specified).

Returns:

  • (Integer, :none, nil)

    the current value of default_execution_start_to_close_timeout



82
83
84
# File 'lib/aws/simple_workflow/workflow_type.rb', line 82

def default_execution_start_to_close_timeout
  @default_execution_start_to_close_timeout
end

#default_task_listString? (readonly)

Specifies the default task list to use for scheduling decision tasks for executions of this workflow type.

Returns:

  • (String, nil)

    the current value of default_task_list



82
83
84
# File 'lib/aws/simple_workflow/workflow_type.rb', line 82

def default_task_list
  @default_task_list
end

#default_task_start_to_close_timeoutInteger, ... (readonly)

The default maximum duration of decision tasks for this workflow type.

The return value may be an integer (number of seconds), the symbol :none (implying no timeout) or nil (not specified).

Returns:

  • (Integer, :none, nil)

    the current value of default_task_start_to_close_timeout



82
83
84
# File 'lib/aws/simple_workflow/workflow_type.rb', line 82

def default_task_start_to_close_timeout
  @default_task_start_to_close_timeout
end

#deprecation_dateTime? (readonly)

When the workflow type was deprecated, or nil if the workflow type has not been deprecated.

Returns:

  • (Time, nil)

    the current value of deprecation_date



82
83
84
# File 'lib/aws/simple_workflow/workflow_type.rb', line 82

def deprecation_date
  @deprecation_date
end

#descriptionString? (readonly)

The description of this workflow type, or nil if was not set when it was registered.

Returns:

  • (String, nil)

    the current value of description



82
83
84
# File 'lib/aws/simple_workflow/workflow_type.rb', line 82

def description
  @description
end

#statusSymbol (readonly)

The status of this workflow type. The status will either be :registered or :deprecated.

Returns:

  • (Symbol)

    the current value of status



82
83
84
# File 'lib/aws/simple_workflow/workflow_type.rb', line 82

def status
  @status
end

Instance Method Details

#count_executions(options = {}) ⇒ Integer

Note:

This operation is eventually consistent. The results are best effort and may not exactly reflect recent updates and changes.

Returns a count of workflow executions of this workflow type.

domain.workflow_types['name','version'].count

Parameters:

  • options (Hash) (defaults to: {})

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.

Returns:

  • (Integer)

    Returns the count of workflow execution of this type.



143
144
145
146
# File 'lib/aws/simple_workflow/workflow_type.rb', line 143

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

#start_execution(options = {}) ⇒ WorkflowExecution

Returns the new workflow execution.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :workflow_id (String)

    A user defined identifier associated with the workflow execution. You can use this to associate a custom identifier with the workflow execution. You may specify the same identifier if a workflow execution is logically a restart of a previous execution. You cannot have two open workflow executions with the same :workflow_id at the same time.

    If you do not provide :workflow_id a random UUID will be generated.

  • :input (String) — default: nil

    The input for the workflow execution. This is a free form string which should be meaningful to the workflow you are starting. This input is made available to the new workflow execution in the WorkflowExecutionStarted history event.

  • :tag_list (Array<string>) — default: []

    A list of tags (strings) to associate with the workflow execution. You can specify a maximum of 5 tags.

  • :child_policy (Symbol) — default: nil

    Specifies the policy to use for the child workflow executions of this workflow execution if it is terminated explicitly or due to an expired timeout. This policy overrides the default child policy specified when registering the workflow type. The supported child policies are:

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

  • :execution_start_to_close_timeout (Integer, :none) — default: nil

    The total duration for this workflow execution. This overrides the default specified when registering the workflow type.

    The value should be a number of seconds (integer) or the symbol :none (implying no timeout).

  • :task_list (String) — default: nil

    The task list to use for the decision tasks generated for this workflow execution. This overrides the default task list specified when registering the workflow type.

  • :task_start_to_close_timeout (Integer, :none) — default: nil

    Specifies the maximum duration of decision tasks for this workflow execution. This parameter overrides the default specified when the workflow type was registered.

    The value should be a number of seconds (integer) or the symbol :none (implying no timeout).

Returns:



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/aws/simple_workflow/workflow_type.rb', line 122

def start_execution options = {}
  
  options[:domain] = domain.name
  start_execution_opts(options, self)
  response = client.start_workflow_execution(options)

  workflow_id = options[:workflow_id]
  run_id = response.data['runId']

  domain.workflow_executions[workflow_id, run_id]

end

#workflow_executionsWorkflowExecutionCollection

Returns a collection that enumerates only workflow executions of this type.

Returns:



150
151
152
# File 'lib/aws/simple_workflow/workflow_type.rb', line 150

def workflow_executions
  WorkflowExecutionCollection.new(domain).with_workflow_type(self)
end