ffi-rzmq 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bnsignore +22 -0
- data/History.txt +36 -0
- data/README.rdoc +18 -22
- data/Rakefile +22 -5
- data/examples/local_lat_poll.rb +54 -0
- data/ffi-rzmq.gemspec +9 -9
- data/lib/ffi-rzmq/context.rb +1 -1
- data/lib/ffi-rzmq/poll.rb +7 -1
- data/lib/ffi-rzmq/socket.rb +75 -21
- data/lib/ffi-rzmq/wrapper.rb +8 -6
- data/lib/ffi-rzmq/zmq.rb +27 -1
- data/spec/context_spec.rb +7 -34
- data/spec/pushpull_spec.rb +16 -19
- data/spec/reqrep_spec.rb +5 -0
- data/spec/socket_spec.rb +249 -109
- data/spec/spec_helper.rb +3 -13
- data/version.txt +1 -1
- metadata +10 -10
- data/.gitignore +0 -2
- data/examples/xreqxrep_poll.rb +0 -82
data/spec/spec_helper.rb
CHANGED
@@ -7,19 +7,9 @@ File.join(File.dirname(__FILE__), %w[.. lib ffi-rzmq]))
|
|
7
7
|
|
8
8
|
Thread.abort_on_exception = true
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Spec::Runner.configure do |config|
|
15
|
-
# == Mock Framework
|
16
|
-
#
|
17
|
-
# RSpec uses it's own mocking framework by default. If you prefer to
|
18
|
-
# use mocha, flexmock or RR, uncomment the appropriate line:
|
19
|
-
#
|
20
|
-
# config.mock_with :mocha
|
21
|
-
# config.mock_with :flexmock
|
22
|
-
# config.mock_with :rr
|
10
|
+
SPEC_CTX = ZMQ::Context.new 1
|
11
|
+
def spec_ctx
|
12
|
+
SPEC_CTX
|
23
13
|
end
|
24
14
|
|
25
15
|
module APIHelper
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 7
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.7.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Chuck Remes
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-12-22 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,19 +27,19 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 3
|
30
|
+
- 5
|
30
31
|
- 4
|
31
|
-
|
32
|
-
version: 3.4.7
|
32
|
+
version: 3.5.4
|
33
33
|
type: :development
|
34
34
|
version_requirements: *id001
|
35
35
|
description: |-
|
36
36
|
This gem wraps the ZeroMQ networking library using the ruby FFI (foreign
|
37
37
|
function interface). It's a pure ruby wrapper so this gem can be loaded
|
38
38
|
and run by any ruby runtime that supports FFI. That's all of them:
|
39
|
-
MRI 1.
|
39
|
+
MRI 1.9.x, Rubinius and JRuby.
|
40
40
|
|
41
41
|
The impetus behind this library was to provide support for ZeroMQ in
|
42
|
-
JRuby which has native threads. Unlike MRI,
|
42
|
+
JRuby which has native threads. Unlike MRI, IronRuby and
|
43
43
|
Rubinius which all have a GIL, JRuby allows for threaded access to ruby
|
44
44
|
code from outside extensions. ZeroMQ is heavily threaded, so until the
|
45
45
|
other runtimes remove their GIL, JRuby will likely be the best
|
@@ -55,12 +55,13 @@ extra_rdoc_files:
|
|
55
55
|
- examples/README.rdoc
|
56
56
|
- version.txt
|
57
57
|
files:
|
58
|
-
- .
|
58
|
+
- .bnsignore
|
59
59
|
- History.txt
|
60
60
|
- README.rdoc
|
61
61
|
- Rakefile
|
62
62
|
- examples/README.rdoc
|
63
63
|
- examples/local_lat.rb
|
64
|
+
- examples/local_lat_poll.rb
|
64
65
|
- examples/local_lat_zerocopy.rb
|
65
66
|
- examples/local_throughput.rb
|
66
67
|
- examples/publish_subscribe.rb
|
@@ -69,7 +70,6 @@ files:
|
|
69
70
|
- examples/remote_throughput.rb
|
70
71
|
- examples/reqrep_poll.rb
|
71
72
|
- examples/request_response.rb
|
72
|
-
- examples/xreqxrep_poll.rb
|
73
73
|
- ffi-rzmq.gemspec
|
74
74
|
- lib/ffi-rzmq.rb
|
75
75
|
- lib/ffi-rzmq/context.rb
|
@@ -119,6 +119,6 @@ rubyforge_project: ffi-rzmq
|
|
119
119
|
rubygems_version: 1.3.7
|
120
120
|
signing_key:
|
121
121
|
specification_version: 3
|
122
|
-
summary: This gem wraps the ZeroMQ networking library using the ruby FFI (foreign function interface)
|
122
|
+
summary: This gem wraps the ZeroMQ networking library using the ruby FFI (foreign function interface).
|
123
123
|
test_files: []
|
124
124
|
|
data/.gitignore
DELETED
data/examples/xreqxrep_poll.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'ffi-rzmq'
|
3
|
-
|
4
|
-
|
5
|
-
link = "tcp://127.0.0.1:5555"
|
6
|
-
|
7
|
-
ctx = ZMQ::Context.new 1
|
8
|
-
s1 = ctx.socket ZMQ::XREQ
|
9
|
-
s1.identity = 'socket1.xreq'
|
10
|
-
s2 = ctx.socket ZMQ::XREP
|
11
|
-
s2.identity = 'socket2.xrep'
|
12
|
-
s3 = ctx.socket ZMQ::XREP
|
13
|
-
s3.identity = 'socket3.xrep'
|
14
|
-
|
15
|
-
s1.bind link
|
16
|
-
s2.connect link
|
17
|
-
#s3.connect link
|
18
|
-
|
19
|
-
poller = ZMQ::Poller.new
|
20
|
-
#poller.register_readable s3
|
21
|
-
poller.register_readable s2
|
22
|
-
poller.register_writable s1
|
23
|
-
|
24
|
-
start_time = Time.now
|
25
|
-
@unsent = true
|
26
|
-
|
27
|
-
until @done do
|
28
|
-
begin
|
29
|
-
poller.poll_nonblock
|
30
|
-
rescue ZMQ::PollError => e
|
31
|
-
puts "efault? [#{e.efault?}]"
|
32
|
-
raise
|
33
|
-
end
|
34
|
-
|
35
|
-
# send the message after 5 seconds
|
36
|
-
if Time.now - start_time > 5 && @unsent
|
37
|
-
puts "sending payload nonblocking"
|
38
|
-
|
39
|
-
5.times do |i|
|
40
|
-
payload = "#{ i.to_s * 40 }"
|
41
|
-
s1.send_string payload, ZMQ::NOBLOCK
|
42
|
-
end
|
43
|
-
@unsent = false
|
44
|
-
end
|
45
|
-
|
46
|
-
# check for messages after 1 second
|
47
|
-
if Time.now - start_time > 1
|
48
|
-
poller.readables.each do |sock|
|
49
|
-
#p poller.readables
|
50
|
-
puts
|
51
|
-
#p poller.writables
|
52
|
-
if sock.identity =~ /xrep/
|
53
|
-
routing_info = sock.recv_string ZMQ::NOBLOCK
|
54
|
-
puts "routing_info received [#{routing_info}] on socket.identity [#{sock.identity}]"
|
55
|
-
else
|
56
|
-
routing_info = nil
|
57
|
-
received_msg = sock.recv_string ZMQ::NOBLOCK
|
58
|
-
|
59
|
-
# skip to the next iteration if received_msg is nil; that means we got an EAGAIN
|
60
|
-
next unless received_msg
|
61
|
-
puts "message received [#{received_msg}] on socket.identity [#{sock.identity}]"
|
62
|
-
end
|
63
|
-
|
64
|
-
while sock.more_parts? do
|
65
|
-
received_msg = sock.recv_string ZMQ::NOBLOCK
|
66
|
-
|
67
|
-
puts "message received [#{received_msg}]"
|
68
|
-
end
|
69
|
-
|
70
|
-
puts "kick back a reply"
|
71
|
-
sock.send_string routing_info, ZMQ::SNDMORE | ZMQ::NOBLOCK if routing_info
|
72
|
-
time = Time.now.strftime "%Y-%m-%dT%H:%M:%S.#{Time.now.usec}"
|
73
|
-
reply = "reply " + sock.identity.upcase + " #{time}"
|
74
|
-
puts "sent reply [#{reply}], #{time}"
|
75
|
-
sock.send_string reply
|
76
|
-
@done = true
|
77
|
-
poller.register_readable s1
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
puts "executed in [#{Time.now - start_time}] seconds"
|