Class: FastlyNsq::Launcher
- Inherits:
-
Object
- Object
- FastlyNsq::Launcher
- Includes:
- SafeThread
- Defined in:
- lib/fastly_nsq/launcher.rb
Overview
FastlyNsq::Launcher is a lighweight wrapper of a thread manager and heartbeat.
This class is used internally by FastlyNsq::CLI.
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#pulse ⇒ Object
Returns the value of attribute pulse.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #beat ⇒ Object
-
#initialize(**options) ⇒ Launcher
constructor
A new instance of Launcher.
- #manager ⇒ Object
- #stop ⇒ Object
- #stop_listeners ⇒ Object
- #stopping? ⇒ Boolean
Methods included from SafeThread
Constructor Details
#initialize(**options) ⇒ Launcher
Returns a new instance of Launcher.
20 21 22 23 24 25 26 27 28 |
# File 'lib/fastly_nsq/launcher.rb', line 20 def initialize(**) @done = false @timeout = [:timeout] || 5 @pulse = [:pulse] || 5 @logger = [:logger] || FastlyNsq.logger FastlyNsq.manager = FastlyNsq::Manager.new(**) FastlyNsq.fire_event :startup end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/fastly_nsq/launcher.rb', line 13 def logger @logger end |
#pulse ⇒ Object
Returns the value of attribute pulse.
14 15 16 |
# File 'lib/fastly_nsq/launcher.rb', line 14 def pulse @pulse end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
13 14 15 |
# File 'lib/fastly_nsq/launcher.rb', line 13 def timeout @timeout end |
Instance Method Details
#beat ⇒ Object
30 31 32 |
# File 'lib/fastly_nsq/launcher.rb', line 30 def beat @heartbeat ||= safe_thread("heartbeat", &method(:start_heartbeat)) end |
#manager ⇒ Object
16 17 18 |
# File 'lib/fastly_nsq/launcher.rb', line 16 def manager FastlyNsq.manager end |
#stop ⇒ Object
34 35 36 37 38 |
# File 'lib/fastly_nsq/launcher.rb', line 34 def stop @done = true manager.terminate(timeout) FastlyNsq.fire_event :shutdown end |
#stop_listeners ⇒ Object
40 41 42 43 |
# File 'lib/fastly_nsq/launcher.rb', line 40 def stop_listeners @done = true manager.stop_listeners end |
#stopping? ⇒ Boolean
45 46 47 |
# File 'lib/fastly_nsq/launcher.rb', line 45 def stopping? @done end |