cztop 1.2.1 → 1.2.3
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 +4 -4
- data/CHANGES.md +9 -0
- data/README.md +18 -10
- data/cztop.gemspec +2 -5
- data/lib/cztop/has_ffi_delegate.rb +11 -9
- data/lib/cztop/send_receive_methods.rb +14 -2
- data/lib/cztop/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d76545700369dac81459715b642249b0b12460a7307e15454800a373feeea0f
|
4
|
+
data.tar.gz: 978a64afa33b8d8ca3f38a1e9f6fc115cee1ba64da8ad6b56eb705392007543f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7bc28d173c43d80379a0e41bc041f8b942aecd3378c3fbe29995c1b9d2d03657ea11c43bbaf4f3781f1ab0f9778e089c4dd76db9ec27419281550d20dd890e1
|
7
|
+
data.tar.gz: 89c5d43a8aab9e10250257592b91f6c8362be08cd5ae66d4b4a5db408f5b58d2c1fd0408e8529c66f0392d169bb6b8e82ca6e6278f88574427e36d00b4e492e2
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
1.2.3 (1/7/2024)
|
2
|
+
-----
|
3
|
+
* no changes, just re-release to update README on https://www.rubydoc.info/gems/cztop
|
4
|
+
|
5
|
+
1.2.2 (1/7/2024)
|
6
|
+
-----
|
7
|
+
* restore compatibility with Ruby 3.0+
|
8
|
+
* fix latency issue
|
9
|
+
|
1
10
|
1.2.1 (1/7/2024)
|
2
11
|
-----
|
3
12
|
* fix changelog URI
|
data/README.md
CHANGED
@@ -18,26 +18,33 @@ See [this example](https://github.com/paddor/cztop/blob/master/examples/async.rb
|
|
18
18
|
```ruby
|
19
19
|
#! /usr/bin/env ruby
|
20
20
|
|
21
|
-
require '
|
21
|
+
require 'bundler/inline'
|
22
|
+
|
23
|
+
gemfile do
|
24
|
+
source 'https://rubygems.org'
|
25
|
+
gem 'cztop', path: '../../'
|
26
|
+
gem 'async'
|
27
|
+
end
|
28
|
+
|
29
|
+
ENDPOINT = 'inproc://req_rep_example'
|
30
|
+
# ENDPOINT = 'ipc:///tmp/req_rep_example0'
|
31
|
+
# ENDPOINT = 'tcp://localhost:5556'
|
22
32
|
|
23
33
|
Async do |task|
|
24
|
-
task.async do |t|
|
25
|
-
socket = CZTop::Socket::REP.new
|
26
|
-
socket.options.rcvtimeo = 50 # ms
|
34
|
+
rep_task = task.async do |t|
|
35
|
+
socket = CZTop::Socket::REP.new ENDPOINT
|
27
36
|
|
28
37
|
loop do
|
29
38
|
msg = socket.receive
|
30
39
|
puts "<<< #{msg.to_a.inspect}"
|
31
40
|
socket << msg.to_a.map(&:upcase)
|
32
|
-
rescue IO::TimeoutError
|
33
|
-
break
|
34
41
|
end
|
35
|
-
|
42
|
+
ensure
|
36
43
|
puts "REP done."
|
37
44
|
end
|
38
45
|
|
39
46
|
task.async do
|
40
|
-
socket = CZTop::Socket::REQ.new
|
47
|
+
socket = CZTop::Socket::REQ.new ENDPOINT
|
41
48
|
|
42
49
|
10.times do |i|
|
43
50
|
socket << "foobar ##{i}"
|
@@ -46,6 +53,7 @@ Async do |task|
|
|
46
53
|
end
|
47
54
|
|
48
55
|
puts "REQ done."
|
56
|
+
rep_task.stop
|
49
57
|
end
|
50
58
|
end
|
51
59
|
```
|
@@ -85,6 +93,8 @@ Executed in 401.51 millis fish external
|
|
85
93
|
|
86
94
|
```
|
87
95
|
|
96
|
+
A slightly more complex version (more sockets) is [here](https://github.com/paddor/cztop/blob/master/examples/massive_async.rb).
|
97
|
+
|
88
98
|
## Overview
|
89
99
|
|
90
100
|
### Features
|
@@ -117,8 +127,6 @@ At least:
|
|
117
127
|
|
118
128
|
* Ruby 3.0, 3.1, 3.2, 3.3
|
119
129
|
|
120
|
-
Using CZTop with Async will require Ruby 3.2 because of the use of `IO::TimeoutError`, which was introduced in Ruby 3.2.
|
121
|
-
|
122
130
|
## Installation
|
123
131
|
|
124
132
|
To use this gem, add this line to your application's Gemfile:
|
data/cztop.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'CZMQ binding based on the generated low-level FFI bindings of CZMQ'
|
13
13
|
spec.homepage = "https://rubygems.org/gems/cztop"
|
14
14
|
spec.license = "ISC"
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 3.
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/paddor/cztop"
|
@@ -32,8 +32,5 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency "rspec-given", "~> 3.8.0"
|
33
33
|
spec.add_development_dependency "pry"
|
34
34
|
spec.add_development_dependency "yard"
|
35
|
-
|
36
|
-
if RUBY_VERSION >= '3.1'
|
37
|
-
spec.add_development_dependency "async", ">= 2.0.1"
|
38
|
-
end
|
35
|
+
spec.add_development_dependency "async"
|
39
36
|
end
|
@@ -52,16 +52,18 @@ module CZTop::HasFFIDelegate
|
|
52
52
|
# SystemCallError subclass, if errno is known)
|
53
53
|
def raise_zmq_err(msg = CZMQ::FFI::Errors.strerror,
|
54
54
|
errno: CZMQ::FFI::Errors.errno)
|
55
|
-
|
56
55
|
case errno
|
57
|
-
when Errno::EINVAL::Errno
|
58
|
-
|
59
|
-
when Errno::
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
56
|
+
when Errno::EINVAL::Errno
|
57
|
+
fail ArgumentError, msg, caller
|
58
|
+
when Errno::EINTR::Errno
|
59
|
+
fail Interrupt, msg, caller
|
60
|
+
when Errno::EHOSTUNREACH::Errno
|
61
|
+
fail SocketError, msg, caller
|
62
|
+
else
|
63
|
+
# If the errno is known, the corresponding Errno::* exception is
|
64
|
+
# automatically constructed. Otherwise, it'll be a plain SystemCallError.
|
65
|
+
# In any case, #errno will return the corresponding errno.
|
66
|
+
fail SystemCallError.new(msg, errno), msg, caller
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
unless defined? IO::TimeoutError
|
4
|
+
# Support Ruby < 3.2
|
5
|
+
class IO::TimeoutError < IOError
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
module CZTop
|
4
10
|
# These are methods that can be used on a {Socket} as well as an {Actor},
|
5
11
|
# but actually just pass through to methods of {Message} (which take
|
@@ -52,6 +58,7 @@ module CZTop
|
|
52
58
|
timeout_at = now + timeout
|
53
59
|
|
54
60
|
while true
|
61
|
+
# p wait_readable: self, timeout: timeout
|
55
62
|
@fd_io.wait_readable(timeout)
|
56
63
|
break if readable? # NOTE: ZMQ FD can't be trusted
|
57
64
|
raise ::IO::TimeoutError if now >= timeout_at
|
@@ -60,8 +67,10 @@ module CZTop
|
|
60
67
|
sleep JIFFY
|
61
68
|
end
|
62
69
|
else
|
63
|
-
|
70
|
+
while true
|
71
|
+
# p wait_readable: self
|
64
72
|
@fd_io.wait_readable
|
73
|
+
break if readable? # NOTE: ZMQ FD can't be trusted
|
65
74
|
|
66
75
|
# HACK for edge case: avoid hogging CPU if FD for socket type doesn't block and just insists
|
67
76
|
sleep JIFFY
|
@@ -85,6 +94,7 @@ module CZTop
|
|
85
94
|
timeout_at = now + timeout
|
86
95
|
|
87
96
|
while true
|
97
|
+
# p wait_writable: self, timeout: timeout
|
88
98
|
@fd_io.wait_writable(timeout)
|
89
99
|
break if writable? # NOTE: ZMQ FD can't be trusted
|
90
100
|
raise ::IO::TimeoutError if now >= timeout_at
|
@@ -93,8 +103,10 @@ module CZTop
|
|
93
103
|
sleep JIFFY
|
94
104
|
end
|
95
105
|
else
|
96
|
-
|
106
|
+
while true
|
107
|
+
# p wait_writable: self
|
97
108
|
@fd_io.wait_writable
|
109
|
+
break if writable? # NOTE: ZMQ FD can't be trusted
|
98
110
|
|
99
111
|
# HACK for edge case: avoid hogging CPU if FD for socket type doesn't block and just insists
|
100
112
|
sleep JIFFY
|
data/lib/cztop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cztop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrik Wenger
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: '0'
|
139
139
|
description: CZMQ binding based on the generated low-level FFI bindings of CZMQ
|
140
140
|
email:
|
141
141
|
- paddor@gmail.com
|
@@ -201,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
201
|
requirements:
|
202
202
|
- - ">="
|
203
203
|
- !ruby/object:Gem::Version
|
204
|
-
version: 3.
|
204
|
+
version: 3.0.0
|
205
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|
207
207
|
- - ">="
|