Class: AWS::Flow::WorkflowDefinitionFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/decider/workflow_definition_factory.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, workflow_type, registration_options, implementation_options, workflow_method, signals, get_state_method) ⇒ WorkflowDefinitionFactory

Returns a new instance of WorkflowDefinitionFactory.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/aws/decider/workflow_definition_factory.rb', line 53

def initialize(klass, workflow_type, registration_options, implementation_options, workflow_method, signals, get_state_method)
  @klass = klass
  @workflow_type = workflow_type
  @registration_options = registration_options
  @implementation_options = implementation_options
  @workflow_method = workflow_method
  @signals = signals
  @get_state_method = get_state_method
  if ! implementation_options.nil?
    @converter = implementation_options.data_converter
  end
  @converter ||= FlowConstants.data_converter

end

Instance Attribute Details

#converterObject (readonly)

Returns the value of attribute converter.



52
53
54
# File 'lib/aws/decider/workflow_definition_factory.rb', line 52

def converter
  @converter
end

Class Method Details

.generate_definition_map(workflow_class) ⇒ Object

Method to create a workflow definition map from a workflow class



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/aws/decider/workflow_definition_factory.rb', line 23

def generate_definition_map(workflow_class)

  unless workflow_class.respond_to?(:workflows)
    raise ArgumentError.new("workflow_class must extend module AWS::Flow::Workflows")
  end

  workflow_definition_map = {}

  workflow_class.workflows.each do |workflow_type|
    options = workflow_type.options
    execution_method = options.execution_method
    registration_options = options.get_registration_options
    get_state_method = workflow_class.get_state_method
    signals = workflow_class.signals

    workflow_definition_map[workflow_type] = self.new(
      workflow_class,
      workflow_type,
      registration_options,
      options,
      execution_method,
      signals,
      get_state_method
    )
  end
  workflow_definition_map
end

Instance Method Details

#delete_workflow_definition(definition) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/aws/decider/workflow_definition_factory.rb', line 74

def delete_workflow_definition(definition)
  FlowFiber.unset(FlowFiber.current, :decision_context)
  # Indicates to GC that these values are no longer needed.
  FlowFiber.local_variables.each_pair do |key, value|
    value = nil
    FlowFiber.local_variables.delete(key)
  end
end

#get_workflow_definition(decision_context) ⇒ Object



68
69
70
71
72
# File 'lib/aws/decider/workflow_definition_factory.rb', line 68

def get_workflow_definition(decision_context)
  FlowFiber.current[:decision_context] = decision_context
  this_instance = @klass.new
  WorkflowDefinition.new(this_instance, @workflow_method, @signals, @get_state_method, @converter)
end