Class: OMQ::Routing::Scatter

Inherits:
Object
  • Object
show all
Includes:
RoundRobin
Defined in:
lib/omq/routing/scatter.rb

Overview

SCATTER socket routing: round-robin send to GATHER peers.

Instance Method Summary collapse

Constructor Details

#initialize(engine) ⇒ Scatter

Returns a new instance of Scatter.

Parameters:

  • engine (Engine)


12
13
14
15
16
# File 'lib/omq/routing/scatter.rb', line 12

def initialize(engine)
  @engine = engine
  @tasks  = []
  init_round_robin(engine)
end

Instance Method Details

#connection_added(connection) ⇒ Object

Parameters:

  • connection (Connection)


28
29
30
31
32
# File 'lib/omq/routing/scatter.rb', line 28

def connection_added(connection)
  @connections << connection
  add_round_robin_send_connection(connection)
  start_reaper(connection)
end

#connection_removed(connection) ⇒ Object

Parameters:

  • connection (Connection)


37
38
39
40
# File 'lib/omq/routing/scatter.rb', line 37

def connection_removed(connection)
  @connections.delete(connection)
  remove_round_robin_send_connection(connection)
end

#enqueue(parts) ⇒ Object

Parameters:

  • parts (Array<String>)


45
46
47
# File 'lib/omq/routing/scatter.rb', line 45

def enqueue(parts)
  enqueue_round_robin(parts)
end

#recv_queueObject

SCATTER is write-only.



21
22
23
# File 'lib/omq/routing/scatter.rb', line 21

def recv_queue
  raise "SCATTER sockets cannot receive"
end

#stopObject

Stops all background tasks (send pumps, reapers).



52
53
54
55
# File 'lib/omq/routing/scatter.rb', line 52

def stop
  @tasks.each(&:stop)
  @tasks.clear
end