rbczmq 1.6 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/ext/rbczmq/socket.h CHANGED
@@ -8,6 +8,7 @@
8
8
  #define ZMQ_SOCKET_PENDING 0x01
9
9
  #define ZMQ_SOCKET_BOUND 0x02
10
10
  #define ZMQ_SOCKET_CONNECTED 0x04
11
+ #define ZMQ_SOCKET_DISCONNECTED 0x08
11
12
 
12
13
  typedef struct {
13
14
  zctx_t *ctx;
@@ -15,11 +16,6 @@ typedef struct {
15
16
  int flags;
16
17
  bool verbose;
17
18
  int state;
18
- #ifndef HAVE_RB_THREAD_BLOCKING_REGION
19
- zlist_t *str_buffer;
20
- zlist_t *frame_buffer;
21
- zlist_t *msg_buffer;
22
- #endif
23
19
  VALUE endpoints;
24
20
  VALUE thread;
25
21
  VALUE context;
@@ -126,6 +122,11 @@ struct nogvl_recv_args {
126
122
  zmq_sock_wrapper *socket;
127
123
  };
128
124
 
125
+ struct nogvl_socket_poll_args {
126
+ zmq_sock_wrapper *socket;
127
+ int timeout;
128
+ };
129
+
129
130
  struct nogvl_monitor_recv_args {
130
131
  void *socket;
131
132
  zmq_msg_t msg;
data/lib/zmq.rb CHANGED
@@ -13,20 +13,6 @@ require 'zmq/version' unless defined? ZMQ::VERSION
13
13
  require 'socket'
14
14
 
15
15
  module ZMQ
16
- def self.version3?
17
- version[0] == 3
18
- end
19
-
20
- def self.stable_version?
21
- version[0] == 3 &&
22
- version[1] == 2 &&
23
- version[2] == 2
24
- end
25
-
26
- def self.version2?
27
- !version3?
28
- end
29
-
30
16
  # Sugaring for creating new ZMQ frames
31
17
  #
32
18
  # ZMQ::Frame("frame") => ZMQ::Frame
data/lib/zmq/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module ZMQ
4
- VERSION = "1.6"
4
+ VERSION = "1.6.2"
5
5
  end
data/rbczmq.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = ZMQ::VERSION
8
8
  s.summary = "Ruby extension for CZMQ - High-level C Binding for ØMQ (http://czmq.zeromq.org)"
9
9
  s.description = "Ruby extension for CZMQ - High-level C Binding for ØMQ (http://czmq.zeromq.org)"
10
- s.authors = ["Lourens Naudé", "James Tucker"]
10
+ s.authors = ["Lourens Naudé", "James Tucker", "Matt Connolly"]
11
11
  s.email = ["lourens@methodmissing.com", "jftucker@gmail.com"]
12
12
  s.homepage = "http://github.com/methodmissing/rbczmq"
13
13
  s.date = Time.now.utc.strftime('%Y-%m-%d')
@@ -0,0 +1,92 @@
1
+ # encoding: utf-8
2
+
3
+ require File.join(File.dirname(__FILE__), 'helper')
4
+
5
+ class TestZmqBeacon < ZmqTestCase
6
+ def test_beacon
7
+ beacon = ZMQ::Beacon.new(80000)
8
+ assert_instance_of ZMQ::Beacon, beacon
9
+ assert_nil beacon.destroy
10
+ assert_raises TypeError do
11
+ ZMQ::Beacon.new(:invalid)
12
+ end
13
+ ensure
14
+ beacon.destroy
15
+ end
16
+
17
+ def test_hostname
18
+ beacon = ZMQ::Beacon.new(80000)
19
+ assert_instance_of String, beacon.hostname
20
+ ensure
21
+ beacon.destroy
22
+ end
23
+
24
+ def test_set_interval
25
+ beacon = ZMQ::Beacon.new(80000)
26
+ beacon.interval = 100
27
+ assert_raises TypeError do
28
+ beacon.interval = :invalid
29
+ end
30
+ ensure
31
+ beacon.destroy
32
+ end
33
+
34
+ def test_noecho
35
+ beacon = ZMQ::Beacon.new(80000)
36
+ assert_nil beacon.noecho
37
+ ensure
38
+ beacon.destroy
39
+ end
40
+
41
+ def test_publish
42
+ beacon = ZMQ::Beacon.new(80000)
43
+ assert_raises TypeError do
44
+ beacon.publish :invalid
45
+ end
46
+ assert_nil beacon.publish("test")
47
+ assert_nil beacon.silence
48
+ ensure
49
+ beacon.destroy
50
+ end
51
+
52
+ def test_subscribe
53
+ beacon = ZMQ::Beacon.new(80000)
54
+ assert_raises TypeError do
55
+ beacon.subscribe :invalid
56
+ end
57
+ assert_nil beacon.subscribe("test")
58
+ assert_nil beacon.unsubscribe
59
+ ensure
60
+ beacon.destroy
61
+ end
62
+
63
+ def test_pipe
64
+ beacon = ZMQ::Beacon.new(80000)
65
+ assert_instance_of ZMQ::Socket::Pair, beacon.pipe
66
+ GC.start # check GC cycle with "detached" socket
67
+ ensure
68
+ beacon.destroy
69
+ end
70
+
71
+ def test_announce_lookup
72
+ ctx = ZMQ::Context.new
73
+ address = "tcp://127.0.0.1:90000"
74
+ rep = ctx.bind(:REP, address)
75
+ service_beacon = ZMQ::Beacon.new(80000)
76
+ service_beacon.publish(address)
77
+ sleep(0.5)
78
+ client_beacon = ZMQ::Beacon.new(80000)
79
+ client_beacon.subscribe("tcp")
80
+ client_beacon.pipe.rcvtimeo = 1000
81
+ sender_address = client_beacon.pipe.recv
82
+ client_address = client_beacon.pipe.recv
83
+ assert_equal address, client_address
84
+ req = ctx.connect(:REQ, client_address)
85
+ req.send "ping"
86
+ assert_equal "ping", rep.recv
87
+ ensure
88
+ ctx.destroy
89
+ service_beacon.destroy
90
+ client_beacon.destroy
91
+ end
92
+ end
data/test/test_context.rb CHANGED
@@ -59,21 +59,6 @@ class TestZmqContext < ZmqTestCase
59
59
  ctx.destroy
60
60
  end
61
61
 
62
- def test_hwm
63
- ctx = ZMQ::Context.new
64
- assert_raises TypeError do
65
- ctx.hwm = :invalid
66
- end
67
- ctx.hwm = 10
68
- assert_raises ZMQ::Error do
69
- ctx.hwm = -2
70
- end
71
- # deprecated method
72
- assert_equal 0, ctx.hwm
73
- ensure
74
- ctx.destroy
75
- end
76
-
77
62
  def test_bind_connect
78
63
  ctx = ZMQ::Context.new
79
64
  rep = ctx.bind(:REP, "inproc://test.bind_connect")
data/test/test_loop.rb CHANGED
@@ -175,7 +175,7 @@ class TestZmqLoop < ZmqTestCase
175
175
 
176
176
  def test_register_ruby_sockets
177
177
  server = TCPServer.new("127.0.0.1", 0)
178
- f, port, host, addr = server.addr
178
+ port = server.addr[1]
179
179
  client = TCPSocket.new("127.0.0.1", port)
180
180
  s = server.accept
181
181
  ret = ZMQ::Loop.run do
@@ -2,8 +2,6 @@
2
2
 
3
3
  require File.join(File.dirname(__FILE__), 'helper')
4
4
 
5
- if ZMQ.stable_version?
6
-
7
5
  class TestMonitor
8
6
  attr_reader :listening, :closed
9
7
 
@@ -43,5 +41,3 @@ class TestZmqMonitoring < ZmqTestCase
43
41
  ctx.destroy
44
42
  end
45
43
  end
46
-
47
- end
data/test/test_poller.rb CHANGED
@@ -71,7 +71,7 @@ class TestZmqPoller < ZmqTestCase
71
71
  def test_poll_ruby_sockets
72
72
  poller = ZMQ::Poller.new
73
73
  server = TCPServer.new("127.0.0.1", 0)
74
- f, port, host, addr = server.addr
74
+ port = server.addr[1]
75
75
  client = TCPSocket.new("127.0.0.1", port)
76
76
  s = server.accept
77
77
 
data/test/test_socket.rb CHANGED
@@ -15,14 +15,24 @@ class TestZmqSocket < ZmqTestCase
15
15
  ctx.destroy
16
16
  end
17
17
 
18
- def test_send_timeout
18
+ def test_disconnect
19
19
  ctx = ZMQ::Context.new
20
20
  rep = ctx.socket(:REP)
21
- if ZMQ.version3?
22
- rep.sndhwm = 1
23
- else
24
- rep.hwm = 1
21
+ endpoint = "inproc://test.socket-send-timeout"
22
+ rep.bind(endpoint)
23
+ req = ctx.connect(:REQ, endpoint)
24
+ assert req.disconnect(endpoint)
25
+ assert_raises Errno::EINVAL do
26
+ req.disconnect "invalid"
25
27
  end
28
+ ensure
29
+ ctx.destroy
30
+ end
31
+
32
+ def test_send_timeout
33
+ ctx = ZMQ::Context.new
34
+ rep = ctx.socket(:REP)
35
+ rep.sndhwm = 1
26
36
  rep.bind("inproc://test.socket-send-timeout")
27
37
  req = ctx.connect(:REQ, "inproc://test.socket-send-timeout")
28
38
  # Cannot test much other than normal transfer's not disrupted
@@ -125,7 +135,7 @@ class TestZmqSocket < ZmqTestCase
125
135
  def test_connect
126
136
  ctx = ZMQ::Context.new
127
137
  rep = ctx.socket(:PAIR)
128
- port = rep.bind("inproc://test.socket-connect")
138
+ rep.bind("inproc://test.socket-connect")
129
139
  req = ctx.socket(:PAIR)
130
140
  assert(req.state & ZMQ::Socket::PENDING)
131
141
  req.connect("inproc://test.socket-connect")
@@ -138,7 +148,7 @@ class TestZmqSocket < ZmqTestCase
138
148
  def test_connect_all
139
149
  ctx = ZMQ::Context.new
140
150
  rep = ctx.socket(:PAIR)
141
- port = rep.bind("inproc://test.socket-connect")
151
+ rep.bind("inproc://test.socket-connect")
142
152
  req = ctx.socket(:PAIR)
143
153
  assert(req.state & ZMQ::Socket::PENDING)
144
154
  req.connect_all("inproc://test.socket-connect")
@@ -381,6 +391,19 @@ class TestZmqSocket < ZmqTestCase
381
391
  ctx.destroy
382
392
  end
383
393
 
394
+ def test_poll
395
+ ctx = ZMQ::Context.new
396
+ rep = ctx.socket(:PAIR)
397
+ rep.bind("inproc://test.socket-poll")
398
+ assert !rep.poll(100)
399
+ req = ctx.socket(:PAIR)
400
+ req.connect("inproc://test.socket-poll")
401
+ req.send("test")
402
+ assert rep.poll(100)
403
+ ensure
404
+ ctx.destroy
405
+ end
406
+
384
407
  def test_send_receive_message
385
408
  ctx = ZMQ::Context.new
386
409
  rep = ctx.socket(:PAIR)
@@ -415,57 +438,44 @@ class TestZmqSocket < ZmqTestCase
415
438
  sock = ctx.socket(:ROUTER)
416
439
  sock.verbose = true
417
440
 
418
- if ZMQ.version3?
419
- assert_equal 1000, sock.sndhwm
420
- sock.sndhwm = 10000
421
- assert_equal 10000, sock.sndhwm
422
-
423
- assert_equal 1000, sock.rcvhwm
424
- sock.rcvhwm = 10000
425
- assert_equal 10000, sock.rcvhwm
426
- else
427
- assert_equal 0, sock.hwm
428
- sock.hwm = 1000
429
- assert_equal 1000, sock.hwm
430
-
431
- assert_equal 0, sock.swap
432
- sock.swap = 1000
433
- assert_equal 1000, sock.swap
441
+ assert_equal 1000, sock.sndhwm
442
+ sock.sndhwm = 10000
443
+ assert_equal 10000, sock.sndhwm
434
444
 
435
- assert_equal(-1, sock.recovery_ivl_msec)
436
- sock.recovery_ivl_msec = 20
437
- assert_equal 20, sock.recovery_ivl_msec
438
- end
445
+ assert_equal 1000, sock.rcvhwm
446
+ sock.rcvhwm = 10000
447
+ assert_equal 10000, sock.rcvhwm
439
448
 
440
449
  assert_equal 0, sock.affinity
441
450
  sock.affinity = 1
442
451
  assert_equal 1, sock.affinity
443
452
 
444
- if ZMQ.version3?
445
- assert_equal 100, sock.rate
446
- sock.rate = 50000
447
- assert_equal 50000, sock.rate
448
- else
449
- assert_equal 40000, sock.rate
450
- sock.rate = 50000
451
- assert_equal 50000, sock.rate
452
- end
453
+ assert_equal 100, sock.rate
454
+ sock.rate = 50000
455
+ assert_equal 50000, sock.rate
453
456
 
454
- if ZMQ.version3?
455
- assert_equal 10000, sock.recovery_ivl
456
- sock.recovery_ivl = 20
457
- assert_equal 20, sock.recovery_ivl
458
- else
459
- assert_equal 10, sock.recovery_ivl
460
- sock.recovery_ivl = 20
461
- assert_equal 20, sock.recovery_ivl
462
- end
457
+ assert_equal 10000, sock.recovery_ivl
458
+ sock.recovery_ivl = 20
459
+ assert_equal 20, sock.recovery_ivl
463
460
 
464
- if ZMQ.version2?
465
- assert_equal true, sock.mcast_loop?
466
- sock.mcast_loop = false
467
- assert !sock.mcast_loop?
468
- end
461
+ assert_equal(-1, sock.maxmsgsize)
462
+ sock.maxmsgsize = 20
463
+ assert_equal 20, sock.maxmsgsize
464
+
465
+ assert_equal 1, sock.multicast_hops
466
+ sock.multicast_hops = 20
467
+ assert_equal 20, sock.multicast_hops
468
+
469
+ assert sock.ipv4only?
470
+ sock.ipv4only = false
471
+ assert !sock.ipv4only?
472
+
473
+ sock.delay_attach_on_connect = true
474
+ sock.router_mandatory = true
475
+ sock.router_raw = true
476
+
477
+ xpub = ctx.socket(:XPUB)
478
+ xpub.xpub_verbose = true
469
479
 
470
480
  assert_equal 0, sock.sndbuf
471
481
  sock.sndbuf = 1000
@@ -491,11 +501,11 @@ class TestZmqSocket < ZmqTestCase
491
501
  sock.reconnect_ivl_max = 5
492
502
  assert_equal 5, sock.reconnect_ivl_max
493
503
 
494
- assert_equal -1, sock.rcvtimeo
504
+ assert_equal(-1, sock.rcvtimeo)
495
505
  sock.rcvtimeo = 200
496
506
  assert_equal 200, sock.rcvtimeo
497
507
 
498
- assert_equal -1, sock.sndtimeo
508
+ assert_equal(-1, sock.sndtimeo)
499
509
  sock.sndtimeo = 200
500
510
  assert_equal 200, sock.sndtimeo
501
511
 
metadata CHANGED
@@ -1,21 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbczmq
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.6'
5
- prerelease:
4
+ version: 1.6.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Lourens Naudé
9
8
  - James Tucker
9
+ - Matt Connolly
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-02 00:00:00.000000000 Z
13
+ date: 2013-05-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake-compiler
17
17
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
18
  requirements:
20
19
  - - ~>
21
20
  - !ruby/object:Gem::Version
@@ -23,7 +22,6 @@ dependencies:
23
22
  type: :development
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
25
  requirements:
28
26
  - - ~>
29
27
  - !ruby/object:Gem::Version
@@ -50,7 +48,9 @@ files:
50
48
  - examples/pub_sub.rb
51
49
  - examples/push_pull.rb
52
50
  - examples/req_rep.rb
53
- - ext/czmq-1.4.0.tar.gz
51
+ - ext/czmq-1.4.1.tar.gz
52
+ - ext/rbczmq/beacon.c
53
+ - ext/rbczmq/beacon.h
54
54
  - ext/rbczmq/context.c
55
55
  - ext/rbczmq/context.h
56
56
  - ext/rbczmq/extconf.rb
@@ -128,6 +128,7 @@ files:
128
128
  - test/socket/test_router_socket.rb
129
129
  - test/socket/test_routing.rb
130
130
  - test/socket/test_sub_socket.rb
131
+ - test/test_beacon.rb
131
132
  - test/test_context.rb
132
133
  - test/test_frame.rb
133
134
  - test/test_handler.rb
@@ -142,28 +143,27 @@ files:
142
143
  - test/test_zmq.rb
143
144
  homepage: http://github.com/methodmissing/rbczmq
144
145
  licenses: []
146
+ metadata: {}
145
147
  post_install_message:
146
148
  rdoc_options:
147
149
  - --charset=UTF-8
148
150
  require_paths:
149
151
  - lib
150
152
  required_ruby_version: !ruby/object:Gem::Requirement
151
- none: false
152
153
  requirements:
153
154
  - - ! '>='
154
155
  - !ruby/object:Gem::Version
155
156
  version: '0'
156
157
  required_rubygems_version: !ruby/object:Gem::Requirement
157
- none: false
158
158
  requirements:
159
159
  - - ! '>='
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0'
162
162
  requirements: []
163
163
  rubyforge_project:
164
- rubygems_version: 1.8.24
164
+ rubygems_version: 2.0.3
165
165
  signing_key:
166
- specification_version: 3
166
+ specification_version: 4
167
167
  summary: Ruby extension for CZMQ - High-level C Binding for ØMQ (http://czmq.zeromq.org)
168
168
  test_files:
169
169
  - test/helper.rb
@@ -181,6 +181,7 @@ test_files:
181
181
  - test/socket/test_router_socket.rb
182
182
  - test/socket/test_routing.rb
183
183
  - test/socket/test_sub_socket.rb
184
+ - test/test_beacon.rb
184
185
  - test/test_context.rb
185
186
  - test/test_frame.rb
186
187
  - test/test_handler.rb
@@ -193,4 +194,3 @@ test_files:
193
194
  - test/test_threading.rb
194
195
  - test/test_timer.rb
195
196
  - test/test_zmq.rb
196
- has_rdoc: true