rzmq-enhancement 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.semver +1 -1
- data/Gemfile.lock +4 -4
- data/README.org +20 -9
- data/bin/rzmq +1 -0
- data/examples/push-pull-ipc.rb +5 -10
- data/examples/rr-request-ipc.rb +1 -1
- data/examples/rr-response-ipc.rb +1 -1
- data/lib/rzmq-enhancement.rb +29 -17
- data/rzmq-enhancement.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 742111712ff78ad08ebfd9230481089d37a16ded
|
4
|
+
data.tar.gz: 8bafaddb0af74529b58fa12f91856627e185a5d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9733eb664874cf73ff7e240c810094c5d090ec884a05ce7f77d7048629dcc4ed880635a9e86f30e0e41bba05c07824bce789f709fe97cc49d3d1b4fde2876fe5
|
7
|
+
data.tar.gz: fe6e3095f2af0c2c91d249b28fc4485b4f8abfdc2e30c275a2710309517c29a393179ebf9ba20286e7c0f4c56216118153d681febd8e983cceeea47def5401e0
|
data/.semver
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,7 +2,7 @@ GEM
|
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
4
|
addressable (2.4.0)
|
5
|
-
awesome_print (1.
|
5
|
+
awesome_print (1.8.0)
|
6
6
|
binding_of_caller (0.7.2)
|
7
7
|
debug_inspector (>= 0.0.1)
|
8
8
|
builder (3.2.3)
|
@@ -45,7 +45,7 @@ GEM
|
|
45
45
|
rdoc
|
46
46
|
semver2
|
47
47
|
jwt (1.5.6)
|
48
|
-
kamelcase (0.0.
|
48
|
+
kamelcase (0.0.1)
|
49
49
|
semver2 (~> 3)
|
50
50
|
method_source (0.8.2)
|
51
51
|
mime-types (2.99.3)
|
@@ -55,8 +55,8 @@ GEM
|
|
55
55
|
multipart-post (2.0.0)
|
56
56
|
nokogiri (1.8.0)
|
57
57
|
mini_portile2 (~> 2.2.0)
|
58
|
-
oauth2 (1.
|
59
|
-
faraday (>= 0.8, < 0.
|
58
|
+
oauth2 (1.4.0)
|
59
|
+
faraday (>= 0.8, < 0.13)
|
60
60
|
jwt (~> 1.0)
|
61
61
|
multi_json (~> 1.3)
|
62
62
|
multi_xml (~> 0.5)
|
data/README.org
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
- [[#install][Install]]
|
6
6
|
- [[#usage][Usage]]
|
7
7
|
- [[#tips][Tips]]
|
8
|
+
- [[#release-notes][Release Notes]]
|
8
9
|
- [[#contributing-to-rzmq-enhancement][Contributing to rzmq-enhancement]]
|
9
10
|
- [[#copyright][Copyright]]
|
10
11
|
|
@@ -20,30 +21,35 @@
|
|
20
21
|
This is still under development, and currently represents
|
21
22
|
only a minimal interface. For the versions of 0.0.x,
|
22
23
|
there will be "rapid" development and breaking changes.
|
23
|
-
|
24
|
+
|
24
25
|
Only when we reach version 0.1.0 or higher, the interfaces
|
25
26
|
and the API will be stable enough for general use.
|
26
27
|
|
27
28
|
Feel free to play with this for now, but don't put it in production
|
28
|
-
code just yet.
|
29
|
+
code just yet. Or if you do, be very aggressive about locking down
|
30
|
+
the exact version. For example:
|
31
|
+
|
32
|
+
#+begin_src ruby
|
33
|
+
gem 'rzmq_enhancement', '0.0.27'
|
34
|
+
#+end_src
|
29
35
|
|
30
36
|
** Preliminaries
|
31
37
|
|
32
38
|
This is implemented as a DSLish Ruby-friendly interface. The
|
33
39
|
initial implementation shall be as "lean" as possible, basically
|
34
|
-
serving our needs at Sensorberg. Eventually, we'll flesh this
|
40
|
+
serving our needs at Sensorberg. Eventually, we'll flesh this
|
35
41
|
out to fully support most of the ffi-rzmq interface.
|
36
42
|
|
37
43
|
This is also "opinionated". We pass all objects as JSON
|
38
|
-
strings, which will probably suit most needs, and will
|
44
|
+
strings, which will probably suit most needs, and will
|
39
45
|
allow the receiving (and sending) ends to be language-agnostic,
|
40
46
|
as long as they use JSON as well.
|
41
47
|
|
42
48
|
** Install
|
43
|
-
|
49
|
+
|
44
50
|
Make sure the ZeroMQ library is already installed on your system. If you
|
45
51
|
are on a Mac, we recommend 'brew' or 'macports' to get it.
|
46
|
-
|
52
|
+
|
47
53
|
From command-line:
|
48
54
|
#+begin_src bash
|
49
55
|
gem install rzmq-enhancement
|
@@ -53,7 +59,7 @@
|
|
53
59
|
#+begin_src ruby
|
54
60
|
gem 'rzmq-enhancement'
|
55
61
|
#+end_src
|
56
|
-
|
62
|
+
|
57
63
|
** Usage
|
58
64
|
Please see the [[./examples][Examples.]]
|
59
65
|
|
@@ -68,11 +74,16 @@
|
|
68
74
|
machine,
|
69
75
|
|
70
76
|
#+begin_src ruby
|
71
|
-
'ipc://anynameyoulike.ipc'
|
77
|
+
'ipc://anynameyoulike.ipc'
|
72
78
|
#+end_src
|
73
79
|
|
80
|
+
** Release Notes
|
81
|
+
| version | date | details |
|
82
|
+
|---------+------------+--------------------------------------------------------------------------------------|
|
83
|
+
| v0.0.27 | 2017-06-22 | zeromq_push semantics now allows you to properly pass the payload in as a parameter. |
|
84
|
+
|
74
85
|
** Contributing to rzmq-enhancement
|
75
|
-
|
86
|
+
|
76
87
|
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
77
88
|
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
78
89
|
- Fork the project.
|
data/bin/rzmq
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
# to be determined
|
data/examples/push-pull-ipc.rb
CHANGED
@@ -7,21 +7,16 @@ include ZeroMQ
|
|
7
7
|
thr = []
|
8
8
|
|
9
9
|
# push
|
10
|
-
thr << Thread.new {
|
10
|
+
thr << Thread.new {
|
11
11
|
(0..10).each do |i|
|
12
|
-
zeromq_push(:pushpull_example,
|
13
|
-
unless i == 10
|
14
|
-
[i, 'mississippi']
|
15
|
-
else
|
16
|
-
:end_of_stream
|
17
|
-
end
|
18
|
-
end
|
12
|
+
zeromq_push(:pushpull_example, payload: [i, 'mississippi'])
|
19
13
|
end
|
14
|
+
zeromq_push(:pushpull_example, payload: :end_of_stream)
|
20
15
|
}
|
21
16
|
|
22
17
|
# pull
|
23
|
-
thr << Thread.new {
|
24
|
-
zeromq_pull_server(:pushpull_example
|
18
|
+
thr << Thread.new {
|
19
|
+
zeromq_pull_server(:pushpull_example) do |payload|
|
25
20
|
pp payload
|
26
21
|
exit if payload == 'end_of_stream'
|
27
22
|
end
|
data/examples/rr-request-ipc.rb
CHANGED
data/examples/rr-response-ipc.rb
CHANGED
data/lib/rzmq-enhancement.rb
CHANGED
@@ -10,18 +10,24 @@ IPCDIR = '/tmp'
|
|
10
10
|
Thread.abort_on_exception = true
|
11
11
|
|
12
12
|
module ZeroMQ
|
13
|
-
|
13
|
+
# This bit will seem confusing, but we must redo grand_pusher to
|
14
|
+
# to make this more sane.
|
14
15
|
def zeromq_push name,
|
15
16
|
endpoint = "ipc://#{IPCDIR}/#{name}.ipc",
|
16
|
-
ctx: :
|
17
|
+
ctx: :push,
|
18
|
+
payload: nil,
|
17
19
|
&block
|
18
|
-
|
19
|
-
|
20
|
+
if block_given?
|
21
|
+
grand_pusher ZMQ::PUSH, name, endpoint, ctx: ctx, payload: payload, &block
|
22
|
+
else
|
23
|
+
grand_pusher(ZMQ::PUSH, name, endpoint, ctx: ctx) { payload }
|
24
|
+
end
|
25
|
+
end
|
20
26
|
|
21
|
-
# this does an endless loop as a "server"
|
27
|
+
# this does an endless loop as a "server"
|
22
28
|
def zeromq_pull_server name,
|
23
29
|
endpoint = "ipc://#{IPCDIR}/#{name}.ipc",
|
24
|
-
ctx: :
|
30
|
+
ctx: :pull,
|
25
31
|
&block
|
26
32
|
grand_server ZMQ::PULL, name, endpoint, ctx: ctx, bind: true, &block
|
27
33
|
end
|
@@ -32,7 +38,7 @@ module ZeroMQ
|
|
32
38
|
**opts,
|
33
39
|
&block
|
34
40
|
h = grand_pusher ZMQ::REQ, name, endpoint, **opts, &block
|
35
|
-
end
|
41
|
+
end
|
36
42
|
|
37
43
|
def zeromq_response_server name,
|
38
44
|
endpoint = "ipc://#{IPCDIR}/#{name}.ipc",
|
@@ -40,13 +46,16 @@ module ZeroMQ
|
|
40
46
|
&block
|
41
47
|
grand_server ZMQ::REP, name, endpoint, bind: true, respond: true, ctx: ctx, &block
|
42
48
|
end
|
43
|
-
|
44
|
-
|
49
|
+
|
50
|
+
private_class_method
|
45
51
|
def ctx_name name, opts
|
46
52
|
:"#{name}.#{opts[:ctx] || :default}"
|
47
53
|
end
|
48
|
-
|
54
|
+
|
49
55
|
# TODO: We don't handle the non-block req case at all. Do we want to?
|
56
|
+
# TODO: We need to rewrite this, it works as is, but is too tricky
|
57
|
+
# TODO: to get the semantics right.
|
58
|
+
private_class_method
|
50
59
|
def grand_pusher type, name, endpoint, **opts, &block
|
51
60
|
init_sys
|
52
61
|
ctxname = ctx_name(name,opts)
|
@@ -61,7 +70,7 @@ module ZeroMQ
|
|
61
70
|
else
|
62
71
|
@ctxh[ctxname]
|
63
72
|
end
|
64
|
-
|
73
|
+
|
65
74
|
if block_given?
|
66
75
|
unless opts[:payload]
|
67
76
|
# here, we get the payload from the block
|
@@ -80,6 +89,7 @@ module ZeroMQ
|
|
80
89
|
h
|
81
90
|
end
|
82
91
|
|
92
|
+
private_class_method
|
83
93
|
def grand_server type, name, endpoint, **opts, &block
|
84
94
|
init_sys
|
85
95
|
ctxname = ctx_name(name,opts)
|
@@ -95,27 +105,29 @@ module ZeroMQ
|
|
95
105
|
end
|
96
106
|
error_check(rc)
|
97
107
|
|
98
|
-
loop do
|
108
|
+
loop do
|
99
109
|
rc = h.server_sock.recv_string payload = ''
|
100
110
|
error_check(rc)
|
101
|
-
|
111
|
+
|
102
112
|
result = block.(JSON.parse(payload))
|
103
113
|
if opts[:respond]
|
104
|
-
rc = h.server_sock.send_string JSON.generate(result)
|
114
|
+
rc = h.server_sock.send_string JSON.generate(result)
|
105
115
|
end
|
106
116
|
end if block_given?
|
107
117
|
h
|
108
118
|
end
|
109
|
-
|
119
|
+
|
120
|
+
private_class_method
|
110
121
|
def init_sys
|
111
122
|
@ctxh ||= {}
|
112
123
|
end
|
113
|
-
|
124
|
+
|
125
|
+
private_class_method
|
114
126
|
def error_check rc
|
115
127
|
if ZMQ::Util.resultcode_ok?(rc)
|
116
128
|
false
|
117
129
|
else
|
118
|
-
raise "Operation failed, errno [#{ZMQ::Util.errno}] description [#{ZMQ::Util.error_string}]"
|
130
|
+
raise "ZeroMQ Operation failed, errno [#{ZMQ::Util.errno}] description [#{ZMQ::Util.error_string}]"
|
119
131
|
end
|
120
132
|
end
|
121
133
|
end
|
data/rzmq-enhancement.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: rzmq-enhancement 0.0.
|
5
|
+
# stub: rzmq-enhancement 0.0.27 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "rzmq-enhancement".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.27"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Fred Mitchell".freeze, "Sensorberg GmbH".freeze]
|
14
|
-
s.date = "2017-06-
|
14
|
+
s.date = "2017-06-22"
|
15
15
|
s.description = "\n The ffi-rzmq wraps ZeroMQ nicely, but not in a Ruby-friendly manner.\n here, we take that one step further to present a mor Ruby-Friendy\n interface.".freeze
|
16
16
|
s.email = "frederick.mitchell@sensorberg.com".freeze
|
17
17
|
s.executables = ["rzmq".freeze]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rzmq-enhancement
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Mitchell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-06-
|
12
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: semver2
|