omq 0.23.0 → 0.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +144 -3
- data/README.md +23 -7
- data/lib/omq/client_server.rb +1 -1
- data/lib/omq/engine/connection_lifecycle.rb +12 -6
- data/lib/omq/engine/heartbeat.rb +1 -1
- data/lib/omq/engine/recv_pump.rb +29 -16
- data/lib/omq/engine.rb +6 -5
- data/lib/omq/ffi/engine.rb +646 -0
- data/lib/omq/ffi/libzmq.rb +134 -0
- data/lib/omq/ffi.rb +12 -0
- data/lib/omq/peer.rb +1 -1
- data/lib/omq/radio_dish.rb +1 -1
- data/lib/omq/readable.rb +5 -1
- data/lib/omq/routing/channel.rb +4 -4
- data/lib/omq/routing/client.rb +2 -2
- data/lib/omq/routing/conn_send_pump.rb +1 -1
- data/lib/omq/routing/dealer.rb +2 -2
- data/lib/omq/routing/dish.rb +2 -2
- data/lib/omq/routing/fan_out.rb +7 -7
- data/lib/omq/routing/gather.rb +2 -2
- data/lib/omq/routing/pair.rb +4 -4
- data/lib/omq/routing/peer.rb +2 -2
- data/lib/omq/routing/pub.rb +2 -2
- data/lib/omq/routing/pull.rb +2 -2
- data/lib/omq/routing/push.rb +3 -3
- data/lib/omq/routing/radio.rb +2 -2
- data/lib/omq/routing/rep.rb +2 -2
- data/lib/omq/routing/req.rb +2 -2
- data/lib/omq/routing/round_robin.rb +4 -4
- data/lib/omq/routing/router.rb +2 -2
- data/lib/omq/routing/scatter.rb +4 -5
- data/lib/omq/routing/server.rb +2 -2
- data/lib/omq/routing/sub.rb +2 -2
- data/lib/omq/routing/xpub.rb +2 -2
- data/lib/omq/routing/xsub.rb +2 -2
- data/lib/omq/socket.rb +2 -1
- data/lib/omq/transport/inproc/{direct_pipe.rb → pipe.rb} +22 -9
- data/lib/omq/transport/inproc.rb +26 -14
- data/lib/omq/transport/udp.rb +1 -1
- data/lib/omq/version.rb +1 -1
- data/lib/omq/writable.rb +32 -43
- metadata +5 -2
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ffi"
|
|
4
|
+
|
|
5
|
+
module OMQ
|
|
6
|
+
module FFI
|
|
7
|
+
# Minimal libzmq FFI bindings — only what OMQ needs.
|
|
8
|
+
#
|
|
9
|
+
module Libzmq
|
|
10
|
+
extend ::FFI::Library
|
|
11
|
+
ffi_lib ["libzmq.so.5", "libzmq.5.dylib", "libzmq"]
|
|
12
|
+
|
|
13
|
+
# Context
|
|
14
|
+
attach_function :zmq_ctx_new, [], :pointer
|
|
15
|
+
attach_function :zmq_ctx_term, [:pointer], :int
|
|
16
|
+
attach_function :zmq_ctx_shutdown, [:pointer], :int
|
|
17
|
+
|
|
18
|
+
# Socket
|
|
19
|
+
attach_function :zmq_socket, [:pointer, :int], :pointer
|
|
20
|
+
attach_function :zmq_close, [:pointer], :int
|
|
21
|
+
attach_function :zmq_bind, [:pointer, :string], :int
|
|
22
|
+
attach_function :zmq_connect, [:pointer, :string], :int
|
|
23
|
+
attach_function :zmq_disconnect, [:pointer, :string], :int
|
|
24
|
+
attach_function :zmq_unbind, [:pointer, :string], :int
|
|
25
|
+
|
|
26
|
+
# Message
|
|
27
|
+
attach_function :zmq_msg_init, [:pointer], :int
|
|
28
|
+
attach_function :zmq_msg_init_size, [:pointer, :size_t], :int
|
|
29
|
+
attach_function :zmq_msg_data, [:pointer], :pointer
|
|
30
|
+
attach_function :zmq_msg_size, [:pointer], :size_t
|
|
31
|
+
attach_function :zmq_msg_close, [:pointer], :int
|
|
32
|
+
attach_function :zmq_msg_send, [:pointer, :pointer, :int], :int
|
|
33
|
+
attach_function :zmq_msg_recv, [:pointer, :pointer, :int], :int
|
|
34
|
+
|
|
35
|
+
# Socket options
|
|
36
|
+
attach_function :zmq_setsockopt, [:pointer, :int, :pointer, :size_t], :int
|
|
37
|
+
attach_function :zmq_getsockopt, [:pointer, :int, :pointer, :pointer], :int
|
|
38
|
+
|
|
39
|
+
# Group membership (RADIO/DISH) — draft API, may not be available
|
|
40
|
+
begin
|
|
41
|
+
attach_function :zmq_join, [:pointer, :string], :int
|
|
42
|
+
attach_function :zmq_leave, [:pointer, :string], :int
|
|
43
|
+
rescue ::FFI::NotFoundError
|
|
44
|
+
# libzmq built without ZMQ_BUILD_DRAFT_API
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# Error
|
|
49
|
+
attach_function :zmq_errno, [], :int
|
|
50
|
+
attach_function :zmq_strerror, [:int], :string
|
|
51
|
+
|
|
52
|
+
# Socket types
|
|
53
|
+
ZMQ_PAIR = 0
|
|
54
|
+
ZMQ_PUB = 1
|
|
55
|
+
ZMQ_SUB = 2
|
|
56
|
+
ZMQ_REQ = 3
|
|
57
|
+
ZMQ_REP = 4
|
|
58
|
+
ZMQ_DEALER = 5
|
|
59
|
+
ZMQ_ROUTER = 6
|
|
60
|
+
ZMQ_PULL = 7
|
|
61
|
+
ZMQ_PUSH = 8
|
|
62
|
+
ZMQ_XPUB = 9
|
|
63
|
+
ZMQ_XSUB = 10
|
|
64
|
+
ZMQ_SERVER = 12
|
|
65
|
+
ZMQ_CLIENT = 13
|
|
66
|
+
ZMQ_RADIO = 14
|
|
67
|
+
ZMQ_DISH = 15
|
|
68
|
+
ZMQ_GATHER = 16
|
|
69
|
+
ZMQ_SCATTER = 17
|
|
70
|
+
ZMQ_PEER = 19
|
|
71
|
+
ZMQ_CHANNEL = 20
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# Socket type name → constant
|
|
75
|
+
SOCKET_TYPES = {
|
|
76
|
+
PAIR: ZMQ_PAIR, PUB: ZMQ_PUB, SUB: ZMQ_SUB,
|
|
77
|
+
REQ: ZMQ_REQ, REP: ZMQ_REP,
|
|
78
|
+
DEALER: ZMQ_DEALER, ROUTER: ZMQ_ROUTER,
|
|
79
|
+
PULL: ZMQ_PULL, PUSH: ZMQ_PUSH,
|
|
80
|
+
XPUB: ZMQ_XPUB, XSUB: ZMQ_XSUB,
|
|
81
|
+
SERVER: ZMQ_SERVER, CLIENT: ZMQ_CLIENT,
|
|
82
|
+
RADIO: ZMQ_RADIO, DISH: ZMQ_DISH,
|
|
83
|
+
GATHER: ZMQ_GATHER, SCATTER: ZMQ_SCATTER,
|
|
84
|
+
PEER: ZMQ_PEER, CHANNEL: ZMQ_CHANNEL,
|
|
85
|
+
}.freeze
|
|
86
|
+
|
|
87
|
+
# Send/recv flags
|
|
88
|
+
ZMQ_DONTWAIT = 1
|
|
89
|
+
ZMQ_SNDMORE = 2
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# Socket options
|
|
93
|
+
ZMQ_IDENTITY = 5
|
|
94
|
+
ZMQ_SUBSCRIBE = 6
|
|
95
|
+
ZMQ_UNSUBSCRIBE = 7
|
|
96
|
+
ZMQ_RCVMORE = 13
|
|
97
|
+
ZMQ_FD = 14
|
|
98
|
+
ZMQ_EVENTS = 15
|
|
99
|
+
ZMQ_LINGER = 17
|
|
100
|
+
ZMQ_SNDHWM = 23
|
|
101
|
+
ZMQ_RCVHWM = 24
|
|
102
|
+
ZMQ_RCVTIMEO = 27
|
|
103
|
+
ZMQ_SNDTIMEO = 28
|
|
104
|
+
ZMQ_MAXMSGSIZE = 22
|
|
105
|
+
ZMQ_LAST_ENDPOINT = 32
|
|
106
|
+
ZMQ_ROUTER_MANDATORY = 33
|
|
107
|
+
ZMQ_RECONNECT_IVL = 18
|
|
108
|
+
ZMQ_RECONNECT_IVL_MAX = 21
|
|
109
|
+
ZMQ_CONFLATE = 54
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# zmq_msg_t is 64 bytes on all platforms
|
|
113
|
+
MSG_T_SIZE = 64
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
# Allocates a zmq_msg_t on the heap.
|
|
117
|
+
#
|
|
118
|
+
# @return [FFI::MemoryPointer]
|
|
119
|
+
#
|
|
120
|
+
def self.alloc_msg
|
|
121
|
+
::FFI::MemoryPointer.new(MSG_T_SIZE)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# Raises an error with the current zmq_errno message.
|
|
126
|
+
#
|
|
127
|
+
def self.check!(rc, label = "zmq")
|
|
128
|
+
return rc if rc >= 0
|
|
129
|
+
errno = zmq_errno
|
|
130
|
+
raise "#{label}: #{zmq_strerror(errno)} (errno #{errno})"
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
data/lib/omq/ffi.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Load the FFI backend for OMQ.
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# require "omq/ffi"
|
|
7
|
+
# push = OMQ::PUSH.new(backend: :ffi)
|
|
8
|
+
#
|
|
9
|
+
# Raises LoadError if libzmq is not installed.
|
|
10
|
+
|
|
11
|
+
require_relative "ffi/libzmq"
|
|
12
|
+
require_relative "ffi/engine"
|
data/lib/omq/peer.rb
CHANGED
data/lib/omq/radio_dish.rb
CHANGED
data/lib/omq/readable.rb
CHANGED
|
@@ -14,7 +14,11 @@ module OMQ
|
|
|
14
14
|
# @raise [IO::TimeoutError] if read_timeout exceeded
|
|
15
15
|
#
|
|
16
16
|
def receive
|
|
17
|
-
|
|
17
|
+
if @engine.on_io_thread?
|
|
18
|
+
Reactor.run(timeout: @options.read_timeout) { @engine.dequeue_recv }
|
|
19
|
+
elsif (timeout = @options.read_timeout)
|
|
20
|
+
Async::Task.current.with_timeout(timeout, IO::TimeoutError) { @engine.dequeue_recv }
|
|
21
|
+
else
|
|
18
22
|
@engine.dequeue_recv
|
|
19
23
|
end
|
|
20
24
|
end
|
data/lib/omq/routing/channel.rb
CHANGED
|
@@ -39,7 +39,7 @@ module OMQ
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
# @param connection [Connection]
|
|
42
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
43
43
|
# @raise [RuntimeError] if a connection already exists
|
|
44
44
|
#
|
|
45
45
|
def connection_added(connection)
|
|
@@ -48,7 +48,7 @@ module OMQ
|
|
|
48
48
|
|
|
49
49
|
@engine.start_recv_pump(connection, @recv_queue)
|
|
50
50
|
|
|
51
|
-
unless connection.is_a?(Transport::Inproc::
|
|
51
|
+
unless connection.is_a?(Transport::Inproc::Pipe)
|
|
52
52
|
@send_queue = Routing.build_queue(@engine.options.send_hwm, :block)
|
|
53
53
|
while (msg = @staging_queue.dequeue(timeout: 0))
|
|
54
54
|
@send_queue.enqueue(msg)
|
|
@@ -58,7 +58,7 @@ module OMQ
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
# @param connection [Connection]
|
|
61
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
62
62
|
#
|
|
63
63
|
def connection_removed(connection)
|
|
64
64
|
if @connection == connection
|
|
@@ -72,7 +72,7 @@ module OMQ
|
|
|
72
72
|
#
|
|
73
73
|
def enqueue(parts)
|
|
74
74
|
conn = @connection
|
|
75
|
-
if conn.is_a?(Transport::Inproc::
|
|
75
|
+
if conn.is_a?(Transport::Inproc::Pipe) && conn.direct_recv_queue
|
|
76
76
|
conn.send_message(parts)
|
|
77
77
|
elsif @send_queue
|
|
78
78
|
@send_queue.enqueue(parts)
|
data/lib/omq/routing/client.rb
CHANGED
|
@@ -42,7 +42,7 @@ module OMQ
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
# @param connection [Connection]
|
|
45
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
46
46
|
#
|
|
47
47
|
def connection_added(connection)
|
|
48
48
|
@connections << connection
|
|
@@ -51,7 +51,7 @@ module OMQ
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
# @param connection [Connection]
|
|
54
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
55
55
|
#
|
|
56
56
|
def connection_removed(connection)
|
|
57
57
|
@connections.delete(connection)
|
data/lib/omq/routing/dealer.rb
CHANGED
|
@@ -42,7 +42,7 @@ module OMQ
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
# @param connection [Connection]
|
|
45
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
46
46
|
#
|
|
47
47
|
def connection_added(connection)
|
|
48
48
|
@engine.start_recv_pump(connection, @recv_queue)
|
|
@@ -50,7 +50,7 @@ module OMQ
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
# @param connection [Connection]
|
|
53
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
54
54
|
#
|
|
55
55
|
def connection_removed(connection)
|
|
56
56
|
@connections.delete(connection)
|
data/lib/omq/routing/dish.rb
CHANGED
|
@@ -41,7 +41,7 @@ module OMQ
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
# @param connection [Connection]
|
|
44
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
45
45
|
#
|
|
46
46
|
def connection_added(connection)
|
|
47
47
|
@connections << connection
|
|
@@ -52,7 +52,7 @@ module OMQ
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
# @param connection [Connection]
|
|
55
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
56
56
|
#
|
|
57
57
|
def connection_removed(connection)
|
|
58
58
|
@connections.delete(connection)
|
data/lib/omq/routing/fan_out.rb
CHANGED
|
@@ -61,7 +61,7 @@ module OMQ
|
|
|
61
61
|
# Override in subclasses to expose subscriptions to the
|
|
62
62
|
# application (e.g. XPUB enqueues to recv_queue).
|
|
63
63
|
#
|
|
64
|
-
# @param conn [Connection]
|
|
64
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
65
65
|
# @param prefix [String]
|
|
66
66
|
#
|
|
67
67
|
def on_subscribe(conn, prefix)
|
|
@@ -74,7 +74,7 @@ module OMQ
|
|
|
74
74
|
# Called when a cancel command is received from a peer.
|
|
75
75
|
# Override in subclasses (e.g. XPUB enqueues to recv_queue).
|
|
76
76
|
#
|
|
77
|
-
# @param conn [Connection]
|
|
77
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
78
78
|
# @param prefix [String]
|
|
79
79
|
#
|
|
80
80
|
def on_cancel(conn, prefix)
|
|
@@ -86,7 +86,7 @@ module OMQ
|
|
|
86
86
|
# Creates a per-connection send queue and starts its send pump.
|
|
87
87
|
# Call from #connection_added.
|
|
88
88
|
#
|
|
89
|
-
# @param conn [Connection]
|
|
89
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
90
90
|
#
|
|
91
91
|
def add_fan_out_send_connection(conn)
|
|
92
92
|
q = Routing.build_queue(@engine.options.send_hwm, @engine.options.on_mute)
|
|
@@ -99,7 +99,7 @@ module OMQ
|
|
|
99
99
|
# down by the per-connection lifecycle barrier.
|
|
100
100
|
# Call from #connection_removed.
|
|
101
101
|
#
|
|
102
|
-
# @param conn [Connection]
|
|
102
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
103
103
|
#
|
|
104
104
|
def remove_fan_out_send_connection(conn)
|
|
105
105
|
@subscribe_all.delete(conn)
|
|
@@ -152,7 +152,7 @@ module OMQ
|
|
|
152
152
|
# In conflate mode, drains the batch and keeps only the latest
|
|
153
153
|
# message per topic before writing.
|
|
154
154
|
#
|
|
155
|
-
# @param conn [Connection]
|
|
155
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
156
156
|
# @param q [Async::LimitedQueue, DropQueue]
|
|
157
157
|
#
|
|
158
158
|
def start_conn_send_pump(conn, q)
|
|
@@ -169,7 +169,7 @@ module OMQ
|
|
|
169
169
|
# Send pump variant for non-conflate fan-out: dequeues, batch-drains,
|
|
170
170
|
# writes each subscribed message, then flushes once.
|
|
171
171
|
#
|
|
172
|
-
# @param conn [Connection]
|
|
172
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
173
173
|
# @param q [Async::LimitedQueue, DropQueue]
|
|
174
174
|
# @param use_wire [Boolean] true iff the encoded wire bytes can
|
|
175
175
|
# be shared across peers (unencrypted ZMTP)
|
|
@@ -219,7 +219,7 @@ module OMQ
|
|
|
219
219
|
# Send pump variant for conflate mode: keeps only the latest
|
|
220
220
|
# subscribed message per batch. Stale duplicates are dropped.
|
|
221
221
|
#
|
|
222
|
-
# @param conn [Connection]
|
|
222
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
223
223
|
# @param q [Async::LimitedQueue, DropQueue]
|
|
224
224
|
# @return [Async::Task]
|
|
225
225
|
#
|
data/lib/omq/routing/gather.rb
CHANGED
|
@@ -36,14 +36,14 @@ module OMQ
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
# @param connection [Connection]
|
|
39
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
40
40
|
#
|
|
41
41
|
def connection_added(connection)
|
|
42
42
|
@engine.start_recv_pump(connection, @recv_queue)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
# @param connection [Connection]
|
|
46
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
47
47
|
#
|
|
48
48
|
def connection_removed(connection)
|
|
49
49
|
end
|
data/lib/omq/routing/pair.rb
CHANGED
|
@@ -43,7 +43,7 @@ module OMQ
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
# @param connection [Connection]
|
|
46
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
47
47
|
# @raise [RuntimeError] if a connection already exists
|
|
48
48
|
#
|
|
49
49
|
def connection_added(connection)
|
|
@@ -52,13 +52,13 @@ module OMQ
|
|
|
52
52
|
|
|
53
53
|
@engine.start_recv_pump(connection, @recv_queue)
|
|
54
54
|
|
|
55
|
-
unless connection.is_a?(Transport::Inproc::
|
|
55
|
+
unless connection.is_a?(Transport::Inproc::Pipe)
|
|
56
56
|
start_send_pump(connection)
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
# @param connection [Connection]
|
|
61
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
62
62
|
#
|
|
63
63
|
def connection_removed(connection)
|
|
64
64
|
@connection = nil if @connection == connection
|
|
@@ -69,7 +69,7 @@ module OMQ
|
|
|
69
69
|
#
|
|
70
70
|
def enqueue(parts)
|
|
71
71
|
conn = @connection
|
|
72
|
-
if conn.is_a?(Transport::Inproc::
|
|
72
|
+
if conn.is_a?(Transport::Inproc::Pipe) && conn.direct_recv_queue
|
|
73
73
|
conn.send_message(parts)
|
|
74
74
|
else
|
|
75
75
|
@send_queue.enqueue(parts)
|
data/lib/omq/routing/peer.rb
CHANGED
|
@@ -50,7 +50,7 @@ module OMQ
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
# @param connection [Connection]
|
|
53
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
54
54
|
#
|
|
55
55
|
def connection_added(connection)
|
|
56
56
|
routing_id = SecureRandom.bytes(4)
|
|
@@ -65,7 +65,7 @@ module OMQ
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
# @param connection [Connection]
|
|
68
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
69
69
|
#
|
|
70
70
|
def connection_removed(connection)
|
|
71
71
|
routing_id = @routing_id_by_connection.delete(connection)
|
data/lib/omq/routing/pub.rb
CHANGED
|
@@ -36,7 +36,7 @@ module OMQ
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
# @param connection [Connection]
|
|
39
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
40
40
|
#
|
|
41
41
|
def connection_added(connection)
|
|
42
42
|
@connections << connection
|
|
@@ -46,7 +46,7 @@ module OMQ
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
# @param connection [Connection]
|
|
49
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
50
50
|
#
|
|
51
51
|
def connection_removed(connection)
|
|
52
52
|
@connections.delete(connection)
|
data/lib/omq/routing/pull.rb
CHANGED
|
@@ -38,14 +38,14 @@ module OMQ
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
# @param connection [Connection]
|
|
41
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
42
42
|
#
|
|
43
43
|
def connection_added(connection)
|
|
44
44
|
@engine.start_recv_pump(connection, @recv_queue)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
# @param connection [Connection]
|
|
48
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
49
49
|
#
|
|
50
50
|
def connection_removed(connection)
|
|
51
51
|
# recv pump stops on EOFError via its connection barrier
|
data/lib/omq/routing/push.rb
CHANGED
|
@@ -33,7 +33,7 @@ module OMQ
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
# @param connection [Connection]
|
|
36
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
37
37
|
#
|
|
38
38
|
def connection_added(connection)
|
|
39
39
|
add_round_robin_send_connection(connection)
|
|
@@ -41,7 +41,7 @@ module OMQ
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
# @param connection [Connection]
|
|
44
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
45
45
|
#
|
|
46
46
|
def connection_removed(connection)
|
|
47
47
|
@connections.delete(connection)
|
|
@@ -64,7 +64,7 @@ module OMQ
|
|
|
64
64
|
# may succeed if the kernel send buffer absorbs the data.
|
|
65
65
|
#
|
|
66
66
|
def start_reaper(conn)
|
|
67
|
-
return if conn.is_a?(Transport::Inproc::
|
|
67
|
+
return if conn.is_a?(Transport::Inproc::Pipe)
|
|
68
68
|
@engine.spawn_conn_pump_task(conn, annotation: "reaper") do
|
|
69
69
|
conn.receive_message # blocks until peer disconnects; then exits
|
|
70
70
|
end
|
data/lib/omq/routing/radio.rb
CHANGED
|
@@ -50,7 +50,7 @@ module OMQ
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
# @param connection [Connection]
|
|
53
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
54
54
|
#
|
|
55
55
|
def connection_added(connection)
|
|
56
56
|
@connections << connection
|
|
@@ -64,7 +64,7 @@ module OMQ
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
# @param connection [Connection]
|
|
67
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
68
68
|
#
|
|
69
69
|
def connection_removed(connection)
|
|
70
70
|
@connections.delete(connection)
|
data/lib/omq/routing/rep.rb
CHANGED
|
@@ -45,7 +45,7 @@ module OMQ
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
# @param connection [Connection]
|
|
48
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
49
49
|
#
|
|
50
50
|
def connection_added(connection)
|
|
51
51
|
@engine.start_recv_pump(connection, @recv_queue) do |msg|
|
|
@@ -63,7 +63,7 @@ module OMQ
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
# @param connection [Connection]
|
|
66
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
67
67
|
#
|
|
68
68
|
def connection_removed(connection)
|
|
69
69
|
@pending_replies.reject! { |r| r[0] == connection }
|
data/lib/omq/routing/req.rb
CHANGED
|
@@ -46,7 +46,7 @@ module OMQ
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
# @param connection [Connection]
|
|
49
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
50
50
|
#
|
|
51
51
|
def connection_added(connection)
|
|
52
52
|
@engine.start_recv_pump(connection, @recv_queue) do |msg|
|
|
@@ -58,7 +58,7 @@ module OMQ
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
# @param connection [Connection]
|
|
61
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
62
62
|
#
|
|
63
63
|
def connection_removed(connection)
|
|
64
64
|
@connections.delete(connection)
|
|
@@ -48,7 +48,7 @@ module OMQ
|
|
|
48
48
|
# Registers a connection and starts its send pump.
|
|
49
49
|
# Call from #connection_added.
|
|
50
50
|
#
|
|
51
|
-
# @param conn [Connection]
|
|
51
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
52
52
|
#
|
|
53
53
|
def add_round_robin_send_connection(conn)
|
|
54
54
|
@connections << conn
|
|
@@ -63,7 +63,7 @@ module OMQ
|
|
|
63
63
|
# guarantee, so this is safe. The pump itself is torn down by
|
|
64
64
|
# the per-connection lifecycle barrier.
|
|
65
65
|
#
|
|
66
|
-
# @param conn [Connection]
|
|
66
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
67
67
|
#
|
|
68
68
|
def remove_round_robin_send_connection(conn)
|
|
69
69
|
update_direct_pipe
|
|
@@ -73,7 +73,7 @@ module OMQ
|
|
|
73
73
|
# Updates the direct-pipe shortcut for inproc single-peer bypass.
|
|
74
74
|
#
|
|
75
75
|
def update_direct_pipe
|
|
76
|
-
if @connections.size == 1 && @connections.first.is_a?(Transport::Inproc::
|
|
76
|
+
if @connections.size == 1 && @connections.first.is_a?(Transport::Inproc::Pipe)
|
|
77
77
|
@direct_pipe = @connections.first
|
|
78
78
|
else
|
|
79
79
|
@direct_pipe = nil
|
|
@@ -128,7 +128,7 @@ module OMQ
|
|
|
128
128
|
# run. The yield is effectively free when the scheduler has no
|
|
129
129
|
# other work.
|
|
130
130
|
#
|
|
131
|
-
# @param conn [Connection]
|
|
131
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
132
132
|
#
|
|
133
133
|
def start_conn_send_pump(conn)
|
|
134
134
|
@engine.spawn_conn_pump_task(conn, annotation: "send pump") do
|
data/lib/omq/routing/router.rb
CHANGED
|
@@ -45,7 +45,7 @@ module OMQ
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
# @param connection [Connection]
|
|
48
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
49
49
|
#
|
|
50
50
|
def connection_added(connection)
|
|
51
51
|
identity = connection.peer_identity
|
|
@@ -61,7 +61,7 @@ module OMQ
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
# @param connection [Connection]
|
|
64
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
65
65
|
#
|
|
66
66
|
def connection_removed(connection)
|
|
67
67
|
identity = @identity_by_connection.delete(connection)
|
data/lib/omq/routing/scatter.rb
CHANGED
|
@@ -33,16 +33,15 @@ module OMQ
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
# @param connection [Connection]
|
|
36
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
37
37
|
#
|
|
38
38
|
def connection_added(connection)
|
|
39
|
-
@connections << connection
|
|
40
39
|
add_round_robin_send_connection(connection)
|
|
41
40
|
start_reaper(connection)
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
|
|
45
|
-
# @param connection [Connection]
|
|
44
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
46
45
|
#
|
|
47
46
|
def connection_removed(connection)
|
|
48
47
|
@connections.delete(connection)
|
|
@@ -63,10 +62,10 @@ module OMQ
|
|
|
63
62
|
# Detects peer disconnection on write-only sockets by
|
|
64
63
|
# blocking on a receive that only returns on disconnect.
|
|
65
64
|
#
|
|
66
|
-
# @param conn [Connection]
|
|
65
|
+
# @param conn [Protocol::ZMTP::Connection]
|
|
67
66
|
#
|
|
68
67
|
def start_reaper(conn)
|
|
69
|
-
return if conn.is_a?(Transport::Inproc::
|
|
68
|
+
return if conn.is_a?(Transport::Inproc::Pipe)
|
|
70
69
|
@engine.spawn_conn_pump_task(conn, annotation: "reaper") do
|
|
71
70
|
conn.receive_message # blocks until peer disconnects; then exits
|
|
72
71
|
end
|
data/lib/omq/routing/server.rb
CHANGED
|
@@ -45,7 +45,7 @@ module OMQ
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
# @param connection [Connection]
|
|
48
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
49
49
|
#
|
|
50
50
|
def connection_added(connection)
|
|
51
51
|
routing_id = SecureRandom.bytes(4)
|
|
@@ -60,7 +60,7 @@ module OMQ
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
# @param connection [Connection]
|
|
63
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
64
64
|
#
|
|
65
65
|
def connection_removed(connection)
|
|
66
66
|
routing_id = @routing_id_by_connection.delete(connection)
|
data/lib/omq/routing/sub.rb
CHANGED
|
@@ -41,7 +41,7 @@ module OMQ
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
# @param connection [Connection]
|
|
44
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
45
45
|
#
|
|
46
46
|
def connection_added(connection)
|
|
47
47
|
@connections << connection
|
|
@@ -54,7 +54,7 @@ module OMQ
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
# @param connection [Connection]
|
|
57
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
58
58
|
#
|
|
59
59
|
def connection_removed(connection)
|
|
60
60
|
@connections.delete(connection)
|
data/lib/omq/routing/xpub.rb
CHANGED
|
@@ -41,7 +41,7 @@ module OMQ
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
# @param connection [Connection]
|
|
44
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
45
45
|
#
|
|
46
46
|
def connection_added(connection)
|
|
47
47
|
@connections << connection
|
|
@@ -51,7 +51,7 @@ module OMQ
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
# @param connection [Connection]
|
|
54
|
+
# @param connection [Protocol::ZMTP::Connection]
|
|
55
55
|
#
|
|
56
56
|
def connection_removed(connection)
|
|
57
57
|
@connections.delete(connection)
|