cztop 0.12.1 → 1.0.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
- SHA1:
3
- metadata.gz: 575a0a5ad125c607c8c85eaf8ac521a5894ef4cc
4
- data.tar.gz: 72f3c5ecfe8e9d8f241d8b6e35ac992d2e194251
2
+ SHA256:
3
+ metadata.gz: '0099b49a3147e57b4e29b8ca7288370f56e06694230c2f390e36308ac1f0cb1e'
4
+ data.tar.gz: d4431ae33cc4c35f9911d755d4377913f502156c26317b04a720c598f1f3eb3b
5
5
  SHA512:
6
- metadata.gz: 810554c984e812f6eb6b7dfc74372022a1fedf08d7c30dc1287a7751f8802e9cd9593591826a7ca85f8c40b76967ba20da3c33bd679843a8de574b3fa9a5c536
7
- data.tar.gz: 78b7fa8237b317994884af6a4f40ac96c9412f28c1f5b23fe0f1b023e3f5785fa86dd1af7f1674e0d95b924eca8d15fae565317370973d54eafcd974fdc79116
6
+ metadata.gz: 48f93f12b32aaed87a7cdbdf3f83ff064e69f1fef3e27e4dfaee21a7d721698bd8e7e1675d6fa1110b7597ae7651d971d4502b631a5505345cbb0dbf8ecc19e8
7
+ data.tar.gz: 90540f6ccab41b27361fc1372feb5198351a725b20a69509285ed459073f438a149a7e5e11043a1936b978610c664a0f7096bbb27c6801054cb85ff6fcd6a0b4
@@ -0,0 +1,26 @@
1
+ name: Specs
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-20.04
8
+ strategy:
9
+ matrix:
10
+ ruby:
11
+ - "2.6"
12
+ - "2.7"
13
+ - "3.0"
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby ${{ matrix.ruby }}
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby }}
20
+ - name: Install CZMQ
21
+ run: sudo apt install libczmq-dev
22
+ - name: Run the default task
23
+ run: |
24
+ gem install bundler -v 2.2.3
25
+ bundle install
26
+ bundle exec rake
@@ -0,0 +1 @@
1
+ 3.0
data/CHANGES.md CHANGED
@@ -1,3 +1,33 @@
1
+ 1.0.0 (01/08/2021)
2
+ -----
3
+ * modernized project
4
+
5
+ 0.13.1 (03/04/2018)
6
+ -----
7
+ * fix specs
8
+
9
+ 0.13.0 (03/04/2018)
10
+ -----
11
+ * use czmq-ffi-gen 0.15.x
12
+ * CZTop::Monitor#listen: removed HANDSHAKE_FAILED and HANDSHAKE_SUCCEED events
13
+ and added HANDSHAKE_SUCCEEDED, HANDSHAKE_FAILED_NO_DETAIL,
14
+ HANDSHAKE:FAILED_PROTOCOL, HANDSHAKE_FAILED_AUTH to reflect changes in CZMQ
15
+ * add CZTop::Monitor#fd and #readable?
16
+ * add CZTop::ZsockOptions#fd (so #fd can be called on Sockets and Actors directly)
17
+ * CZTop::Message#to_a: create less intermediate objects
18
+ * support ZMQ_RECONNECT_IVL option
19
+ * CZTop::Frame#group: return nil if group string is empty
20
+
21
+ 0.12.2 (11/24/2017)
22
+ -----
23
+ * no changes, but this release includes an up-to-date version of this file
24
+
25
+ 0.12.1 (11/23/2017)
26
+ -----
27
+ * actually include the change for CZTop::Poller#wait documented in 0.12.0
28
+ * more robust specs around CZTop::Monitor
29
+ * test recent rubies on CI
30
+
1
31
  0.12.0 (11/23/2017)
2
32
  -----
3
33
  * CZTop::Monitor#listen: accept HANDSHAKE_FAILED and HANDSHAKE_SUCCEED events
