cztop 1.2.2 → 1.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecc7b2951190994c49a1fe184641bc8933b0564dce1bdf00a346b491d67f5810
4
- data.tar.gz: 0d54b8a9bd48d08ca734a5aee4a5317c13aa1a7f2b620fa036dbde8c61b98eb9
3
+ metadata.gz: c158b4eded1b181765d923d869fc6b9f959313f7640bfc3dc8b47b113dcf4d5c
4
+ data.tar.gz: afcca2379f96a9569f1776938873767fcbaaa78ec3a08faf2f860b17b42b6f34
5
5
  SHA512:
6
- metadata.gz: b9f762a7ed4509bef25d4f995fd8ed7bcbe40ea67b829eda881d3973b5656ba9c72eb485b56916edddd112006e804d21f74eb17d016d50764db1ef35f7de0c2a
7
- data.tar.gz: d2a876b9478e43c322e10388ac929d8cc97bcf5a9e19d9b4a67b1e042b2830165ff16d7721334c22ebb42172819b7e9397854123d90908ff8eeaffb0e3055565
6
+ metadata.gz: f4ab7318be7ef914957517c7dc8bb9d4030faa89b86de08479d5ad4fcc63b544745f19d0945d119898a378855f51039788f89df0dd3b9994ec2801100d5f31c3
7
+ data.tar.gz: 3d68e63fb44e994bcac69c76855991c8f71a4c275f76c9afcd728ccc3d3e906d1f25359bf36861136ac8252e6b433bcbec81047217a18052900a7ae3e302f0ce
data/CHANGES.md CHANGED
@@ -1,3 +1,12 @@
1
+ 1.2.4 (1/16/2024)
2
+ -----
3
+ * PolymorphicZsockMethods#wait: fail with NotImplementedError inside non-blocking Fibers
4
+ * fail with ArgumentError when sending message with no parts
5
+
6
+ 1.2.3 (1/7/2024)
7
+ -----
8
+ * no changes, just re-release to update README on https://www.rubydoc.info/gems/cztop
9
+
1
10
  1.2.2 (1/7/2024)
2
11
  -----
3
12
  * restore compatibility with Ruby 3.0+
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 'cztop'
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("inproc://req_rep_example")
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("inproc://req_rep_example")
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
data/cztop.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "ISC"
15
15
  spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
16
16
 
17
- spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["homepage_uri"] = "https://github.com/paddor/cztop"
18
18
  spec.metadata["source_code_uri"] = "https://github.com/paddor/cztop"
19
19
  spec.metadata["changelog_uri"] = "https://github.com/paddor/cztop/blob/master/CHANGES.md"
20
20
 
data/lib/cztop/actor.rb CHANGED
@@ -37,7 +37,7 @@ module CZTop
37
37
  class Actor
38
38
 
39
39
  include HasFFIDelegate
40
- extend CZTop::HasFFIDelegate::ClassMethods
40
+ extend HasFFIDelegate::ClassMethods
41
41
  include ZsockOptions
42
42
  include SendReceiveMethods
43
43
  include PolymorphicZsockMethods
@@ -6,7 +6,7 @@ module CZTop
6
6
  # @return [Integer] number of frames
7
7
  # @see content_size
8
8
  def size
9
- frames.count
9
+ ffi_delegate.size
10
10
  end
11
11
 
12
12
 
data/lib/cztop/message.rb CHANGED
@@ -32,7 +32,7 @@ module CZTop
32
32
  end
33
33
 
34
34
 
35
- # @return [Boolean] if this message is empty or not
35
+ # @return [Boolean] if this message is empty or not (no frames or every frame has length zero)
36
36
  def empty?
37
37
  content_size.zero?
38
38
  end
@@ -56,11 +56,13 @@ module CZTop
56
56
  # corresponding
57
57
  # to the given routing ID)
58
58
  # @raise [ArgumentError] if the message is invalid, e.g. when trying to
59
- # send a multi-part message over a CLIENT/SERVER socket
59
+ # send a message with a no parts, or a multi-part message over a CLIENT/SERVER socket
60
60
  # @raise [SystemCallError] for any other error code set after +zmsg_send+
61
61
  # returns with failure. Please report as bug.
62
62
  #
63
63
  def send_to(destination)
64
+ fail ArgumentError, "message has no frames" if size.zero?
65
+
64
66
  destination.wait_writable
65
67
 
66
68
  rc = Zmsg.send(ffi_delegate, destination)
@@ -14,7 +14,10 @@ module CZTop
14
14
 
15
15
  # Waits for a signal.
16
16
  # @return [Integer] the received signal
17
+ # @note This will block and is therefore not compatible with {Fiber.scheduler} (e.g. Async).
17
18
  def wait
19
+ fail NotImplementedError if !Fiber.blocking?
20
+
18
21
  ::CZMQ::FFI::Zsock.wait(ffi_delegate)
19
22
  end
20
23
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Support Ruby < 3.2
4
3
  unless defined? IO::TimeoutError
4
+ # Support Ruby < 3.2
5
5
  class IO::TimeoutError < IOError
6
6
  end
7
7
  end
data/lib/cztop/socket.rb CHANGED
@@ -5,7 +5,7 @@ module CZTop
5
5
  class Socket
6
6
 
7
7
  include HasFFIDelegate
8
- extend CZTop::HasFFIDelegate::ClassMethods
8
+ extend HasFFIDelegate::ClassMethods
9
9
  include ZsockOptions
10
10
  include SendReceiveMethods
11
11
  include PolymorphicZsockMethods
data/lib/cztop/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CZTop
4
4
 
5
- VERSION = '1.2.2'
5
+ VERSION = '1.2.4'
6
6
 
7
7
  end
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: 1.2.2
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-07 00:00:00.000000000 Z
11
+ date: 2024-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: czmq-ffi-gen
@@ -190,7 +190,7 @@ homepage: https://rubygems.org/gems/cztop
190
190
  licenses:
191
191
  - ISC
192
192
  metadata:
193
- homepage_uri: https://rubygems.org/gems/cztop
193
+ homepage_uri: https://github.com/paddor/cztop
194
194
  source_code_uri: https://github.com/paddor/cztop
195
195
  changelog_uri: https://github.com/paddor/cztop/blob/master/CHANGES.md
196
196
  post_install_message: