cztop 0.12.2 → 0.13.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: 2708e0dcccf2c643508cce8f13beda57e2c94c6c
4
- data.tar.gz: 283d72a0d068c54b6afa43de7afc2419c63b3dbe
3
+ metadata.gz: 8ad5ff197b11908dc2757c0ee6a838d6eba71a80
4
+ data.tar.gz: 9ea6a9d22790c08ca8127a8ee368ee04eed40c17
5
5
  SHA512:
6
- metadata.gz: f73d2f9ad678244752783832575d767e4adb334aca79740c613f0b39596e39a1f665e5e0ba0b6b1f4b4a49d325ea0fc7d226232f96498acf6e05f269606315a6
7
- data.tar.gz: 0b5c571a8b61b47795659940be7659a5837c04d46b52fb578c0d87d099b656a46ef44356e61d644c86a6a44fabe73193ac7a4d5477043cb215007834d22de062
6
+ metadata.gz: 6024fe538a43ee3da235d86e9eda9ba64bbef99097b509acc14cbc49c4a5d913ea6f467ef1b01669af2b17c272d8fdf7e5a7c2d51743a616d23e272ce1cfecfa
7
+ data.tar.gz: 1319974428aeab272139a6833cfacc9d8fc141f2974c24b978877835b96e7176cb23f9330c36eeb17b1e75850ae1c483db7e1a481e50bb74ae913644a06d20de
data/CHANGES.md CHANGED
@@ -1,3 +1,15 @@
1
+ 0.13.0 (03/04/2018)
2
+ -----
3
+ * use czmq-ffi-gen 0.15.x
4
+ * CZTop::Monitor#listen: removed HANDSHAKE_FAILED and HANDSHAKE_SUCCEED events
5
+ and added HANDSHAKE_SUCCEEDED, HANDSHAKE_FAILED_NO_DETAIL,
6
+ HANDSHAKE:FAILED_PROTOCOL, HANDSHAKE_FAILED_AUTH to reflect changes in CZMQ
7
+ * add CZTop::Monitor#fd and #readable?
8
+ * add CZTop::ZsockOptions#fd (so #fd can be called on Sockets and Actors directly)
9
+ * CZTop::Message#to_a: create less intermediate objects
10
+ * support ZMQ_RECONNECT_IVL option
11
+ * CZTop::Frame#group: return nil if group string is empty
12
+
1
13
  0.12.2 (11/24/2017)
2
14
  -----
3
15
  * no changes, but this release includes an up-to-date version of this file
data/cztop.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "czmq-ffi-gen", "~> 0.13.0"
21
+ spec.add_runtime_dependency "czmq-ffi-gen", "~> 0.15.0"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.10"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
data/lib/cztop/frame.rb CHANGED
@@ -156,13 +156,13 @@ module CZTop
156
156
  end
157
157
 
158
158
  # Gets the group (radio/dish pattern).
159
- # @note This only set when the frame has been read from
159
+ # @note This is only set when the frame has been read from
160
160
  # a {CZTop::Socket::DISH} socket.
161
161
  # @return [String] the group
162
162
  # @return [nil] when no group has been set
163
163
  def group
164
164
  group = ffi_delegate.group
165
- return nil if group.empty?
165
+ return nil if group.nil? || group.empty?
166
166
  group
167
167
  end
168
168
 
@@ -174,7 +174,7 @@ module CZTop
174
174
  # @return [new_group]
175
175
  def group=(new_group)
176
176
  rc = ffi_delegate.set_group(new_group)
177
- raise_zmq_err("unable to set group to %p" % group) if rc == -1
177
+ raise_zmq_err("unable to set group to %p" % new_group) if rc == -1
178
178
  end
179
179
  end
180
180
  end
data/lib/cztop/message.rb CHANGED
@@ -142,7 +142,16 @@ module CZTop
142
142
  # strings. This can be a problem if the message is huge/has huge frames.
143
143
  # @return [Array<String>] all frames
144
144
  def to_a
145
- frames.map(&:to_s)
145
+ ffi_delegate = ffi_delegate()
146
+ frame = ffi_delegate.first
147
+ return [] if frame.null?
148
+
149
+ arr = [ frame.data.read_bytes(frame.size) ]
150
+ while frame = ffi_delegate.next and not frame.null?
151
+ arr << frame.data.read_bytes(frame.size)
152
+ end
153
+
154
+ return arr
146
155
  end
147
156
 
148
157
  # Inspects this {Message}.
data/lib/cztop/monitor.rb CHANGED
@@ -39,6 +39,7 @@ module CZTop
39
39
 
40
40
  # @return [Array<String>] types of valid events
