Class: JobDispatch::Signaller
- Inherits:
-
Object
- Object
- JobDispatch::Signaller
- Defined in:
- lib/job_dispatch/signaller.rb
Overview
This class represents a ZeroMQ socket for signalling to the broker that there are jobs immediately available.
Instance Attribute Summary collapse
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #connect ⇒ Object
- #disconnect ⇒ Object
-
#initialize(wakeup_connect_address) ⇒ Signaller
constructor
A new instance of Signaller.
-
#signal(queue = 'default') ⇒ Object
signals are a straight.
Constructor Details
#initialize(wakeup_connect_address) ⇒ Signaller
Returns a new instance of Signaller.
7 8 9 |
# File 'lib/job_dispatch/signaller.rb', line 7 def initialize(wakeup_connect_address) @wakeup_connect_address = wakeup_connect_address end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
5 6 7 |
# File 'lib/job_dispatch/signaller.rb', line 5 def socket @socket end |
Instance Method Details
#connect ⇒ Object
11 12 13 14 15 16 |
# File 'lib/job_dispatch/signaller.rb', line 11 def connect if @socket.nil? @socket = JobDispatch.context.socket(ZMQ::PUB) @socket.connect(@wakeup_connect_address) end end |
#disconnect ⇒ Object
18 19 20 21 22 23 |
# File 'lib/job_dispatch/signaller.rb', line 18 def disconnect if @socket @socket.close @socket = nil end end |
#signal(queue = 'default') ⇒ Object
signals are a straight
26 27 28 |
# File 'lib/job_dispatch/signaller.rb', line 26 def signal(queue='default') @socket.send(queue) end |