Class: JobDispatch::Signaller

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#socketObject (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

#connectObject



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

#disconnectObject



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