Class: Insika::Server::Boot

Inherits:
Object
  • Object
show all
Defined in:
lib/insika/server/boot.rb

Overview

Turns the components into a service. MANDATORY order, no parallelism: plugins → stores → recovery → (app for the listen). "Never accepts a request before recovery" is guaranteed BY CONSTRUCTION: the listen (Falcon) only runs after #call returns the app, and #call only returns after Recovery.run finishes.

Instance Method Summary collapse

Constructor Details

#initialize(wiring, logger: $stdout, app: nil) ⇒ Boot

wiring: object with the named steps (load_plugins/build_stores/ recovery/app) — the config/wiring.rb. logger: simple IO (default $stdout; nil silences). app: overrides the wiring's app step — for a serving arm (config.ru) that assembles its own Rack app around the wiring; the "recovery before the listen" guarantee is unchanged (#call still only returns after recovery).



19
20
21
22
23
# File 'lib/insika/server/boot.rb', line 19

def initialize(wiring, logger: $stdout, app: nil)
  @wiring = wiring
  @logger = logger
  @app = app
end

Instance Method Details

#callObject

-> Rack app ready for the run. A store failure at boot (corrupted file → StoreError) PROPAGATES and aborts the process (coming up without durability is worse than not coming up); an unrecoverable task does NOT bring down the boot (Recovery already marks it :failed).



29
30
31
32
33
34
35
36
37
# File 'lib/insika/server/boot.rb', line 29

def call
  @wiring.load_plugins
  @wiring.build_stores
  warn_if_ephemeral
  summary = run_recovery
  log("boot: recovery complete — #{summary[:resumed].size} resumed, " \
      "#{summary[:failed].size} failed")
  @app || @wiring.app
end