Module: Ons

Defined in:
lib/ons.rb,
lib/ons/lmfao.rb,
lib/ons/version.rb,
lib/ons/consumer.rb,
lib/ons/producer.rb

Overview

.

Defined Under Namespace

Modules: LMFAO Classes: Consumer, Producer

Constant Summary collapse

VERSION =
'1.0.0'.freeze

Class Method Summary collapse

Class Method Details

.loop_foreverObject

Block the current thread.


32
33
34
35
# File 'lib/ons.rb', line 32

def self.loop_forever
  raise 'please start an Ons::Consumer instance before loop forever' if Consumer.instances.empty?
  LMFAO.event_thread.join
end

.register_cleanup_hooksObject

Perform an automatic cleanup at program exit.

It handles:


20
21
22
23
24
25
26
27
28
29
# File 'lib/ons.rb', line 20

def self.register_cleanup_hooks
  return if @registered
  @registered = true

  at_exit do
    Consumer.instances.each(&:shutdown)
    Producer.instances.each(&:shutdown)
    LMFAO.event_thread && LMFAO.event_thread.terminate
  end
end