Class: OllamaAgent::Runtime::SagaRecoveryDaemon

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/runtime/saga_recovery_daemon.rb

Overview

Exclusive per-manifest recovery lease + compensation + saga seal.

Instance Method Summary collapse

Constructor Details

#initialize(db:, saga_coordinator:, compensation_engine:, clock_epoch_provider:) ⇒ SagaRecoveryDaemon

Returns a new instance of SagaRecoveryDaemon.



7
8
9
10
11
12
# File 'lib/ollama_agent/runtime/saga_recovery_daemon.rb', line 7

def initialize(db:, saga_coordinator:, compensation_engine:, clock_epoch_provider:)
  @db = db
  @saga_coordinator = saga_coordinator
  @compensation_engine = compensation_engine
  @clock_epoch_provider = clock_epoch_provider
end

Instance Method Details

#recover_orphans(holder:, ttl_epochs: 60) ⇒ Array<Hash>

Returns each element :manifest_id, :status.

Parameters:

  • holder (String)

    logical worker id

  • ttl_epochs (Integer) (defaults to: 60)

    lease length in logical epochs (caller-owned clock).

Returns:

  • (Array<Hash>)

    each element :manifest_id, :status



17
18
19
20
21
22
23
24
25
# File 'lib/ollama_agent/runtime/saga_recovery_daemon.rb', line 17

def recover_orphans(holder:, ttl_epochs: 60)
  epoch = @clock_epoch_provider.call.to_i
  ttl = ttl_epochs.to_i
  outcomes = []
  @saga_coordinator.each_active do |saga|
    outcomes << recover_one(saga[:manifest_id], holder, epoch, ttl)
  end
  outcomes
end