Class: Smith::Workflow::SplitStepPersistence::ExecutionBindingSnapshot

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

Constant Summary collapse

MAX_NESTED_WORKFLOWS =
128
MAX_TRANSITIONS =
10_000

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transition, workflow_class:) ⇒ ExecutionBindingSnapshot

Returns a new instance of ExecutionBindingSnapshot.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/smith/workflow/split_step_persistence/execution_binding_snapshot.rb', line 17

def initialize(transition, workflow_class:)
  @transition = transition
  @workflow_class = workflow_class
  @bindings = ExecutionBindingCollector.new
  @visited_workflows = {}.compare_by_identity
  @visited_workflows[workflow_class] = true
  @workflow_snapshots = {}.compare_by_identity
  @workflow_queue = []
  @workflow_queue_index = 0
  @transition_count = 0
end

Class Method Details

.capture(transition, workflow_class:) ⇒ Object



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

def self.capture(transition, workflow_class:)
  new(transition, workflow_class:).capture
end

Instance Method Details

#captureObject



29
30
31
32
33
34
35
36
# File 'lib/smith/workflow/split_step_persistence/execution_binding_snapshot.rb', line 29

def capture
  capture_transition(@transition, workflow_class: @workflow_class)
  drain_workflow_queue
  @bindings.resolve!
  @bindings.freeze
  @workflow_snapshots.freeze
  freeze
end

#each_agent_bindingObject



42
43
44
# File 'lib/smith/workflow/split_step_persistence/execution_binding_snapshot.rb', line 42

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

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



38
39
40
# File 'lib/smith/workflow/split_step_persistence/execution_binding_snapshot.rb', line 38

def fetch!(name, workflow_class:, transition_name:, role:)
  @bindings.fetch!(name, workflow_class:, transition_name:, role:)
end

#verify_workflow!(workflow_class) ⇒ Object



46
47
48
49
50
51
# File 'lib/smith/workflow/split_step_persistence/execution_binding_snapshot.rb', line 46

def verify_workflow!(workflow_class)
  snapshot = @workflow_snapshots.fetch(workflow_class) do
    raise WorkflowError, "execution authorization does not contain nested workflow #{workflow_class}"
  end
  snapshot.verify!
end