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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acd34ba3fc6400948cb525260fffeb2c537f9efa
4
- data.tar.gz: f62399fa0d1b808429b8c18cf17bd38f709bac47
3
+ metadata.gz: 6ab0525484eaa3a85997daa74351b47ed170555a
4
+ data.tar.gz: 9c1235eaf262177ff07679c21ad4f4974e56bb28
5
5
  SHA512:
6
- metadata.gz: 9340fc6c1f9a1df80f29446e56cd69d49eeadd44336e4ef5201a91cc7f76c797aac653dc9046766d419ed60d4c53fe5192e75b926895db2c2255ea3c80299bfb
7
- data.tar.gz: f6f2a361fcbb633dc8d1373d77dec5ebe415f3bec465eb91c2b75496ce2c7fb8bd58f2e379ef22a83186921469663d835eeea1983db82a5f7bcb666e7dcc72e6
6
+ metadata.gz: 253f420fdc12f74a9aad39757272e6a81d575f085e953bb2846a3a5d6541e61bb8c8308d67edd2b63557e842bb96d7b7a917e6a9a6be62a6a300261d91a06b9d
7
+ data.tar.gz: 3ce26fbac959bdb3208a35083d9a0b5c9ddd377e2df32059bdaa65e57bbd3d7b3917d06f57e0aca25c5b3ca8d1e49b832cf1f1977f8e8c31ff00fb3f2e594767
data/README.md CHANGED
@@ -47,6 +47,7 @@ server.listen do |message|
47
47
  puts message
48
48
  'Thanks for the message!' # The return of the block is sent to the client.
49
49
  end
