Class: OMQ::Routing::Client
- Inherits:
-
Object
- Object
- OMQ::Routing::Client
- Includes:
- FairRecv, RoundRobin
- Defined in:
- lib/omq/routing/client.rb
Overview
CLIENT socket routing: round-robin send, fair-queue receive.
Same as DEALER — no envelope manipulation.
Instance Attribute Summary collapse
- #recv_queue ⇒ FairQueue readonly
Instance Method Summary collapse
- #connection_added(connection) ⇒ Object
- #connection_removed(connection) ⇒ Object
- #enqueue(parts) ⇒ Object
-
#initialize(engine) ⇒ Client
constructor
A new instance of Client.
-
#stop ⇒ Object
Stops all background tasks.
Constructor Details
#initialize(engine) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 |
# File 'lib/omq/routing/client.rb', line 15 def initialize(engine) @engine = engine @recv_queue = FairQueue.new @tasks = [] init_round_robin(engine) end |
Instance Attribute Details
#recv_queue ⇒ FairQueue (readonly)
25 26 27 |
# File 'lib/omq/routing/client.rb', line 25 def recv_queue @recv_queue end |
Instance Method Details
#connection_added(connection) ⇒ Object
29 30 31 32 33 |
# File 'lib/omq/routing/client.rb', line 29 def connection_added(connection) @connections << connection add_fair_recv_connection(connection) add_round_robin_send_connection(connection) end |
#connection_removed(connection) ⇒ Object
38 39 40 41 42 |
# File 'lib/omq/routing/client.rb', line 38 def connection_removed(connection) @connections.delete(connection) @recv_queue.remove_queue(connection) remove_round_robin_send_connection(connection) end |
#enqueue(parts) ⇒ Object
47 48 49 |
# File 'lib/omq/routing/client.rb', line 47 def enqueue(parts) enqueue_round_robin(parts) end |
#stop ⇒ Object
Stops all background tasks.
53 54 55 56 |
# File 'lib/omq/routing/client.rb', line 53 def stop @tasks.each(&:stop) @tasks.clear end |