Class: Bolt::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt/notifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(executor = nil) ⇒ Notifier

Returns a new instance of Notifier.



5
6
7
8
9
10
# File 'lib/bolt/notifier.rb', line 5

def initialize(executor = nil)
  # lazy-load expensive gem code
  require 'concurrent'

  @executor = executor || Concurrent::SingleThreadExecutor.new
end

Instance Method Details

#notify(callback, event) ⇒ Object



12
13
14
15
16
# File 'lib/bolt/notifier.rb', line 12

def notify(callback, event)
  @executor.post do
    callback.call(event)
  end
end

#shutdownObject



18
19
20
21
# File 'lib/bolt/notifier.rb', line 18

def shutdown
  @executor.shutdown
  @executor.wait_for_termination
end