Class: Mistri::Dispatchers::Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/mistri/dispatchers.rb

Overview

Real in-process background: the child runs on its own thread and the spawn call returns immediately. Enough for development and for hosts whose children are short; queue-backed hosts plug their own lambda.

Instance Method Summary collapse

Instance Method Details

#call(spec, runner) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/mistri/dispatchers.rb', line 34

def call(spec, runner)
  ::Thread.new do
    runner.call
  rescue StandardError => e
    reported = EventDelivery.original(e)
    # Execution failures have a durable terminal before re-raising;
    # cleanup may raise after a successful terminal. Neither should
    # make a thread die loudly or disappear without a diagnostic.
    warn "mistri: background runner for #{spec["name"].inspect} crashed: " \
         "#{reported.class}: #{reported.message}"
  end
  nil
end