Class: Smith::Workflow::SplitStepPersistence::ExecutionBindingCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/smith/workflow/split_step_persistence/execution_binding_collector.rb

Constant Summary collapse

MAX_BINDINGS =
10_000

Instance Method Summary collapse

Constructor Details

#initializeExecutionBindingCollector

Returns a new instance of ExecutionBindingCollector.



12
13
14
15
# File 'lib/smith/workflow/split_step_persistence/execution_binding_collector.rb', line 12

def initialize
  @requests = {}
  @bindings = {}
end

Instance Method Details

#capture(transition, workflow_class:) ⇒ Object



17
18
19
20
21
22
# File 'lib/smith/workflow/split_step_persistence/execution_binding_collector.rb', line 17

def capture(transition, workflow_class:)
  capture_binding(transition.agent_name, workflow_class:, transition:, role: :agent)
  capture_fanout(transition, workflow_class:)
  capture_optimization(transition, workflow_class:)
  capture_orchestration(transition, workflow_class:)
end

#eachObject



39
40
41
# File 'lib/smith/workflow/split_step_persistence/execution_binding_collector.rb', line 39

def each(&)
  @bindings.each(&)
end

#fetch!(name, workflow_class:, transition_name:, role:) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/smith/workflow/split_step_persistence/execution_binding_collector.rb', line 24

def fetch!(name, workflow_class:, transition_name:, role:)
  @bindings.fetch(name.to_s) do
    raise WorkflowError,
          "execution authorization does not contain #{role} :#{name} " \
          "for workflow #{workflow_class}, transition :#{transition_name}"
  end
end

#freezeObject



43
44
45
46
47
# File 'lib/smith/workflow/split_step_persistence/execution_binding_collector.rb', line 43

def freeze
  @requests.freeze
  @bindings.freeze
  super
end

#resolve!Object



32
33
34
35
36
37
# File 'lib/smith/workflow/split_step_persistence/execution_binding_collector.rb', line 32

def resolve!
  @bindings = Agent::Registry.capture_bindings!(@requests.values)

  @requests.freeze
  self
end