Class: SagaForge::Execution::CompensationFacade

Inherits:
Object
  • Object
show all
Defined in:
lib/saga_forge/execution/compensation_facade.rb

Overview

Yielded to compensation blocks: context is the snapshot (§A.4). No transition verbs — rollback has one direction.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(correlation_id:, current_state:, context:) ⇒ CompensationFacade

Returns a new instance of CompensationFacade.



8
9
10
11
12
13
# File 'lib/saga_forge/execution/compensation_facade.rb', line 8

def initialize(correlation_id:, current_state:, context:)
  @correlation_id = correlation_id
  @current_state = current_state
  @context = context
  @staged_publishes = []
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/saga_forge/execution/compensation_facade.rb', line 6

def context
  @context
end

#correlation_idObject (readonly)

Returns the value of attribute correlation_id.



6
7
8
# File 'lib/saga_forge/execution/compensation_facade.rb', line 6

def correlation_id
  @correlation_id
end

#current_stateObject (readonly)

Returns the value of attribute current_state.



6
7
8
# File 'lib/saga_forge/execution/compensation_facade.rb', line 6

def current_state
  @current_state
end

#staged_publishesObject (readonly)

Returns the value of attribute staged_publishes.



6
7
8
# File 'lib/saga_forge/execution/compensation_facade.rb', line 6

def staged_publishes
  @staged_publishes
end

Instance Method Details

#publish(event_name, **payload) ⇒ Object



15
16
17
18
# File 'lib/saga_forge/execution/compensation_facade.rb', line 15

def publish(event_name, **payload)
  @staged_publishes.concat(Router.resolve(event_name, payload))
  nil
end