41
41
  EVENTS = %w[
42
+ ALL
42
43
  CONNECTED
43
44
  CONNECT_DELAYED
44
45
  CONNECT_RETRIED
@@ -50,9 +51,10 @@ module CZTop
50
51
  CLOSE_FAILED
51
52
  DISCONNECTED
52
53
  MONITOR_STOPPED
53
- HANDSHAKE_FAILED
54
- HANDSHAKE_SUCCEED
55
- ALL
54
+ HANDSHAKE_SUCCEEDED
55
+ HANDSHAKE_FAILED_NO_DETAIL
56
+ HANDSHAKE_FAILED_PROTOCOL
57
+ HANDSHAKE_FAILED_AUTH
56
58
  ]
57
59
 
58
60
  # Configure monitor to listen for specific events.
@@ -73,6 +75,18 @@ module CZTop
73
75
  @actor.wait
74
76
  end
75
77
 
78
+ # Useful for registration in an event-loop.
79
+ # @return [Integer] the FD
80
+ # @see ZsockOptions#fd
81
+ def fd
82
+ @actor.fd
83
+ end
84
+
85
+ # @return [Boolean] whether there's at least one event available
86
+ def readable?
87
+ @actor.readable?
88
+ end
89
+
76
90
  # Get next event. This blocks until the next event is available.
77
91
  # @example
78
92
  # socket = CZTop::Socket::ROUTER.new("tcp://127.0.0.1:5050")
@@ -93,8 +107,8 @@ module CZTop
93
107
  # end
94
108
  # end
95
109
  #
96
- # @return [String] one of the events from {EVENTS}, something like
97
- # <tt>["ACCEPTED", "73", "tcp://127.0.0.1:55585"]</tt>
110
+ # @return [Message] one of the events from (after {#to_a} it's something like
111
+ # <tt>["ACCEPTED", "73", "tcp://127.0.0.1:55585"]</tt>)
98
112
  def next
99
113
  @actor.receive
100
114
  end
data/lib/cztop/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CZTop
2
- VERSION = "0.12.2"
2
+ VERSION = "0.13.0"
3
3
  end
@@ -29,6 +29,13 @@ module CZTop
29
29
  (options.events & Poller::ZMQ::POLLOUT) > 0
30
30
  end
31
31
 
32
+ # Useful for registration in an event-loop.
33
+ # @return [Integer]
34
+ # @see OptionsAccessor#fd
35
+ def fd
36
+ options.fd
37
+ end
38
+
32
39
  # Used to access the options of a {Socket} or {Actor}.
33
40
  class OptionsAccessor
34
41
  # @return [Socket, Actor] whose options this {OptionsAccessor} instance
@@ -312,6 +319,20 @@ module CZTop
312
319
  # @see CZTop::Poller::ZMQ::POLLIN and CZTop::Poller::ZMQ::POLLOUT
313
320
  def events() Zsock.events(@zocket) end
314
321
 
322
+ # @return [Integer] current value of RECONNECT_IVL
323
+ def reconnect_ivl() Zsock.reconnect_ivl(@zocket) end
324
+ # This defines the number of milliseconds to wait while
325
+ # closing/disconnecting a socket if there are outstanding messages to
326
+ # send.
327
+ #
328
+ # Default is 0, which means to not wait at all. -1 means to wait
329
+ # indefinitely
330
+ #
331
+ # @param new_value [Integer] new value for RECONNECT_IVL
332
+ def reconnect_ivl=(new_value)
333
+ Zsock.set_reconnect_ivl(@zocket, new_value)
334
+ end
335
+
315
336
  # TODO: a reasonable subset of these
316
337
  #// Get socket options
317
338
  #int zsock_gssapi_server (void *self);
@@ -325,7 +346,6 @@ module CZTop
325
346
  #int zsock_recovery_ivl (void *self);
326
347
  #int zsock_sndbuf (void *self);
327
348
  #int zsock_rcvbuf (void *self);
328
- #int zsock_reconnect_ivl (void *self);
329
349
  #int zsock_reconnect_ivl_max (void *self);
330
350
  #int zsock_backlog (void *self);
331
351
  #int zsock_maxmsgsize (void *self);
@@ -366,7 +386,6 @@ module CZTop
366
386
  #void zsock_set_recovery_ivl (void *self, int recovery_ivl);
367
387
  #void zsock_set_sndbuf (void *self, int sndbuf);
368
388
  #void zsock_set_rcvbuf (void *self, int rcvbuf);
369
- #void zsock_set_reconnect_ivl (void *self, int reconnect_ivl);
370
389
  #void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max);
371
390
  #void zsock_set_backlog (void *self, int backlog);
372
391
  #void zsock_set_maxmsgsize (void *self, int maxmsgsize);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cztop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-24 00:00:00.000000000 Z
11
+ date: 2018-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: czmq-ffi-gen
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.13.0
19
+ version: 0.15.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.13.0
26
+ version: 0.15.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement