ffi-rzmq 1.0.3 → 2.0.7
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 +7 -0
- data/.travis.yml +5 -6
- data/AUTHORS.txt +7 -1
- data/History.txt +79 -0
- data/README.rdoc +67 -29
- data/Rakefile +15 -0
- data/examples/README.rdoc +1 -3
- data/examples/{v3api/latency_measurement.rb → latency_measurement.rb} +1 -2
- data/examples/{v3api/local_lat.rb → local_lat.rb} +1 -1
- data/examples/{v3api/local_lat_poll.rb → local_lat_poll.rb} +4 -4
- data/examples/{v3api/local_throughput.rb → local_throughput.rb} +1 -1
- data/examples/{v3api/pub.rb → pub.rb} +1 -1
- data/examples/{v2api/publish_subscribe.rb → publish_subscribe.rb} +2 -2
- data/examples/{v2api/remote_lat.rb → remote_lat.rb} +1 -1
- data/examples/{v3api/remote_throughput.rb → remote_throughput.rb} +4 -3
- data/examples/repreq_over_curve.rb +60 -0
- data/examples/{v2api/reqrep_poll.rb → reqrep_poll.rb} +3 -4
- data/examples/{v2api/request_response.rb → request_response.rb} +1 -2
- data/examples/{v3api/sub.rb → sub.rb} +1 -2
- data/examples/{v3api/throughput_measurement.rb → throughput_measurement.rb} +1 -1
- data/examples/{v3api/xreqxrep_poll.rb → xreqxrep_poll.rb} +6 -7
- data/ffi-rzmq.gemspec +4 -4
- data/lib/ffi-rzmq/context.rb +26 -54
- data/lib/ffi-rzmq/device.rb +8 -4
- data/lib/ffi-rzmq/exceptions.rb +3 -0
- data/lib/ffi-rzmq/message.rb +24 -30
- data/lib/ffi-rzmq/poll.rb +5 -16
- data/lib/ffi-rzmq/poll_item.rb +0 -1
- data/lib/ffi-rzmq/socket.rb +132 -282
- data/lib/ffi-rzmq/util.rb +28 -36
- data/lib/ffi-rzmq/version.rb +1 -1
- data/lib/ffi-rzmq.rb +3 -3
- data/lib/io_extensions.rb +1 -1
- data/spec/context_spec.rb +18 -23
- data/spec/device_spec.rb +13 -12
- data/spec/message_spec.rb +13 -13
- data/spec/multipart_spec.rb +11 -11
- data/spec/nonblocking_recv_spec.rb +22 -22
- data/spec/poll_spec.rb +49 -49
- data/spec/pushpull_spec.rb +12 -11
- data/spec/reqrep_spec.rb +11 -11
- data/spec/socket_spec.rb +110 -197
- data/spec/spec_helper.rb +3 -11
- data/spec/support/generate_keys_and_certs.rb +41 -0
- data/spec/support/test.crt +26 -13
- data/spec/support/test.key +49 -13
- data/spec/util_spec.rb +29 -0
- data/travis_build_script.sh +27 -0
- metadata +83 -104
- data/examples/v2api/latency_measurement.rb +0 -139
- data/examples/v2api/local_lat.rb +0 -58
- data/examples/v2api/local_lat_poll.rb +0 -66
- data/examples/v2api/local_throughput.rb +0 -58
- data/examples/v2api/pub.rb +0 -46
- data/examples/v2api/remote_throughput.rb +0 -39
- data/examples/v2api/sub.rb +0 -74
- data/examples/v2api/throughput_measurement.rb +0 -138
- data/examples/v2api/xreqxrep_poll.rb +0 -93
- data/examples/v3api/publish_subscribe.rb +0 -82
- data/examples/v3api/remote_lat.rb +0 -71
- data/examples/v3api/reqrep_poll.rb +0 -62
- data/examples/v3api/request_response.rb +0 -40
- data/lib/ffi-rzmq/constants.rb +0 -187
- data/lib/ffi-rzmq/libc.rb +0 -19
- data/lib/ffi-rzmq/libzmq.rb +0 -283
data/spec/support/test.crt
CHANGED
@@ -1,15 +1,28 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
MIIE1DCCArygAwIBAgIBADANBgkqhkiG9w0BAQUFADAcMRowGAYDVQQDDBFub2Jv
|
3
|
+
ZHkvREM9ZXhhbXBsZTAeFw0xOTAxMDUxNjAxMThaFw0yOTAxMDIxNjAxMThaMBwx
|
4
|
+
GjAYBgNVBAMMEW5vYm9keS9EQz1leGFtcGxlMI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7TtlFQOCq6
|
49
|
+
8x05z8O/HGQd069dbt8R8TJYg66ocDW7KmtFZnCr6Wp/I0uqFzG3ySbAbR7FpXQm
|
50
|
+
u2wiNaNCr9HpKYIWX/PkHOadFak95KlBiFoAVwMDKQp27RmgPnGHdQGCXvUppg==
|
15
51
|
-----END RSA PRIVATE KEY-----
|
data/spec/util_spec.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
2
|
+
|
3
|
+
module ZMQ
|
4
|
+
describe Util do
|
5
|
+
|
6
|
+
if LibZMQ.version4?
|
7
|
+
describe "curve_keypair" do
|
8
|
+
|
9
|
+
it "returns a set of public and private keys (libsodium linked)" do
|
10
|
+
expect(ZMQ::Util).to receive(:curve_keypair).and_return([0, 1])
|
11
|
+
public_key, private_key = ZMQ::Util.curve_keypair
|
12
|
+
|
13
|
+
expect(public_key).not_to eq private_key
|
14
|
+
expect(public_key).not_to be_nil
|
15
|
+
expect(private_key).not_to be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "raises if zmq does not support CURVE (libsodium not linked)" do
|
19
|
+
expect do
|
20
|
+
allow(LibZMQ).to receive(:zmq_curve_keypair).and_return(-1)
|
21
|
+
ZMQ::Util.curve_keypair
|
22
|
+
end.to raise_exception(ZMQ::NotSupportedError)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#/bin/bash
|
2
|
+
set -ev
|
3
|
+
|
4
|
+
bundle install
|
5
|
+
|
6
|
+
sudo apt-get -qq update
|
7
|
+
sudo apt-get install libtool pkg-config build-essential autoconf automake wget
|
8
|
+
|
9
|
+
git clone https://github.com/jedisct1/libsodium --branch stable
|
10
|
+
cd libsodium
|
11
|
+
./autogen.sh
|
12
|
+
./configure && make check
|
13
|
+
sudo make install
|
14
|
+
cd ..
|
15
|
+
|
16
|
+
VERSION="4.2.2"
|
17
|
+
BASE="zeromq-${VERSION}"
|
18
|
+
TARBALL="${BASE}.tar.gz"
|
19
|
+
wget https://github.com/zeromq/libzmq/releases/download/v$VERSION/$TARBALL
|
20
|
+
tar -xvf $TARBALL
|
21
|
+
cd $BASE
|
22
|
+
./autogen.sh
|
23
|
+
./configure && make check
|
24
|
+
sudo make install
|
25
|
+
sudo ldconfig
|
26
|
+
|
27
|
+
bundle exec rake spec
|
metadata
CHANGED
@@ -1,117 +1,96 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-rzmq
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
version: 1.0.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.7
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Chuck Remes
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
11
|
+
date: 2019-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi-rzmq-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
25
17
|
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 0
|
29
|
-
version: "0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.7
|
30
20
|
type: :runtime
|
31
|
-
version_requirements: *id001
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: rspec
|
34
21
|
prerelease: false
|
35
|
-
|
36
|
-
requirements:
|
37
|
-
- -
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.7'
|
43
34
|
type: :development
|
44
|
-
version_requirements: *id002
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name: rake
|
47
35
|
prerelease: false
|
48
|
-
|
49
|
-
requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
50
45
|
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
|
53
|
-
- 0
|
54
|
-
version: "0"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
55
48
|
type: :development
|
56
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
57
55
|
description: |-
|
58
56
|
This gem wraps the ZeroMQ networking library using the ruby FFI (foreign
|
59
57
|
function interface). It's a pure ruby wrapper so this gem can be loaded
|
60
|
-
and run by any ruby runtime that supports FFI. That's all of the major ones -
|
61
|
-
|
62
|
-
email:
|
58
|
+
and run by any ruby runtime that supports FFI. That's all of the major ones - MRI, Rubinius and JRuby.
|
59
|
+
email:
|
63
60
|
- git@chuckremes.com
|
64
61
|
executables: []
|
65
|
-
|
66
62
|
extensions: []
|
67
|
-
|
68
63
|
extra_rdoc_files: []
|
69
|
-
|
70
|
-
|
71
|
-
- .
|
72
|
-
- .
|
73
|
-
- .travis.yml
|
64
|
+
files:
|
65
|
+
- ".bnsignore"
|
66
|
+
- ".gitignore"
|
67
|
+
- ".travis.yml"
|
74
68
|
- AUTHORS.txt
|
75
69
|
- Gemfile
|
76
70
|
- History.txt
|
77
71
|
- README.rdoc
|
78
72
|
- Rakefile
|
79
73
|
- examples/README.rdoc
|
80
|
-
- examples/
|
81
|
-
- examples/
|
82
|
-
- examples/
|
83
|
-
- examples/
|
84
|
-
- examples/
|
85
|
-
- examples/
|
86
|
-
- examples/
|
87
|
-
- examples/
|
88
|
-
- examples/
|
89
|
-
- examples/
|
90
|
-
- examples/
|
91
|
-
- examples/
|
92
|
-
- examples/
|
93
|
-
- examples/
|
94
|
-
- examples/v3api/local_lat.rb
|
95
|
-
- examples/v3api/local_lat_poll.rb
|
96
|
-
- examples/v3api/local_throughput.rb
|
97
|
-
- examples/v3api/pub.rb
|
98
|
-
- examples/v3api/publish_subscribe.rb
|
99
|
-
- examples/v3api/remote_lat.rb
|
100
|
-
- examples/v3api/remote_throughput.rb
|
101
|
-
- examples/v3api/reqrep_poll.rb
|
102
|
-
- examples/v3api/request_response.rb
|
103
|
-
- examples/v3api/sub.rb
|
104
|
-
- examples/v3api/throughput_measurement.rb
|
105
|
-
- examples/v3api/xreqxrep_poll.rb
|
74
|
+
- examples/latency_measurement.rb
|
75
|
+
- examples/local_lat.rb
|
76
|
+
- examples/local_lat_poll.rb
|
77
|
+
- examples/local_throughput.rb
|
78
|
+
- examples/pub.rb
|
79
|
+
- examples/publish_subscribe.rb
|
80
|
+
- examples/remote_lat.rb
|
81
|
+
- examples/remote_throughput.rb
|
82
|
+
- examples/repreq_over_curve.rb
|
83
|
+
- examples/reqrep_poll.rb
|
84
|
+
- examples/request_response.rb
|
85
|
+
- examples/sub.rb
|
86
|
+
- examples/throughput_measurement.rb
|
87
|
+
- examples/xreqxrep_poll.rb
|
106
88
|
- ext/README
|
107
89
|
- ffi-rzmq.gemspec
|
108
90
|
- lib/ffi-rzmq.rb
|
109
|
-
- lib/ffi-rzmq/constants.rb
|
110
91
|
- lib/ffi-rzmq/context.rb
|
111
92
|
- lib/ffi-rzmq/device.rb
|
112
93
|
- lib/ffi-rzmq/exceptions.rb
|
113
|
-
- lib/ffi-rzmq/libc.rb
|
114
|
-
- lib/ffi-rzmq/libzmq.rb
|
115
94
|
- lib/ffi-rzmq/message.rb
|
116
95
|
- lib/ffi-rzmq/poll.rb
|
117
96
|
- lib/ffi-rzmq/poll_item.rb
|
@@ -130,39 +109,37 @@ files:
|
|
130
109
|
- spec/reqrep_spec.rb
|
131
110
|
- spec/socket_spec.rb
|
132
111
|
- spec/spec_helper.rb
|
112
|
+
- spec/support/generate_keys_and_certs.rb
|
133
113
|
- spec/support/test.crt
|
134
114
|
- spec/support/test.key
|
135
|
-
|
115
|
+
- spec/util_spec.rb
|
116
|
+
- travis_build_script.sh
|
136
117
|
homepage: http://github.com/chuckremes/ffi-rzmq
|
137
|
-
licenses:
|
138
|
-
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
139
121
|
post_install_message:
|
140
122
|
rdoc_options: []
|
141
|
-
|
142
|
-
require_paths:
|
123
|
+
require_paths:
|
143
124
|
- lib
|
144
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
-
requirements:
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
146
127
|
- - ">="
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
-
requirements:
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
153
132
|
- - ">="
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
|
156
|
-
- 0
|
157
|
-
version: "0"
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
158
135
|
requirements: []
|
159
|
-
|
160
136
|
rubyforge_project: ffi-rzmq
|
161
|
-
rubygems_version:
|
137
|
+
rubygems_version: 2.7.3
|
162
138
|
signing_key:
|
163
|
-
specification_version:
|
164
|
-
summary: This gem wraps the ZeroMQ (0mq) networking library using Ruby FFI (foreign
|
165
|
-
|
139
|
+
specification_version: 4
|
140
|
+
summary: This gem wraps the ZeroMQ (0mq) networking library using Ruby FFI (foreign
|
141
|
+
function interface).
|
142
|
+
test_files:
|
166
143
|
- spec/context_spec.rb
|
167
144
|
- spec/device_spec.rb
|
168
145
|
- spec/message_spec.rb
|
@@ -173,5 +150,7 @@ test_files:
|
|
173
150
|
- spec/reqrep_spec.rb
|
174
151
|
- spec/socket_spec.rb
|
175
152
|
- spec/spec_helper.rb
|
153
|
+
- spec/support/generate_keys_and_certs.rb
|
176
154
|
- spec/support/test.crt
|
177
155
|
- spec/support/test.key
|
156
|
+
- spec/util_spec.rb
|
@@ -1,139 +0,0 @@
|
|
1
|
-
|
2
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
|
3
|
-
|
4
|
-
|
5
|
-
# Within a single process, we start up two threads. One thread has a REQ (request)
|
6
|
-
# socket and the second thread has a REP (reply) socket. We measure the
|
7
|
-
# *round-trip* latency between these sockets. Only *one* message is in flight at
|
8
|
-
# any given moment.
|
9
|
-
#
|
10
|
-
# This example also illustrates how a single context can be shared amongst several
|
11
|
-
# threads. Sharing a single context also allows a user to specify the "inproc"
|
12
|
-
# transport in addition to "tcp" and "ipc".
|
13
|
-
#
|
14
|
-
# % ruby latency_measurement.rb tcp://127.0.0.1:5555 1024 1_000_000
|
15
|
-
#
|
16
|
-
# % ruby latency_measurement.rb inproc://lm_sock 1024 1_000_000
|
17
|
-
#
|
18
|
-
|
19
|
-
if ARGV.length < 3
|
20
|
-
puts "usage: ruby latency_measurement.rb <connect-to> <message-size> <roundtrip-count>"
|
21
|
-
exit
|
22
|
-
end
|
23
|
-
|
24
|
-
link = ARGV[0]
|
25
|
-
message_size = ARGV[1].to_i
|
26
|
-
roundtrip_count = ARGV[2].to_i
|
27
|
-
|
28
|
-
def assert(rc)
|
29
|
-
raise "Last API call failed at #{caller(1)}" unless rc >= 0
|
30
|
-
end
|
31
|
-
|
32
|
-
begin
|
33
|
-
master_context = ZMQ::Context.new
|
34
|
-
rescue ContextError => e
|
35
|
-
STDERR.puts "Failed to allocate context or socket!"
|
36
|
-
raise
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
class Receiver
|
41
|
-
def initialize context, link, size, count
|
42
|
-
@context = context
|
43
|
-
@link = link
|
44
|
-
@size = size
|
45
|
-
@count = count
|
46
|
-
|
47
|
-
begin
|
48
|
-
@socket = @context.socket(ZMQ::REP)
|
49
|
-
rescue ContextError => e
|
50
|
-
STDERR.puts "Failed to allocate REP socket!"
|
51
|
-
raise
|
52
|
-
end
|
53
|
-
|
54
|
-
assert(@socket.setsockopt(ZMQ::LINGER, 100))
|
55
|
-
|
56
|
-
assert(@socket.setsockopt(ZMQ::HWM, 100))
|
57
|
-
|
58
|
-
assert(@socket.bind(@link))
|
59
|
-
end
|
60
|
-
|
61
|
-
def run
|
62
|
-
@count.times do
|
63
|
-
string = ''
|
64
|
-
assert(@socket.recv_string(string, 0))
|
65
|
-
|
66
|
-
raise "Message size doesn't match, expected [#{@size}] but received [#{string.size}]" if @size != string.size
|
67
|
-
|
68
|
-
assert(@socket.send_string(string, 0))
|
69
|
-
end
|
70
|
-
|
71
|
-
assert(@socket.close)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
class Transmitter
|
76
|
-
def initialize context, link, size, count
|
77
|
-
@context = context
|
78
|
-
@link = link
|
79
|
-
@size = size
|
80
|
-
@count = count
|
81
|
-
|
82
|
-
begin
|
83
|
-
@socket = @context.socket(ZMQ::REQ)
|
84
|
-
rescue ContextError => e
|
85
|
-
STDERR.puts "Failed to allocate REP socket!"
|
86
|
-
raise
|
87
|
-
end
|
88
|
-
|
89
|
-
assert(@socket.setsockopt(ZMQ::LINGER, 100))
|
90
|
-
|
91
|
-
assert(@socket.setsockopt(ZMQ::HWM, 100))
|
92
|
-
|
93
|
-
assert(@socket.connect(@link))
|
94
|
-
end
|
95
|
-
|
96
|
-
def run
|
97
|
-
msg = "#{ '3' * @size }"
|
98
|
-
|
99
|
-
elapsed = elapsed_microseconds do
|
100
|
-
@count.times do
|
101
|
-
assert(@socket.send_string(msg, 0))
|
102
|
-
assert(@socket.recv_string(msg, 0))
|
103
|
-
|
104
|
-
raise "Message size doesn't match, expected [#{@size}] but received [#{msg.size}]" if @size != msg.size
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
latency = elapsed / @count / 2
|
109
|
-
|
110
|
-
puts "message size: %i [B]" % @size
|
111
|
-
puts "roundtrip count: %i" % @count
|
112
|
-
puts "throughput (msgs/s): %i" % (@count / (elapsed / 1_000_000))
|
113
|
-
puts "mean latency: %.3f [us]" % latency
|
114
|
-
assert(@socket.close)
|
115
|
-
end
|
116
|
-
|
117
|
-
def elapsed_microseconds(&blk)
|
118
|
-
start = Time.now
|
119
|
-
yield
|
120
|
-
value = ((Time.now - start) * 1_000_000)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
threads = []
|
125
|
-
threads << Thread.new do
|
126
|
-
receiver = Receiver.new(master_context, link, message_size, roundtrip_count)
|
127
|
-
receiver.run
|
128
|
-
end
|
129
|
-
|
130
|
-
sleep 1
|
131
|
-
|
132
|
-
threads << Thread.new do
|
133
|
-
transmitter = Transmitter.new(master_context, link, message_size, roundtrip_count)
|
134
|
-
transmitter.run
|
135
|
-
end
|
136
|
-
|
137
|
-
threads.each {|t| t.join}
|
138
|
-
|
139
|
-
master_context.terminate
|
data/examples/v2api/local_lat.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2007-2010 iMatix Corporation
|
3
|
-
#
|
4
|
-
# This file is part of 0MQ.
|
5
|
-
#
|
6
|
-
# 0MQ is free software; you can redistribute it and/or modify it under
|
7
|
-
# the terms of the Lesser GNU General Public License as published by
|
8
|
-
# the Free Software Foundation; either version 3 of the License, or
|
9
|
-
# (at your option) any later version.
|
10
|
-
#
|
11
|
-
# 0MQ is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# Lesser GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the Lesser GNU General Public License
|
17
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
|
19
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
|
20
|
-
|
21
|
-
if ARGV.length < 3
|
22
|
-
puts "usage: ruby local_lat.rb <connect-to> <message-size> <roundtrip-count>"
|
23
|
-
exit
|
24
|
-
end
|
25
|
-
|
26
|
-
bind_to = ARGV[0]
|
27
|
-
message_size = ARGV[1].to_i
|
28
|
-
roundtrip_count = ARGV[2].to_i
|
29
|
-
|
30
|
-
def assert(rc)
|
31
|
-
raise "Last API call failed at #{caller(1)}" unless rc >= 0
|
32
|
-
end
|
33
|
-
|
34
|
-
begin
|
35
|
-
ctx = ZMQ::Context.new
|
36
|
-
s = ctx.socket(ZMQ::REP)
|
37
|
-
rescue ContextError => e
|
38
|
-
STDERR.puts "Failed to allocate context or socket!"
|
39
|
-
raise
|
40
|
-
end
|
41
|
-
|
42
|
-
assert(s.setsockopt(ZMQ::LINGER, 100))
|
43
|
-
assert(s.setsockopt(ZMQ::HWM, 100))
|
44
|
-
|
45
|
-
assert(s.bind(bind_to))
|
46
|
-
|
47
|
-
roundtrip_count.times do
|
48
|
-
string = ''
|
49
|
-
assert(s.recv_string(string, 0))
|
50
|
-
|
51
|
-
raise "Message size doesn't match, expected [#{message_size}] but received [#{string.size}]" if message_size != string.size
|
52
|
-
|
53
|
-
assert(s.send_string(string, 0))
|
54
|
-
end
|
55
|
-
|
56
|
-
assert(s.close)
|
57
|
-
|
58
|
-
ctx.terminate
|
@@ -1,66 +0,0 @@
|
|
1
|
-
|
2
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'ffi-rzmq')
|
3
|
-
|
4
|
-
if ARGV.length < 3
|
5
|
-
puts "usage: ruby local_lat.rb <connect-to> <message-size> <roundtrip-count>"
|
6
|
-
exit
|
7
|
-
end
|
8
|
-
|
9
|
-
link = ARGV[0]
|
10
|
-
message_size = ARGV[1].to_i
|
11
|
-
roundtrip_count = ARGV[2].to_i
|
12
|
-
|
13
|
-
def assert(rc)
|
14
|
-
raise "Last API call failed at #{caller(1)}" unless rc >= 0
|
15
|
-
end
|
16
|
-
|
17
|
-
begin
|
18
|
-
ctx = ZMQ::Context.new
|
19
|
-
s1 = ctx.socket(ZMQ::REQ)
|
20
|
-
s2 = ctx.socket(ZMQ::REP)
|
21
|
-
rescue ContextError => e
|
22
|
-
STDERR.puts "Failed to allocate context or socket!"
|
23
|
-
raise
|
24
|
-
end
|
25
|
-
|
26
|
-
assert(s1.setsockopt(ZMQ::LINGER, 100))
|
27
|
-
assert(s2.setsockopt(ZMQ::LINGER, 100))
|
28
|
-
|
29
|
-
assert(s1.connect(link))
|
30
|
-
assert(s2.bind(link))
|
31
|
-
|
32
|
-
poller = ZMQ::Poller.new
|
33
|
-
poller.register_readable(s2)
|
34
|
-
poller.register_readable(s1)
|
35
|
-
|
36
|
-
|
37
|
-
start_time = Time.now
|
38
|
-
|
39
|
-
# kick it off
|
40
|
-
message = ZMQ::Message.new("a" * message_size)
|
41
|
-
assert(s1.sendmsg(message, ZMQ::NonBlocking))
|
42
|
-
|
43
|
-
i = roundtrip_count
|
44
|
-
|
45
|
-
until i.zero?
|
46
|
-
i -= 1
|
47
|
-
|
48
|
-
assert(poller.poll_nonblock)
|
49
|
-
|
50
|
-
poller.readables.each do |socket|
|
51
|
-
received_message = ''
|
52
|
-
assert(socket.recv_string(received_message, ZMQ::NonBlocking))
|
53
|
-
assert(socket.sendmsg(ZMQ::Message.new(received_message), ZMQ::NonBlocking))
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
elapsed_usecs = (Time.now.to_f - start_time.to_f) * 1_000_000
|
58
|
-
latency = elapsed_usecs / roundtrip_count / 2
|
59
|
-
|
60
|
-
puts "mean latency: %.3f [us]" % latency
|
61
|
-
puts "received all messages in %.3f seconds" % (elapsed_usecs / 1_000_000)
|
62
|
-
|
63
|
-
assert(s1.close)
|
64
|
-
assert(s2.close)
|
65
|
-
|
66
|
-
ctx.terminate
|