Class: MobME::Infrastructure::Queue::Backends::ZeroMQ
- Inherits:
-
MobME::Infrastructure::Queue::Backend
- Object
- MobME::Infrastructure::Queue::Backend
- MobME::Infrastructure::Queue::Backends::ZeroMQ
- Defined in:
- lib/mobme/infrastructure/queue/backends/zeromq.rb
Instance Method Summary collapse
- #add(queue, item, metadata = {}) ⇒ Object
-
#add_bulk(queue, items = []) ⇒ Object
Adds many items together.
- #connect ⇒ Object
- #empty(queue) ⇒ Object
-
#initialize(options = {}) ⇒ ZeroMQ
constructor
A new instance of ZeroMQ.
- #list(queue) ⇒ Object
- #list_queues ⇒ Object
- #peek(queue) ⇒ Object
-
#remove(queue) ⇒ Object
Simple remove without reserving items.
- #remove_queues(*queues) ⇒ Object (also: #remove_queue)
- #size(queue) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ZeroMQ
Returns a new instance of ZeroMQ.
7 8 9 10 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 7 def initialize( = {}) @socket = [:socket] || "ipc:///tmp/mobme-infrastructure-queue-messages.sock" connect end |
Instance Method Details
#add(queue, item, metadata = {}) ⇒ Object
19 20 21 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 19 def add(queue, item, = {}) dispatch(:add, queue, item, ) end |
#add_bulk(queue, items = []) ⇒ Object
Adds many items together
24 25 26 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 24 def add_bulk(queue, items = []) dispatch(:add_bulk, queue, items) end |
#connect ⇒ Object
12 13 14 15 16 17 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 12 def connect @context = EM::ZeroMQ::Context.new(1) @pool = EM::Synchrony::ConnectionPool.new(:size => 20) do @context.connect(ZMQ::REQ, @socket) end end |
#empty(queue) ⇒ Object
45 46 47 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 45 def empty(queue) dispatch(:empty, queue) end |
#list(queue) ⇒ Object
41 42 43 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 41 def list(queue) dispatch(:list, queue) end |
#list_queues ⇒ Object
49 50 51 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 49 def list_queues dispatch(:list_queues) end |
#peek(queue) ⇒ Object
33 34 35 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 33 def peek(queue) dispatch(:peek, queue) end |
#remove(queue) ⇒ Object
Simple remove without reserving items
29 30 31 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 29 def remove(queue) dispatch(:remove, queue) end |
#remove_queues(*queues) ⇒ Object Also known as: remove_queue
53 54 55 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 53 def remove_queues(*queues) dispatch(:remove_queues, *queues) end |
#size(queue) ⇒ Object
37 38 39 |
# File 'lib/mobme/infrastructure/queue/backends/zeromq.rb', line 37 def size(queue) dispatch(:size, queue) end |