50
+ ```
50
51
 
51
52
  JSON Echo Server
52
53
  ----------------
@@ -99,6 +100,64 @@ subscriber = EZMQ.Subscriber.new topic: 'foorever'
99
100
  subscriber.listen
100
101
  ````
101
102
 
103
+ Pipeline Work Generator
104
+ ------------------------
105
+ Generates work, distributes it to workers via PUSH socket.
106
+
107
+ ```
108
+ require 'ezmq'
109
+ require 'json'
110
+
111
+ generator = EZMQ::Pusher.new :bind, encode: -> m { JSON.dump m }
112
+
113
+ 15.times do |id|
114
+ work = { 'id' => "task_#{ id }", 'request' => '100' }
115
+ puts "Generated work #{work}"
116
+ generator.send work
117
+ end
118
+
119
+ ```
120
+
121
+ Pipeline Workers
122
+ ---------------
123
+ 3 worker threads PULL work from the Generator and PUSH results to the Collector.
124
+
125
+ The 'work' here is generating a random number between 1 and a requested maximum.
126
+
127
+ ```
128
+ require 'ezmq'
129
+ require 'json'
130
+
131
+ workers = []
132
+
133
+ 3.times do |id|
134
+ workers << Thread.new do
135
+ input = EZMQ::Puller.new :connect, decode: -> m { JSON.load m }
136
+ output = EZMQ::Pusher.new port: 5556, encode: -> m { JSON.dump m }
137
+ input.listen do |work|
138
+ puts "Worker #{id} pulled #{work}"
139
+ result = rand(1..work['request'].to_i)
140
+ report = { 'id' => work['id'], 'result' => result }
141
+ output.send report
142
+ end
143
+ end
144
+ end
145
+
146
+ workers.each(&:join)
147
+ ```
148
+
149
+ Pipeline Results Collector
150
+ --------------------------
151
+ PULLs results from workers and prints it to STDOUT.
152
+
153
+ ```
154
+ require 'ezmq'
155
+ require 'json'
156
+
157
+ collector = EZMQ::Puller.new port: 5556
158
+ collector.listen
159
+ ```
160
+
102
161
  Operating System Notes
103
162
  ======================
104
163
 
@@ -101,7 +101,7 @@
101
101
 
102
102
 
103
103
 
104
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="EZMQ/Client.html" title="EZMQ::Client (class)">Client</a></span>, <span class='object_link'><a href="EZMQ/Publisher.html" title="EZMQ::Publisher (class)">Publisher</a></span>, <span class='object_link'><a href="EZMQ/Server.html" title="EZMQ::Server (class)">Server</a></span>, <span class='object_link'><a href="EZMQ/Socket.html" title="EZMQ::Socket (class)">Socket</a></span>, <span class='object_link'><a href="EZMQ/Subscriber.html" title="EZMQ::Subscriber (class)">Subscriber</a></span>
104
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="EZMQ/Client.html" title="EZMQ::Client (class)">Client</a></span>, <span class='object_link'><a href="EZMQ/Publisher.html" title="EZMQ::Publisher (class)">Publisher</a></span>, <span class='object_link'><a href="EZMQ/Puller.html" title="EZMQ::Puller (class)">Puller</a></span>, <span class='object_link'><a href="EZMQ/Pusher.html" title="EZMQ::Pusher (class)">Pusher</a></span>, <span class='object_link'><a href="EZMQ/Server.html" title="EZMQ::Server (class)">Server</a></span>, <span class='object_link'><a href="EZMQ/Socket.html" title="EZMQ::Socket (class)">Socket</a></span>, <span class='object_link'><a href="EZMQ/Subscriber.html" title="EZMQ::Subscriber (class)">Subscriber</a></span>
105
105
 
106
106
 
107
107
  </p>
@@ -117,7 +117,7 @@
117
117
  </div>
118
118
 
119
119
  <div id="footer">
120
- Generated on Fri Jan 9 13:06:26 2015 by
120
+ Generated on Sun Jan 11 14:20:10 2015 by
121
121
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
122
122
  0.8.7.6 (ruby-2.0.0).
123
123
  </div>
@@ -195,7 +195,7 @@
195
195
 
196
196
 
197
197
  <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">Socket</a></span></h3>
198
- <p class="inherited"><span class='object_link'><a href="Socket.html#bind-instance_method" title="EZMQ::Socket#bind (method)">#bind</a></span>, <span class='object_link'><a href="Socket.html#connect-instance_method" title="EZMQ::Socket#connect (method)">#connect</a></span>, <span class='object_link'><a href="Socket.html#receive-instance_method" title="EZMQ::Socket#receive (method)">#receive</a></span>, <span class='object_link'><a href="Socket.html#send-instance_method" title="EZMQ::Socket#send (method)">#send</a></span></p>
198
+ <p class="inherited"><span class='object_link'><a href="Socket.html#bind-instance_method" title="EZMQ::Socket#bind (method)">#bind</a></span>, <span class='object_link'><a href="Socket.html#connect-instance_method" title="EZMQ::Socket#connect (method)">#connect</a></span>, <span class='object_link'><a href="Socket.html#listen-instance_method" title="EZMQ::Socket#listen (method)">#listen</a></span>, <span class='object_link'><a href="Socket.html#receive-instance_method" title="EZMQ::Socket#receive (method)">#receive</a></span>, <span class='object_link'><a href="Socket.html#send-instance_method" title="EZMQ::Socket#send (method)">#send</a></span></p>
199
199
  <div id="constructor_details" class="method_details_list">
200
200
  <h2>Constructor Details</h2>
201
201
 
@@ -252,12 +252,12 @@
252
252
  <pre class="lines">
253
253
 
254
254
 
255
- 119
256
- 120
257
- 121</pre>
255
+ 133
256
+ 134
257
+ 135</pre>
258
258
  </td>
259
259
  <td>
260
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 119</span>
260
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 133</span>
261
261
 
262
262
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
263
263
  <span class='kw'>super</span> <span class='symbol'>:connect</span><span class='comma'>,</span> <span class='const'>ZMQ</span><span class='op'>::</span><span class='const'>REQ</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span>
@@ -375,17 +375,17 @@
375
375
  <pre class="lines">
376
376
 
377
377
 
378
- 132
379
- 133
380
- 134
381
- 135
382
- 136
383
- 137
384
- 138
385
- 139</pre>
378
+ 146
379
+ 147
380
+ 148
381
+ 149
382
+ 150
383
+ 151
384
+ 152
385
+ 153</pre>
386
386
  </td>
387
387
  <td>
388
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 132</span>
388
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 146</span>
389
389
 
390
390
  <span class='kw'>def</span> <span class='id identifier rubyid_request'>request</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
391
391
  <span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span>
@@ -405,7 +405,7 @@
405
405
  </div>
406
406
 
407
407
  <div id="footer">
408
- Generated on Fri Jan 9 13:06:26 2015 by
408
+ Generated on Sun Jan 11 14:20:10 2015 by
409
409
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
410
410
  0.8.7.6 (ruby-2.0.0).
411
411
  </div>
@@ -195,7 +195,7 @@
195
195
 
196
196
 
197
197
  <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">Socket</a></span></h3>
198
- <p class="inherited"><span class='object_link'><a href="Socket.html#bind-instance_method" title="EZMQ::Socket#bind (method)">#bind</a></span>, <span class='object_link'><a href="Socket.html#connect-instance_method" title="EZMQ::Socket#connect (method)">#connect</a></span>, <span class='object_link'><a href="Socket.html#receive-instance_method" title="EZMQ::Socket#receive (method)">#receive</a></span></p>
198
+ <p class="inherited"><span class='object_link'><a href="Socket.html#bind-instance_method" title="EZMQ::Socket#bind (method)">#bind</a></span>, <span class='object_link'><a href="Socket.html#connect-instance_method" title="EZMQ::Socket#connect (method)">#connect</a></span>, <span class='object_link'><a href="Socket.html#listen-instance_method" title="EZMQ::Socket#listen (method)">#listen</a></span>, <span class='object_link'><a href="Socket.html#receive-instance_method" title="EZMQ::Socket#receive (method)">#receive</a></span></p>
199
199
  <div id="constructor_details" class="method_details_list">
200
200
  <h2>Constructor Details</h2>
201
201
 
@@ -252,12 +252,12 @@
252
252
  <pre class="lines">
253
253
 
254
254
 
255
- 186
256
- 187
257
- 188</pre>
255
+ 200
256
+ 201
257
+ 202</pre>
258
258
  </td>
259
259
  <td>
260
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 186</span>
260
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 200</span>
261
261
 
262
262
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
263
263
  <span class='kw'>super</span> <span class='symbol'>:bind</span><span class='comma'>,</span> <span class='const'>ZMQ</span><span class='op'>::</span><span class='const'>PUB</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span>
@@ -398,12 +398,12 @@
398
398
  <pre class="lines">
399
399
 
400
400
 
401
- 199
402
- 200
403
- 201</pre>
401
+ 213
402
+ 214
403
+ 215</pre>
404
404
  </td>
405
405
  <td>
406
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 199</span>
406
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 213</span>
407
407
 
408
408
  <span class='kw'>def</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>topic:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
409
409
  <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_send_string'>send_string</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span> <span class='id identifier rubyid_topic'>topic</span> <span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span> <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:encode</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='ivar'>@encode</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='id identifier rubyid_message'>message</span> <span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
@@ -418,7 +418,7 @@
418
418
  </div>
419
419
 
420
420
  <div id="footer">
421
- Generated on Fri Jan 9 13:06:26 2015 by
421
+ Generated on Sun Jan 11 14:20:10 2015 by
422
422
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
423
423
  0.8.7.6 (ruby-2.0.0).
424
424
  </div>
@@ -0,0 +1,276 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: EZMQ::Puller
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!EZMQ/Puller.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (P)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../EZMQ.html" title="EZMQ (module)">EZMQ</a></span></span>
36
+ &raquo;
37
+ <span class="title">Puller</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: EZMQ::Puller
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName"><span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">Socket</a></span></span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next"><span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">Socket</a></span></li>
82
+
83
+ <li class="next">EZMQ::Puller</li>
84
+
85
+ </ul>
86
+ <a href="#" class="inheritanceTree">show all</a>
87
+
88
+ </dd>
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+ <dt class="r2 last">Defined in:</dt>
99
+ <dd class="r2 last">lib/ezmq.rb</dd>
100
+
101
+ </dl>
102
+ <div class="clear"></div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>Pull socket that receives messages but does not send them.</p>
108
+
109
+
110
+ </div>
111
+ </div>
112
+ <div class="tags">
113
+
114
+
115
+ </div>
116
+
117
+
118
+
119
+
120
+
121
+ <h2>Instance Attribute Summary</h2>
122
+
123
+ <h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">Socket</a></span></h3>
124
+ <p class="inherited"><span class='object_link'><a href="Socket.html#context-instance_method" title="EZMQ::Socket#context (method)">#context</a></span>, <span class='object_link'><a href="Socket.html#decode-instance_method" title="EZMQ::Socket#decode (method)">#decode</a></span>, <span class='object_link'><a href="Socket.html#encode-instance_method" title="EZMQ::Socket#encode (method)">#encode</a></span>, <span class='object_link'><a href="Socket.html#socket-instance_method" title="EZMQ::Socket#socket (method)">#socket</a></span></p>
125
+
126
+
127
+
128
+ <h2>
129
+ Instance Method Summary
130
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
131
+ </h2>
132
+
133
+ <ul class="summary">
134
+
135
+ <li class="public ">
136
+ <span class="summary_signature">
137
+
138
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Puller) <strong>initialize</strong>(mode = :bind, **options) </a>
139
+
140
+
141
+
142
+ </span>
143
+
144
+
145
+ <span class="note title constructor">constructor</span>
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+ <span class="summary_desc"><div class='inline'>
155
+ <p>Creates a new Puller socket.</p>
156
+ </div></span>
157
+
158
+ </li>
159
+
160
+
161
+ </ul>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">Socket</a></span></h3>
174
+ <p class="inherited"><span class='object_link'><a href="Socket.html#bind-instance_method" title="EZMQ::Socket#bind (method)">#bind</a></span>, <span class='object_link'><a href="Socket.html#connect-instance_method" title="EZMQ::Socket#connect (method)">#connect</a></span>, <span class='object_link'><a href="Socket.html#listen-instance_method" title="EZMQ::Socket#listen (method)">#listen</a></span>, <span class='object_link'><a href="Socket.html#receive-instance_method" title="EZMQ::Socket#receive (method)">#receive</a></span>, <span class='object_link'><a href="Socket.html#send-instance_method" title="EZMQ::Socket#send (method)">#send</a></span></p>
175
+ <div id="constructor_details" class="method_details_list">
176
+ <h2>Constructor Details</h2>
177
+
178
+ <div class="method_details first">
179
+ <h3 class="signature first" id="initialize-instance_method">
180
+
181
+ - (<tt><span class='object_link'><a href="" title="EZMQ::Puller (class)">Puller</a></span></tt>) <strong>initialize</strong>(mode = :bind, **options)
182
+
183
+
184
+
185
+
186
+
187
+ </h3><div class="docstring">
188
+ <div class="discussion">
189
+
190
+ <p>Creates a new Puller socket.</p>
191
+
192
+
193
+ </div>
194
+ </div>
195
+ <div class="tags">
196
+ <p class="tag_title">Parameters:</p>
197
+ <ul class="param">
198
+
199
+ <li>
200
+
201
+ <span class='name'>mode</span>
202
+
203
+
204
+ <span class='type'>(<tt>:bind</tt>, <tt>:connect</tt>)</span>
205
+
206
+
207
+ <em class="default">(defaults to: <tt>:bind</tt>)</em>
208
+
209
+
210
+ &mdash;
211
+ <div class='inline'>
212
+ <p>a mode for the socket.</p>
213
+ </div>
214
+
215
+ </li>
216
+
217
+ <li>
218
+
219
+ <span class='name'>options</span>
220
+
221
+
222
+ <span class='type'>(<tt>Hash</tt>)</span>
223
+
224
+
225
+
226
+ &mdash;
227
+ <div class='inline'>
228
+ <p>optional parameters.</p>
229
+ </div>
230
+
231
+ </li>
232
+
233
+ </ul>
234
+
235
+
236
+ <p class="tag_title">See Also:</p>
237
+ <ul class="see">
238
+
239
+ <li><span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">EZMQ::Socket for optional parameters.</a></span></li>
240
+
241
+ </ul>
242
+
243
+ </div><table class="source_code">
244
+ <tr>
245
+ <td>
246
+ <pre class="lines">
247
+
248
+
249
+ 289
250
+ 290
251
+ 291</pre>
252
+ </td>
253
+ <td>
254
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 289</span>
255
+
256
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_mode'>mode</span> <span class='op'>=</span> <span class='symbol'>:bind</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
257
+ <span class='kw'>super</span> <span class='id identifier rubyid_mode'>mode</span><span class='comma'>,</span> <span class='const'>ZMQ</span><span class='op'>::</span><span class='const'>PULL</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span>
258
+ <span class='kw'>end</span></pre>
259
+ </td>
260
+ </tr>
261
+ </table>
262
+ </div>
263
+
264
+ </div>
265
+
266
+
267
+ </div>
268
+
269
+ <div id="footer">
270
+ Generated on Sun Jan 11 14:20:10 2015 by
271
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
272
+ 0.8.7.6 (ruby-2.0.0).
273
+ </div>
274
+
275
+ </body>
276
+ </html>