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

#capture_agent(name, workflow_class:, transition:, role:) ⇒ Object



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

def capture_agent(name, workflow_class:, transition:, role:)
  capture_binding(name, workflow_class:, transition:, role:)
  self
end

#eachObject



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

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



48
49
50
51
52
# File 'lib/smith/workflow/split_step_persistence/execution_binding_collector.rb', line 48

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

#resolve!Object



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

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

  @requests.freeze
  self
end