Class: BBK::App::Middlewares::Watchdog
- Defined in:
- lib/bbk/app/middlewares/watchdog.rb
Instance Attribute Summary collapse
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#message_factory ⇒ Object
readonly
Returns the value of attribute message_factory.
-
#pinger_thread ⇒ Object
readonly
Returns the value of attribute pinger_thread.
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
-
#reply_to ⇒ Object
readonly
Returns the value of attribute reply_to.
-
#route ⇒ Object
readonly
Returns the value of attribute route.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#watcher_delay ⇒ Object
readonly
Returns the value of attribute watcher_delay.
-
#watcher_thread ⇒ Object
readonly
Returns the value of attribute watcher_thread.
Attributes inherited from Base
Instance Method Summary collapse
- #build(app) ⇒ Object
- #call(msg) ⇒ Object
-
#initialize(publisher, route, message_factory, reply_to, delay: 20, timeout: 60, watcher_delay: 40) ⇒ Watchdog
constructor
A new instance of Watchdog.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(publisher, route, message_factory, reply_to, delay: 20, timeout: 60, watcher_delay: 40) ⇒ Watchdog
Returns a new instance of Watchdog.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 9 def initialize(publisher, route, , reply_to, delay: 20, timeout: 60, watcher_delay: 40) @publisher = publisher @route = route @message_factory = @reply_to = reply_to @delay = delay @timeout = timeout @timestamp = Time.now.to_i @watcher_delay = watcher_delay end |
Instance Attribute Details
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
6 7 8 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 6 def delay @delay end |
#message_factory ⇒ Object (readonly)
Returns the value of attribute message_factory.
6 7 8 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 6 def @message_factory end |
#pinger_thread ⇒ Object (readonly)
Returns the value of attribute pinger_thread.
6 7 8 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 6 def pinger_thread @pinger_thread end |
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
6 7 8 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 6 def publisher @publisher end |
#reply_to ⇒ Object (readonly)
Returns the value of attribute reply_to.
6 7 8 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 6 def reply_to @reply_to end |
#route ⇒ Object (readonly)
Returns the value of attribute route.
6 7 8 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 6 def route @route end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 6 def timeout @timeout end |
#watcher_delay ⇒ Object (readonly)
Returns the value of attribute watcher_delay.
6 7 8 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 6 def watcher_delay @watcher_delay end |
#watcher_thread ⇒ Object (readonly)
Returns the value of attribute watcher_thread.
6 7 8 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 6 def watcher_thread @watcher_thread end |
Instance Method Details
#build(app) ⇒ Object
20 21 22 23 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 20 def build(app) @app = app self end |
#call(msg) ⇒ Object
25 26 27 28 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 25 def call(msg) touch @app.call(msg) end |
#start ⇒ Object
30 31 32 33 34 35 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 30 def start touch start_ping start_watch self end |
#stop ⇒ Object
37 38 39 40 |
# File 'lib/bbk/app/middlewares/watchdog.rb', line 37 def stop @pinger_thread&.kill @watcher_thread&.kill end |