ezmq 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +59 -0
- data/doc/EZMQ.html +2 -2
- data/doc/EZMQ/Client.html +15 -15
- data/doc/EZMQ/Publisher.html +10 -10
- data/doc/EZMQ/Puller.html +276 -0
- data/doc/EZMQ/Pusher.html +276 -0
- data/doc/EZMQ/Server.html +15 -15
- data/doc/EZMQ/Socket.html +172 -56
- data/doc/EZMQ/Subscriber.html +20 -135
- data/doc/_index.html +15 -1
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +70 -16
- data/doc/index.html +70 -16
- data/doc/method_list.html +24 -12
- data/doc/top-level-namespace.html +1 -1
- data/ezmq.gemspec +1 -1
- data/lib/ezmq.rb +59 -32
- metadata +4 -2
data/doc/method_list.html
CHANGED
@@ -88,20 +88,32 @@
|
|
88
88
|
|
89
89
|
|
90
90
|
<li class="r1 ">
|
91
|
-
<span class='object_link'><a href="EZMQ/
|
92
|
-
<small>EZMQ::
|
91
|
+
<span class='object_link'><a href="EZMQ/Pusher.html#initialize-instance_method" title="EZMQ::Pusher#initialize (method)">#initialize</a></span>
|
92
|
+
<small>EZMQ::Pusher</small>
|
93
93
|
</li>
|
94
94
|
|
95
95
|
|
96
96
|
<li class="r2 ">
|
97
|
+
<span class='object_link'><a href="EZMQ/Subscriber.html#initialize-instance_method" title="EZMQ::Subscriber#initialize (method)">#initialize</a></span>
|
98
|
+
<small>EZMQ::Subscriber</small>
|
99
|
+
</li>
|
100
|
+
|
101
|
+
|
102
|
+
<li class="r1 ">
|
97
103
|
<span class='object_link'><a href="EZMQ/Socket.html#initialize-instance_method" title="EZMQ::Socket#initialize (method)">#initialize</a></span>
|
98
104
|
<small>EZMQ::Socket</small>
|
99
105
|
</li>
|
100
106
|
|
101
107
|
|
108
|
+
<li class="r2 ">
|
109
|
+
<span class='object_link'><a href="EZMQ/Publisher.html#initialize-instance_method" title="EZMQ::Publisher#initialize (method)">#initialize</a></span>
|
110
|
+
<small>EZMQ::Publisher</small>
|
111
|
+
</li>
|
112
|
+
|
113
|
+
|
102
114
|
<li class="r1 ">
|
103
|
-
<span class='object_link'><a href="EZMQ/
|
104
|
-
<small>EZMQ::
|
115
|
+
<span class='object_link'><a href="EZMQ/Client.html#initialize-instance_method" title="EZMQ::Client#initialize (method)">#initialize</a></span>
|
116
|
+
<small>EZMQ::Client</small>
|
105
117
|
</li>
|
106
118
|
|
107
119
|
|
@@ -112,8 +124,8 @@
|
|
112
124
|
|
113
125
|
|
114
126
|
<li class="r1 ">
|
115
|
-
<span class='object_link'><a href="EZMQ/
|
116
|
-
<small>EZMQ::
|
127
|
+
<span class='object_link'><a href="EZMQ/Puller.html#initialize-instance_method" title="EZMQ::Puller#initialize (method)">#initialize</a></span>
|
128
|
+
<small>EZMQ::Puller</small>
|
117
129
|
</li>
|
118
130
|
|
119
131
|
|
@@ -124,8 +136,8 @@
|
|
124
136
|
|
125
137
|
|
126
138
|
<li class="r1 ">
|
127
|
-
<span class='object_link'><a href="EZMQ/
|
128
|
-
<small>EZMQ::
|
139
|
+
<span class='object_link'><a href="EZMQ/Socket.html#listen-instance_method" title="EZMQ::Socket#listen (method)">#listen</a></span>
|
140
|
+
<small>EZMQ::Socket</small>
|
129
141
|
</li>
|
130
142
|
|
131
143
|
|
@@ -142,14 +154,14 @@
|
|
142
154
|
|
143
155
|
|
144
156
|
<li class="r2 ">
|
145
|
-
<span class='object_link'><a href="EZMQ/
|
146
|
-
<small>EZMQ::
|
157
|
+
<span class='object_link'><a href="EZMQ/Publisher.html#send-instance_method" title="EZMQ::Publisher#send (method)">#send</a></span>
|
158
|
+
<small>EZMQ::Publisher</small>
|
147
159
|
</li>
|
148
160
|
|
149
161
|
|
150
162
|
<li class="r1 ">
|
151
|
-
<span class='object_link'><a href="EZMQ/
|
152
|
-
<small>EZMQ::
|
163
|
+
<span class='object_link'><a href="EZMQ/Socket.html#send-instance_method" title="EZMQ::Socket#send (method)">#send</a></span>
|
164
|
+
<small>EZMQ::Socket</small>
|
153
165
|
</li>
|
154
166
|
|
155
167
|
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on
|
106
|
+
Generated on Sun Jan 11 14:20:10 2015 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.7.6 (ruby-2.0.0).
|
109
109
|
</div>
|
data/ezmq.gemspec
CHANGED
data/lib/ezmq.rb
CHANGED
@@ -8,7 +8,7 @@ module EZMQ
|
|
8
8
|
|
9
9
|
# Creates a 0MQ socket.
|
10
10
|
#
|
11
|
-
# @param [
|
11
|
+
# @param [:bind, :connect] mode the mode of the socket.
|
12
12
|
# @param [Object] type the type of socket to use.
|
13
13
|
# @param [Hash] options optional parameters.
|
14
14
|
#
|
@@ -16,14 +16,10 @@ module EZMQ
|
|
16
16
|
# (one will be created if not provided).
|
17
17
|
# @option options [lambda] encode how to encode messages.
|
18
18
|
# @option options [lambda] decode how to decode messages.
|
19
|
-
# @option options [String] protocol protocol
|
20
|
-
#
|
21
|
-
# @option options [
|
22
|
-
#
|
23
|
-
# @note 'localhost' does not always work as expected. Prefer '127.0.0.1'
|
24
|
-
# @option options [Fixnum] port port to use for endpoint.
|
25
|
-
# Default: 5555
|
26
|
-
# @note `port` is ignored unless protocol is either 'tcp' or 'udp'.
|
19
|
+
# @option options [String] protocol ('tcp') protocol for transport.
|
20
|
+
# @option options [String] address ('127.0.0.1') address for endpoint.
|
21
|
+
# @option options [Fixnum] port (5555) port for endpoint.
|
22
|
+
# @note port is ignored unless protocol is either 'tcp' or 'udp'.
|
27
23
|
#
|
28
24
|
# @return [Socket] a new instance of Socket.
|
29
25
|
#
|
@@ -37,9 +33,9 @@ module EZMQ
|
|
37
33
|
method(mode).call endpoint
|
38
34
|
end
|
39
35
|
|
40
|
-
# Sends a message
|
36
|
+
# Sends a message to the socket.
|
41
37
|
#
|
42
|
-
# @note If
|
38
|
+
# @note If message is not a String, #encode must convert it to one.
|
43
39
|
#
|
44
40
|
# @param [String] message the message to send.
|
45
41
|
# @param [Hash] options optional parameters.
|
@@ -77,11 +73,12 @@ module EZMQ
|
|
77
73
|
|
78
74
|
# Binds the socket to the given address.
|
79
75
|
#
|
80
|
-
# @param [String] protocol protocol
|
81
|
-
# @param [String] address
|
82
|
-
# @note 'localhost'
|
83
|
-
#
|
84
|
-
# @
|
76
|
+
# @param [String] protocol ('tcp') protocol for transport.
|
77
|
+
# @param [String] address ('127.0.0.1') address for endpoint.
|
78
|
+
# @note An address of 'localhost' is not reliable on all platforms.
|
79
|
+
# Prefer '127.0.0.1' instead.
|
80
|
+
# @param [Fixnum] port (5555) port for endpoint.
|
81
|
+
# @note port is ignored unless protocol is either 'tcp' or 'udp'.
|
85
82
|
#
|
86
83
|
# @return [Boolean] was binding successful?
|
87
84
|
#
|
@@ -93,10 +90,10 @@ module EZMQ
|
|
93
90
|
|
94
91
|
# Connects the socket to the given address.
|
95
92
|
#
|
96
|
-
# @param [String] protocol protocol
|
97
|
-
# @param [String] address
|
98
|
-
# @param [Fixnum] port port
|
99
|
-
# @note
|
93
|
+
# @param [String] protocol ('tcp') protocol for transport.
|
94
|
+
# @param [String] address ('127.0.0.1') address for endpoint.
|
95
|
+
# @param [Fixnum] port (5555) port for endpoint.
|
96
|
+
# @note port is ignored unless protocol is either 'tcp' or 'udp'.
|
100
97
|
#
|
101
98
|
# @return [Boolean] was connection successful?
|
102
99
|
#
|
@@ -105,6 +102,23 @@ module EZMQ
|
|
105
102
|
endpoint = "#{ endpoint }:#{ port }" if %w(tcp udp).include? protocol
|
106
103
|
@socket.connect(endpoint) == 0
|
107
104
|
end
|
105
|
+
|
106
|
+
# By default, waits for a message and prints it to STDOUT.
|
107
|
+
#
|
108
|
+
# @yield message passes the message received to the block.
|
109
|
+
# @yieldparam [String] message the message received.
|
110
|
+
#
|
111
|
+
# @return [void]
|
112
|
+
#
|
113
|
+
def listen
|
114
|
+
loop do
|
115
|
+
if block_given?
|
116
|
+
yield receive
|
117
|
+
else
|
118
|
+
puts receive
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
108
122
|
end
|
109
123
|
|
110
124
|
# Request socket that sends messages and receives replies.
|
@@ -245,22 +259,35 @@ module EZMQ
|
|
245
259
|
def unsubscribe(topic)
|
246
260
|
@socket.setsockopt(ZMQ::UNSUBSCRIBE, topic) == 0
|
247
261
|
end
|
262
|
+
end
|
248
263
|
|
249
|
-
|
264
|
+
# Push socket that sends messages but does not receive them.
|
265
|
+
class Pusher < EZMQ::Socket
|
266
|
+
# Creates a new Pusher socket.
|
250
267
|
#
|
251
|
-
# @
|
252
|
-
# @
|
268
|
+
# @param [:bind, :connect] mode a mode for the socket.
|
269
|
+
# @param [Hash] options optional parameters.
|
270
|
+
# @see EZMQ::Socket EZMQ::Socket for optional parameters.
|
253
271
|
#
|
254
|
-
# @return [
|
272
|
+
# @return [Pusher] a new instance of Pusher.
|
255
273
|
#
|
256
|
-
def
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
274
|
+
def initialize(mode = :connect, **options)
|
275
|
+
super mode, ZMQ::PUSH, options
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
# Pull socket that receives messages but does not send them.
|
280
|
+
class Puller < EZMQ::Socket
|
281
|
+
# Creates a new Puller socket.
|
282
|
+
#
|
283
|
+
# @param [:bind, :connect] mode a mode for the socket.
|
284
|
+
# @param [Hash] options optional parameters.
|
285
|
+
# @see EZMQ::Socket EZMQ::Socket for optional parameters.
|
286
|
+
#
|
287
|
+
# @return [Puller] a new instance of Puller.
|
288
|
+
#
|
289
|
+
def initialize(mode = :bind, **options)
|
290
|
+
super mode, ZMQ::PULL, options
|
264
291
|
end
|
265
292
|
end
|
266
293
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezmq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Olstrom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-rzmq
|
@@ -166,6 +166,8 @@ files:
|
|
166
166
|
- doc/EZMQ.html
|
167
167
|
- doc/EZMQ/Client.html
|
168
168
|
- doc/EZMQ/Publisher.html
|
169
|
+
- doc/EZMQ/Puller.html
|
170
|
+
- doc/EZMQ/Pusher.html
|
169
171
|
- doc/EZMQ/Server.html
|
170
172
|
- doc/EZMQ/Socket.html
|
171
173
|
- doc/EZMQ/Subscriber.html
|