Class: Textus::Application::Refresh::Orchestrator

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/application/refresh/orchestrator.rb

Instance Method Summary collapse

Constructor Details

#initialize(worker:, bus:, store_root:, store: nil, role: "human", detached_spawner: nil) ⇒ Orchestrator

Returns a new instance of Orchestrator.



5
6
7
8
9
10
11
12
# File 'lib/textus/application/refresh/orchestrator.rb', line 5

def initialize(worker:, bus:, store_root:, store: nil, role: "human", detached_spawner: nil)
  @worker = worker
  @bus = bus
  @store_root = store_root
  @store = store
  @role = role
  @detached_spawner = detached_spawner || default_spawner
end

Instance Method Details

#execute(action, key:) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/textus/application/refresh/orchestrator.rb', line 14

def execute(action, key:)
  case action
  when Textus::Domain::Action::Return       then Textus::Domain::Outcome::Skipped.new
  when Textus::Domain::Action::RefreshSync  then run_sync(key)
  when Textus::Domain::Action::RefreshTimed then run_timed(action.budget_ms, key)
  else raise ArgumentError.new("unknown action: #{action.inspect}")
  end
end