data/Gemfile CHANGED
@@ -2,13 +2,4 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  # useful when working on czmq-ffi-gen in parallel
5
- #gem "czmq-ffi-gen", git: "https://github.com/paddor/czmq-ffi-gen.git"
6
- #gem "rspec-core", git: "file:///Users/paddor/src/ruby/rspec-core"
7
-
8
- group :development do
9
- gem 'rubocop', require: false
10
- gem 'coveralls', require: false, platform: :mri
11
-
12
- # >= 3.1 doesn't work on Rubinius, see guard/listen#391
13
- gem 'listen', '~> 3.0.x', require: false
14
- end
5
+ # gem "czmq-ffi-gen", path: "../czmq-ffi-gen"
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ![Specs status](https://github.com/paddor/cztop/workflows/Specs/badge.svg)
2
+
1
3
  # CZTop
2
4
 
3
5
  CZTop is a CZMQ binding for Ruby. It is based on
@@ -6,33 +8,6 @@ FFI binding of [CZMQ](https://github.com/zeromq/czmq) and has a focus on being
6
8
  easy to use for Rubyists (POLS) and providing first class support for security
7
9
  mechanisms (like CURVE).
8
10
 
9
- You might wanna check out
10
- [cztop-patterns](https://github.com/paddor/cztop-patterns). It's still very
11
- new, but will contain some reusable patterns described in the Zguide.
12
-
13
- [![Build Status on Travis CI](https://travis-ci.org/paddor/cztop.svg?branch=master)](https://travis-ci.org/paddor/cztop?branch=master)
14
- [![Code Climate](https://codeclimate.com/repos/56677a7849f50a141c001784/badges/48f3cca3c62df9e4b17b/gpa.svg)](https://codeclimate.com/repos/56677a7849f50a141c001784/feed)
15
- [![Inline docs](http://inch-ci.org/github/paddor/cztop.svg?branch=master&style=shields)](http://inch-ci.org/github/paddor/cztop)
16
- [![Dependency Status](https://gemnasium.com/paddor/cztop.svg)](https://gemnasium.com/paddor/cztop)
17
- [![Coverage Status](https://coveralls.io/repos/paddor/cztop/badge.svg?branch=master&service=github)](https://coveralls.io/github/paddor/cztop?branch=master)
18
- [![ISC License](https://img.shields.io/badge/license-ISC_License-blue.svg)](LICENSE)
19
-
20
- ## Goals
21
-
22
- Here are some some of the goals I have/had in mind for this library:
23
-
24
- - [x] as easy as possible, Ruby-esque API
25
- - [x] first class support for security (CURVE mechanism)
26
- - [x] including handling of certificates
27
- - [x] support MRI, Rubinius, and JRuby
28
- - [x] high-quality API documentation
29
- - [x] 100% test coverage
30
- - [x] provide a portable Z85 implementation
31
- * unlike [fpesce/z85](https://github.com/fpesce/z85), which is a C extension
32
- - [x] use it to replace the [Celluloid::ZMQ](https://github.com/celluloid/celluloid-zmq) part of [Celluloid](https://github.com/celluloid/celluloid)
33
- * [celluloid/celluloid-zmq#56](https://github.com/celluloid/celluloid-zmq/issues/56)
34
- - [ ] implement some of the missing (CZMQ based) Ruby examples in the [ZMQ Guide](http://zguide.zeromq.org/page:all)
35
-
36
11
  ## Overview
37
12
 
38
13
  ### Class Hierarchy
@@ -96,51 +71,28 @@ More information in the [API documentation](http://www.rubydoc.info/github/paddo
96
71
  * use `Socket#CURVE_server!(cert)` on the server
97
72
  * and `Socket#CURVE_client!(client_cert, server_cert)` on the client
98
73
  * socket types as Ruby classes
99
- * no need to manually pass some constant
74
+ * no need to manually pass type constants
100
75
  * but you can: `CZTop::Socket.new_by_type(:REP)`
101
- * e.g. `#subscribe` only exists on CZTop::Socket::SUB
102
- * DRAFT API ready
103
- * CLIENT/SERVER/RADIO/DISH/SCATTER/GATHER and other DRAFT methods are supported if the libraries (ZMQ/CZMQ) have been compiled with DRAFT APIs enabled (`--enable-drafts`)
104
- * there is `#routing_id` and `#routing_id=` on the following classes:
105
- * CZTop::Message
106
- * CZTop::Frame
107
- * there is `#group` and `#group=` on CZTop::Frame
108
- * ZMTP 3.1 heartbeat ready
109
- * `socket.options.heartbeat_ivl = 2000`
110
- * `socket.options.heartbeat_timeout = 8000`
76
+ * e.g. `#subscribe` only exists on `CZTop::Socket::SUB`
111
77
 
112
78
  ## Requirements
113
79
 
114
- You'll need:
115
-
116
- * CZMQ >= 4.0.0
117
- * ZMQ >= 4.2.0
118
80
 
119
- For security mechanisms like CURVE, it's recommended to use Libsodium. However,
120
- ZMQ can be compiled with tweetnacl enabled.
81
+ * CZMQ >= 4.2
82
+ * ZMQ >= 4.3
121
83
 
122
- To install on OSX using homebrew, run:
123
84
 
124
- $ brew install libsodium
125
- $ brew install zmq --HEAD --with-libsodium
126
- $ brew install czmq --HEAD
85
+ On Ubuntu 20.04+:
127
86
 
128
- If you're running Linux, go check [this page](http://zeromq.org/distro:_start)
129
- to get more help. Make sure to install CZMQ, not only ZMQ.
87
+ $ sudo apt install libczmq-dev
130
88
 
131
- **Note:** Currently (as of May 2016), when compiling ZMQ from master, it may
132
- be required to pass `--enable-drafts` to `./configure` to make sure all the
133
- `zmq_poller_*()` functions are available. However, this doesn't seem to be the
134
- case on all systems.
89
+ On macOS using Homebrew, run:
135
90
 
136
- ### Supported Ruby versions
91
+ $ brew install czmq
137
92
 
138
- See [.travis.yml](https://github.com/paddor/cztop/blob/master/.travis.yml) for a list of Ruby versions against which CZTop
139
- is tested.
93
+ ### Supported Rubies
140
94
 
141
- At the time of writing, these include:
142
-
143
- * MRI (2.3, 2.2)
95
+ * MRI (2.6, 2.7, 3.0)
144
96
  * Rubinius (HEAD)
145
97
  * JRuby 9000 (HEAD)
146
98
 
@@ -165,222 +117,21 @@ Or install it yourself as:
165
117
  The API should be fairly straight-forward to anyone who is familiar with CZMQ
166
118
  and Ruby. The following API documentation is currently available:
167
119
 
168
- * [YARD API documentation](http://www.rubydoc.info/github/paddor/cztop) (HEAD)
169
120
  * [YARD API documentation](http://www.rubydoc.info/gems/cztop) (release)
170
121
 
171
122
  Feel free to start a [wiki](https://github.com/paddor/cztop/wiki) page.
172
123
 
173
124
  ## Performance
174
125
 
175
- Performance should be pretty okay since this is based on czmq-ffi-gen, which is
176
- reasonably thin. CZTop is basically only a convenience layer on top, with some
177
- nice error checking. But hey, it's Ruby. Don't expect 5M messages per second
178
- with a latency of 3us.
179
-
180
- The measured latency on my laptop ranges from ~20us to ~60us per message for
181
- 1kb messages, depending on whether transport is inproc, IPC, or TCP/IP.
126
+ CZTop is just a convenience layer on top of the thin czmq-ffi-gen library.
182
127
 
183
- Make sure you check out the
128
+ Make sure to check out the
184
129
  [perf](https://github.com/paddor/cztop/blob/master/perf) directory for latency
185
130
  and throughput measurement scripts.
186
131
 
187
132
  ## Usage
188
133
 
189
- See the [examples](https://github.com/paddor/cztop/blob/master/examples) directory for some examples. Here's a very simple one:
190
-
191
- ### rep.rb:
192
-
193
- ```ruby
194
- #!/usr/bin/env ruby
195
- require 'cztop'
196
-
197
- # create and bind socket
198
- socket = CZTop::Socket::REP.new("ipc:///tmp/req_rep_example")
199
- puts "<<< Socket bound to #{socket.last_endpoint.inspect}"
200
-
201
- # Simply echo every message, with every frame String#upcase'd.
202
- while msg = socket.receive
203
- puts "<<< #{msg.to_a.inspect}"
204
- socket << msg.to_a.map(&:upcase)
205
- end
206
- ```
207
-
208
- ### req.rb:
209
-
210
- ```ruby
211
- #!/usr/bin/env ruby
212
- require 'cztop'
213
-
214
- # connect
215
- socket = CZTop::Socket::REQ.new("ipc:///tmp/req_rep_example")
216
- puts ">>> Socket connected."
217
-
218
- # simple string
219
- socket << "foobar"
220
- msg = socket.receive
221
- puts ">>> #{msg.to_a.inspect}"
222
-
223
- # multi frame message as array
224
- socket << %w[foo bar baz]
225
- msg = socket.receive
226
- puts ">>> #{msg.to_a.inspect}"
227
-
228
- # manually instantiating a Message
229
- msg = CZTop::Message.new("bla")
230
- msg << "another frame" # append a frame
231
- socket << msg
232
- msg = socket.receive
233
- puts ">>> #{msg.to_a.inspect}"
234
-
235
- ##
236
- # This will send 20 additional messages:
237
- #
238
- # $ ./req.rb 20
239
- #
240
- if ARGV.first
241
- ARGV.first.to_i.times do
242
- socket << ["fooooooooo", "baaaaaar"]
243
- puts ">>> " + socket.receive.to_a.inspect
244
- end
245
- end
246
- ```
247
-
248
- ### Running it
249
-
250
- ```
251
- $ ./rep.rb & ./req.rb 3
252
- [3] 35321
253
- >>> Socket connected.
254
- <<< Socket bound to "ipc:///tmp/req_rep_example"
255
- <<< ["foobar"]
256
- >>> ["FOOBAR"]
257
- <<< ["foo", "bar", "baz"]
258
- >>> ["FOO", "BAR", "BAZ"]
259
- <<< ["bla", "another frame"]
260
- >>> ["BLA", "ANOTHER FRAME"]
261
- <<< ["fooooooooo", "baaaaaar"]
262
- >>> ["FOOOOOOOOO", "BAAAAAAR"]
263
- <<< ["fooooooooo", "baaaaaar"]
264
- >>> ["FOOOOOOOOO", "BAAAAAAR"]
265
- <<< ["fooooooooo", "baaaaaar"]
266
- >>> ["FOOOOOOOOO", "BAAAAAAR"]
267
- $
268
- ```
269
-
270
- ## TODO
271
-
272
- * [x] pack generated code into its own gem ([czmq-ffi-gen](https://github.com/paddor/czmq-ffi-gen))
273
- * think of a neat Ruby API, including:
274
- - [x] Actor
275
- - [x] Beacon
276
- - [x] Certificate
277
- - [x] Socket
278
- - [50%] access to all socket options
279
- - [x] Security mechanisms
280
- - [x] Message
281
- - [x] Frame
282
- - [x] enumerable Frames
283
- - [x] Authenticator
284
- - [x] Loop
285
- - [x] Monitor
286
- - [x] Poller
287
- - [x] Proxy
288
- - [x] Config
289
- - [x] Z85
290
- * write the missing XML API files in CZMQ
291
- - [x] zarmour.xml
292
- - [x] zconfig.xml
293
- - [x] zsock_option.xml
294
- - [x] zcert.xml
295
- - [x] zcertstore.xml
296
- * [x] check availability of libsodium within CZTop
297
- * [x] read error strings for exceptions where appropriate (zmq_strerror)
298
- * [x] add support for ZMTP 3.1 heartbeats in CZMQ
299
- * [x] add padded variant of Z85
300
- * add more examples
301
- * [x] [simple REQ/REP](https://github.com/paddor/cztop/tree/master/examples/simple_req_rep)
302
- * [x] [Taxy System](https://github.com/paddor/cztop/tree/master/examples/taxi_system) with CURVE security and heartbeating
303
- * [x] change from ROUTER/DEALER to SERVER/CLIENT
304
- * [x] [Actor](https://github.com/paddor/cztop/tree/master/examples/ruby_actor) with Ruby block
305
- * [ ] PUSH/PULL
306
- * [ ] PUB/SUB
307
- * [ ] add performance benchmarks
308
- * [x] inproc latency
309
- * [x] inproc throughput
310
- * [x] local/remote latency
311
- * [ ] local/remote throughput
312
- * see [perf](https://github.com/paddor/cztop/blob/master/perf) directory
313
- * [x] support older versions of ZMQ
314
- * [x] ZMQ HEAD
315
- * [x] tested on CI
316
- * [x] ZMQ 4.1
317
- * [x] tested on CI
318
- * as of April 2016, this isn't the case anymore
319
- * [x] ZMQ 4.0
320
- * [x] tested on CI
321
- * as of March 2016, this isn't the case anymore
322
- * [ ] ZMQ 3.2
323
- * too big a pain ([d5172ab](https://github.com/paddor/czmq-ffi-gen/commit/d5172ab6db64999c50ba24f71569acf1dd45af51))
324
- * [x] support multiple versions of CZMQ
325
- * [x] CZMQ HEAD
326
- * [x] test on CI
327
- * [x] CZMQ 3.0.2 (current stable)
328
- * no `zcert_meta_unset()` ([zeromq/czmq#1246](https://github.com/zeromq/czmq/issues/1246))
329
- * [x] adapt czmq-ffi-gen so it doesn't raise while `attach_function`
330
- * no `zproc`(especially no `zproc_has_curve()`)
331
- * [x] adapt czmq-ffi-gen so it doesn't raise while `attach_function`, attach `zsys_has_curve()` instead (under same name)
332
- * [x] adapt test suite to skip affected test examples
333
- * [x] test on CI
334
- * as of March, 2016, this isn't the case anymore
335
- * [x] port [Poller](http://www.rubydoc.info/gems/cztop/CZTop/Poller) to `zmq_poll()`
336
- * backwards compatible (`#add_reader`, `#add_writer`, `#wait` behave the same)
337
- * but in addition, it has `#readables` and `#writables` which return arrays of sockets
338
- * could then be used in Celluloid::ZMQ
339
- * [ ] add `Message#to_s`
340
- * return frame as string, if there's only one frame
341
- * raise if there are multiple frames
342
- * only safe to use on messages from SERVER/CLIENT sockets
343
- * single-part messages are the future
344
- * not sure yet
345
- * [x] get rid of Loop
346
- * cannot handle CLIENT/SERVER sockets
347
- * there good timer gems for Ruby
348
- * Poller can be used to embed in an existing event loop (Celluloid), or make your own trivial one
349
- * [x] provide `z85encode` and `z85decode` utilities
350
- * can be used in a pipeline (limited memory usage)
351
- * reusable interface: `Z85::Pipe`
352
-
353
- ## Reasons
354
-
355
- Why another CZMQ Ruby binding? Here is a list of existing projects I found and
356
- the issues with them, from my point of view:
357
-
358
- * [Asmod4n/ruby-ffi-czmq](https://github.com/Asmod4n/ruby-ffi-czmq)
359
- * outdated
360
- * according to its author, it's an "abomination"
361
- * [methodmissing/rbczmq](https://github.com/methodmissing/rbczmq)
362
- * no support for security features (see [methodmissing/rbczmq#28](https://github.com/methodmissing/rbczmq/issues/28))
363
- * no JRuby support (see [methodmissing/rbczmq#48](https://github.com/methodmissing/rbczmq/issues/48))
364
- * doesn't feel like Ruby
365
- * [mtortonesi/ruby-czmq](https://github.com/mtortonesi/ruby-czmq)
366
- * no tests
367
- * no documentation
368
- * outdated
369
- * doesn't feel like Ruby
370
- * [chuckremes/ffi-rzmq](https://github.com/chuckremes/ffi-rzmq)
371
- * support discontinued
372
- * low level ZMQ gem, not CZMQ
373
-
374
- Furthermore, I knew about the generated low-level Ruby FFI binding in the
375
- [zeromq/czmq](https://github.com/zeromq/czmq) repository. I wanted to make use
376
- of it because I love that it's generated (and thus, most likely correct
377
- and up-to-date). Unfortunately, it was in pretty bad shape and missing a few
378
- CZMQ classes.
379
-
380
- So I decided to improve the quality and usability of the binding and add the
381
- missing classes. The result is
382
- [czmq-ffi-gen](https://github.com/paddor/czmq-ffi-gen) which provides a solid
383
- foundation for CZTop.
134
+ See the [examples](https://github.com/paddor/cztop/blob/master/examples) directory for some examples.
384
135
 
385
136
 
386
137
  ## Contributing
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cztop/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/cztop/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "cztop"
@@ -9,28 +8,27 @@ Gem::Specification.new do |spec|
9
8
  spec.authors = ["Patrik Wenger"]
10
9
  spec.email = ["paddor@gmail.com"]
11
10
 
12
- spec.summary = %q{CZMQ Ruby binding, based on the generated low-level FFI bindings of CZMQ}
13
- spec.homepage = "https://github.com/paddor/cztop"
11
+ spec.summary = %q{CZMQ Ruby binding based on the generated low-level FFI bindings of CZMQ}
12
+ spec.homepage = "https://rubygems.org/gems/cztop"
14
13
  spec.license = "ISC"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/paddor/cztop"
18
+ spec.metadata["changelog_uri"] = "https://github.com/paddor/cztop/blob/master/CHANGELOG.md"
15
19
 
16
20
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
21
  spec.bindir = "exe"
18
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
23
  spec.require_paths = ["lib"]
20
24
 
21
- spec.add_runtime_dependency "czmq-ffi-gen", "~> 0.13.0"
25
+ spec.add_runtime_dependency "czmq-ffi-gen", "~> 1.0"
22
26
 
23
- spec.add_development_dependency "bundler", "~> 1.10"
24
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "bundler"
28
+ spec.add_development_dependency "rake"
25
29
  spec.add_development_dependency "rspec"
26
30
  spec.add_development_dependency "minitest"
27
31
  spec.add_development_dependency "rspec-given", "~> 3.8.0"
28
32
  spec.add_development_dependency "pry"
29
33
  spec.add_development_dependency "yard"
30
- spec.add_development_dependency "guard"
31
- spec.add_development_dependency "guard-rspec"
32
- spec.add_development_dependency "guard-yard"
33
- spec.add_development_dependency "guard-shell"
34
- spec.add_development_dependency 'terminal-notifier-guard'
35
- spec.add_development_dependency 'foreman'
36
34
  end
@@ -8,7 +8,7 @@ module CZTop
8
8
  # Warns if CURVE security isn't available.
9
9
  # @return [void]
10
10
  def self.check_curve_availability
11
- return if Zproc.has_curve
11
+ return if Zsys.has_curve
12
12
  warn "CZTop: CURVE isn't available. Consider installing libsodium."
13
13
  end
14
14
 
@@ -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
@@ -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}.
@@ -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
@@ -9,8 +9,9 @@ module CZTop
9
9
 
10
10
  extend ::FFI::Library
11
11
  lib_name = 'libzmq'
12
- lib_paths = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
13
- .map { |path| "#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}" }
12
+ lib_dirs = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
13
+ lib_dirs = [*ENV['LIBZMQ_PATH'].split(':'), *lib_dirs] if ENV['LIBZMQ_PATH']
14
+ lib_paths = lib_dirs.map { |path| "#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}" }
14
15
  ffi_lib lib_paths + [lib_name]
15
16
 
16
17
  # This represents a +zmq_poller_event_t+ as in:
@@ -1,3 +1,3 @@
1
1
  module CZTop
2
- VERSION = "0.12.1"
2
+ VERSION = "1.0.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.1
4
+ version: 1.0.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: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: czmq-ffi-gen
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.13.0
19
+ version: '1.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: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.10'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.10'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -122,90 +122,6 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: guard
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: guard-rspec
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: guard-yard
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: guard-shell
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: terminal-notifier-guard
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: foreman
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
125
  description:
210
126
  email:
211
127
  - paddor@gmail.com
@@ -215,21 +131,19 @@ executables:
215
131
  extensions: []
216
132
  extra_rdoc_files: []
217
133
  files:
134
+ - ".github/workflows/main.yml"
218
135
  - ".gitignore"
219
136
  - ".rspec"
220
- - ".travis.yml"
137
+ - ".ruby-version"
221
138
  - ".yardopts"
222
139
  - AUTHORS
223
140
  - CHANGES.md
224
141
  - Gemfile
225
- - Guardfile
226
142
  - LICENSE
227
- - Procfile
228
143
  - README.md
229
144
  - Rakefile
230
145
  - bin/console
231
146
  - bin/setup
232
- - ci-scripts/install-deps
233
147
  - cztop.gemspec
234
148
  - examples/ruby_actor/actor.rb
235
149
  - examples/simple_req_rep/rep.rb
@@ -283,10 +197,13 @@ files:
283
197
  - perf/inproc_thru.rb
284
198
  - perf/local_lat.rb
285
199
  - perf/remote_lat.rb
286
- homepage: https://github.com/paddor/cztop
200
+ homepage: https://rubygems.org/gems/cztop
287
201
  licenses:
288
202
  - ISC
289
- metadata: {}
203
+ metadata:
204
+ homepage_uri: https://rubygems.org/gems/cztop
205
+ source_code_uri: https://github.com/paddor/cztop
206
+ changelog_uri: https://github.com/paddor/cztop/blob/master/CHANGELOG.md
290
207
  post_install_message:
291
208
  rdoc_options: []
292
209
  require_paths:
@@ -295,16 +212,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
295
212
  requirements:
296
213
  - - ">="
297
214
  - !ruby/object:Gem::Version
298
- version: '0'
215
+ version: 2.5.0
299
216
  required_rubygems_version: !ruby/object:Gem::Requirement
300
217
  requirements:
301
218
  - - ">="
302
219
  - !ruby/object:Gem::Version
303
220
  version: '0'
304
221
  requirements: []
305
- rubyforge_project:
306
- rubygems_version: 2.6.8
222
+ rubygems_version: 3.2.4
307
223
  signing_key:
308
224
  specification_version: 4
309
- summary: CZMQ Ruby binding, based on the generated low-level FFI bindings of CZMQ
225
+ summary: CZMQ Ruby binding based on the generated low-level FFI bindings of CZMQ
310
226
  test_files: []
@@ -1,37 +0,0 @@
1
- language: ruby
2
- dist: trusty
3
- sudo: false
4
- cache:
5
- directories:
6
- - $HOME/.ccache
7
- - $HOME/.bundle
8
- rvm:
9
- - 2.4.2
10
- - 2.3.5
11
- - 2.2.8
12
- - jruby-head
13
- - rubinius-3.86
14
- env:
15
- # NOTE: These are recognized by czmq-ffi-gen's CI scripts.
16
- - CZMQ_VERSION=HEAD ZMQ_VERSION=HEAD
17
- - CZMQ_VERSION=stable ZMQ_VERSION=stable
18
- matrix:
19
- exclude:
20
- - rvm: 2.3.5
21
- env: CZMQ_VERSION=HEAD ZMQ_VERSION=HEAD
22
- - rvm: 2.2.8
23
- env: CZMQ_VERSION=HEAD ZMQ_VERSION=HEAD
24
- - rvm: jruby-head
25
- env: CZMQ_VERSION=HEAD ZMQ_VERSION=HEAD
26
- - rvm: rubinius-3.86
27
- env: CZMQ_VERSION=HEAD ZMQ_VERSION=HEAD
28
- allow_failures:
29
- - rvm: rubinius-3.86
30
- before_install:
31
- - PATH="/usr/lib/ccache:$PATH" # enable ccache
32
- - export LD_LIBRARY_PATH=$HOME/lib # custom libs (for execution)
33
- - export PKG_CONFIG_PATH=$HOME/lib/pkgconfig # custom libs (for linking)
34
- - export BUNDLE_PATH=$HOME/.bundle # bundle caching
35
- - ci-scripts/install-deps
36
- - gem install bundler -v 1.10.6
37
- script: bundle exec rake spec
data/Guardfile DELETED
@@ -1,61 +0,0 @@
1
- require "guard/rspec/dsl"
2
-
3
- # Start using
4
- #
5
- # bundle exec guard -g doc & bundle exec guard -g spec
6
- #
7
- # This way you get parallel execution, so
8
- # * documentation is regenerated immediately
9
- # * specs are run immediately
10
-
11
- README_FILE = %r{^README\.md}
12
-
13
- # set these later using help from guard-rspec
14
- ruby_lib_files = nil
15
- spec_files = nil
16
-
17
- # I don't need no shell that hogs my CPU whenever I hit return.
18
- interactor :off
19
-
20
- group :spec do
21
- guard :rspec, cmd: "bundle exec rspec" do
22
- dsl = Guard::RSpec::Dsl.new(self)
23
-
24
- # RSpec files
25
- rspec = dsl.rspec
26
- watch(rspec.spec_helper) { rspec.spec_dir }
27
- watch(rspec.spec_support) { rspec.spec_dir }
28
- watch(rspec.spec_files)
29
- spec_files = rspec.spec_files
30
-
31
- # Ruby files
32
- ruby = dsl.ruby
33
- watch(ruby.lib_files) { |m| rspec.spec.(m[1]) }
34
- ruby_lib_files = ruby.lib_files
35
- end
36
-
37
-
38
- puts "README pattern: %p" % README_FILE
39
- puts "ruby lib files pattern: %p" % ruby_lib_files
40
- puts "spec files pattern: %p" % spec_files
41
- end
42
-
43
- group :syntax_check do
44
- guard :shell do
45
- # check Ruby syntax
46
- watch(Regexp.union(ruby_lib_files, spec_files)) do |m|
47
- puts "Checking Ruby syntax of %p ..." % m[0]
48
- if not system("ruby -c #{m[0]}")
49
- n "#{m[0]} is incorrect", 'Ruby Syntax', :failed
50
- end
51
- end
52
- end
53
- end
54
-
55
- YARD_OPTS = "--use-cache .yardoc/cache.db"
56
-
57
- group :doc do
58
- guard 'yard' do
59
- watch(Regexp.union(README_FILE, ruby_lib_files))
60
- end
61
- end
data/Procfile DELETED
@@ -1,3 +0,0 @@
1
- doc: bundle exec guard -g doc
2
- spec: bundle exec guard -g spec
3
- syntax_check: bundle exec guard -g syntax_check
@@ -1,8 +0,0 @@
1
- #!/bin/sh -x
2
- set -e
3
- mkdir -p vendor
4
- cd vendor
5
- git clone --depth 1 https://github.com/paddor/czmq-ffi-gen
6
- cd czmq-ffi-gen
7
- ci-scripts/install-libzmq
8
- ci-scripts/install-libczmq