Module: Hsdq::Listener
Overview
This module is holding the methods for the class listener. The listener is connected to the Redis instance with the blocking cx_listener connection
It is popping the "Spark" (ephemeral part of the message) from the list. When a spark is popped, it is validated and processed in the receiver module.
Instance Method Summary collapse
-
#hsdq_alive? ⇒ Boolean
When true allow the listener to start When set to false, the listener exit the listening loop.
-
#hsdq_exit! ⇒ Object
Set exit to force the listening loop to exit.
-
#hsdq_exit? ⇒ Boolean
Flag break the listening loop if true.
-
#hsdq_running? ⇒ Boolean
Flag allowing or not the processing of the queue.
-
#hsdq_start(channel, options) ⇒ Object
Start hsdq to listen to channel.
-
#hsdq_start! ⇒ Boolean
Set the flag to allow processing the queue.
-
#hsdq_stop! ⇒ Boolean
Set the flag to stop processing the queue.
-
#hsdq_stopped? ⇒ Boolean
Opposite or hsdq_running.
-
#kill_alive! ⇒ Object
stops the listening loop.
-
#start_listener(options = {}) ⇒ Object
Start the listener :nocov:.
Methods included from Connectors
#cx_admin, #cx_data, #cx_listener, #cx_session
Instance Method Details
#hsdq_alive? ⇒ Boolean
When true allow the listener to start When set to false, the listener exit the listening loop. This is mostly to exit gracefully the program The listener needs to be restarted specifically, if need to run again
53 54 55 56 |
# File 'lib/hsdq/listener.rb', line 53 def hsdq_alive? @hsdq_alive = true if @hsdq_alive.nil? @hsdq_alive end |
#hsdq_exit! ⇒ Object
Set exit to force the listening loop to exit.
65 66 67 |
# File 'lib/hsdq/listener.rb', line 65 def hsdq_exit! @hsdq_exit = true end |
#hsdq_exit? ⇒ Boolean
Flag break the listening loop if true.
60 61 62 |
# File 'lib/hsdq/listener.rb', line 60 def hsdq_exit? @hsdq_exit end |
#hsdq_running? ⇒ Boolean
Flag allowing or not the processing of the queue
37 38 39 40 |
# File 'lib/hsdq/listener.rb', line 37 def hsdq_running? @hsdq_running = true if @hsdq_running.nil? @hsdq_running end |
#hsdq_start(channel, options) ⇒ Object
Start hsdq to listen to channel.
17 18 19 20 21 |
# File 'lib/hsdq/listener.rb', line 17 def hsdq_start(channel, ) () if hsdq_start! hsdq_loop(channel) end |
#hsdq_start! ⇒ Boolean
Set the flag to allow processing the queue
31 32 33 |
# File 'lib/hsdq/listener.rb', line 31 def hsdq_start! @hsdq_running = true end |
#hsdq_stop! ⇒ Boolean
Set the flag to stop processing the queue
25 26 27 |
# File 'lib/hsdq/listener.rb', line 25 def hsdq_stop! @hsdq_running = false end |
#hsdq_stopped? ⇒ Boolean
Opposite or hsdq_running.
45 46 47 |
# File 'lib/hsdq/listener.rb', line 45 def hsdq_stopped? !hsdq_running? end |
#kill_alive! ⇒ Object
stops the listening loop
70 71 72 |
# File 'lib/hsdq/listener.rb', line 70 def kill_alive! @hsdq_alive = false end |
#start_listener(options = {}) ⇒ Object
Start the listener :nocov:
76 77 78 79 |
# File 'lib/hsdq/listener.rb', line 76 def start_listener(={}) Thread.new { hsdq_start(channel, ) } Thread.new { admin_listener } end |