omq-backend-rust 0.3.0 → 0.3.2

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: 4f12671673afe657015b59cf65873132c88c5cbb15cf34962b54318fb944310c
4
- data.tar.gz: 3b7de77e6e01dc461fa0aa969870472442a2f9b3b4657fa5b35ca1fe90bd8940
3
+ metadata.gz: f5dcf736d17ac0b002f05bfc256c305526cfe541a0c790864588bcd1ee5d877d
4
+ data.tar.gz: 434a2087deed72f03a5304332e87ebb4af32929cae91c984af59360dc32ded54
5
5
  SHA512:
6
- metadata.gz: 77dda34fcf69ef4d048d74276b1ae5cd455b23086de0a826f751862014e0d048dd8f27ccc2042f5332ff91a5410f11243f687450ca0093e58ab19377b64ec9dd
7
- data.tar.gz: 2536562047da85d828e732a03c5a551a85b2b0774821f3ada32f890ba48f4453696c0243ef5e66248cbdee763623d1cf0f9b45bb74ac5e9aedba6aab014558ed
6
+ metadata.gz: 8dd8f9cfcd6eed1bf7c27e31e295281c666525278cb259af17169cfa377328ae6aca12095f633e56f27e9bd07df596c554b9e34747fa603131d2bb8b11298d8f
7
+ data.tar.gz: 6234856801ef2bf0a382b844427dcb84af5c506d8333923e01b3268d12d22509c0dfad444adc63ac59493b951e3ca1b6e53dfa7500c5fd827328effdcfd580db
data/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.3.2] - 2026-11-26
6
+
7
+ ### Fixed
8
+
9
+ - Without a native Fiber scheduler (TruffleRuby), monitor events could stop
10
+ arriving: the watcher re-armed the monitor fd only after its last empty
11
+ check, so an event in between never woke it, and promises such as
12
+ `subscriber_joined` never resolved.
13
+
14
+ ## [0.3.1] - 2026-10-15
15
+
16
+ ### Fixed
17
+
18
+ - Resolve RADIO subscriber readiness on `join_received` monitor events.
19
+ - Reject unsupported security mechanisms instead of silently using NULL.
20
+ - Forward CURVE authenticators on MRI, TruffleRuby, and JRuby, preserving the
21
+ Ruby `PeerInfo` and crypto public-key types.
22
+ - Reject JRuby authenticator configuration when the OMQ.java callback classes
23
+ are missing from the JVM classpath.
24
+
25
+ ### Changed
26
+
27
+ - Require `omq-rs >= 0.2.5` for native authentication callbacks and REQ/REP
28
+ fixes: reject unrelated REQ replies and bodyless REP requests, and preserve
29
+ REP reply destinations across prefetched requests and disconnects.
30
+
5
31
  ## [0.3.0] - 2026-08-26
6
32
 
7
33
  ### Added
data/README.md CHANGED
@@ -12,8 +12,11 @@ MRI and TruffleRuby, or through OMQ.java on JRuby.
12
12
 
13
13
  ## Install
14
14
 
15
- The `omq-rs` dependency compiles OMQ.rs during installation on MRI and
16
- TruffleRuby. JRuby uses OMQ.java on Java 25 or newer. The Java gem selects the
15
+ The `omq-rs >= 0.2.5` dependency compiles OMQ.rs during installation on MRI
16
+ and TruffleRuby. This minimum includes the REQ/REP envelope and reply-routing
17
+ fixes in `omq-tokio` 0.28.1 and `omq-proto` 0.32.1.
18
+
19
+ JRuby uses OMQ.java on Java 25 or newer. The Java gem selects the
17
20
  matching OMQ.java artifact on Linux x86_64, macOS aarch64, macOS x86_64, and
18
21
  Windows x86_64.
19
22
 
@@ -48,8 +51,7 @@ ensure
48
51
  end
49
52
  ```
50
53
 
51
- The `:rust` backend is fully interoperable with the default `:ruby` backend.
52
- Mix backends freely within the same process.
54
+ Select a backend per socket to exchange ZMTP messages with Ruby and other peers.
53
55
 
54
56
  ## Supported socket types
55
57
 
@@ -62,6 +64,23 @@ SCATTER/GATHER, CHANNEL.
62
64
  - **NULL** (default)
63
65
  - **CURVE** (CurveZMQ, via [Nuckle](https://github.com/paddor/nuckle))
64
66
 
67
+ CURVE authenticators receive `Protocol::ZMTP::PeerInfo`, including a public key
68
+ from the configured crypto backend. As with the Ruby engine, the identity is
69
+ empty during authentication.
70
+
71
+ On JRuby, OMQ.java 0.3.0's JNI callback threads require the platform jar on the
72
+ JVM `CLASSPATH`. For example:
73
+
74
+ ```sh
75
+ CLASSPATH="$HOME/.m2/repository/io/github/paddor/omq-java/0.3.0/omq-java-0.3.0-linux-x86_64.jar" jruby app.rb
76
+ ```
77
+
78
+ Without it, configuring a CURVE authenticator raises `ArgumentError` before
79
+ opening a connection. CURVE without an authenticator does not need this workaround.
80
+
81
+ PLAIN and custom mechanisms raise `ArgumentError` before binding, connecting,
82
+ or sending. They are not supported by this adapter.
83
+
65
84
  ## Compressed transports
66
85
 
67
86
  The Rust backend supports `lz4+tcp://` and `zstd+tcp://`. Compression
@@ -210,15 +210,26 @@ module OMQ
210
210
  @monitor_watching = true
211
211
  FdWatcher.watch_loop(@socket.monitor_fd, owner: self) do |io|
212
212
  io.read_nonblock(256, exception: false)
213
- while (data = @socket.try_monitor_event)
214
- handle_monitor_event(data)
215
- end
216
- @socket.monitor_fd unless @closed
213
+ drain_monitor_events
217
214
  end
218
215
  end
219
216
  end
220
217
 
221
218
 
219
+ # Handles queued monitor events until none is left. #monitor_fd arms
220
+ # the notification fd, and it signals only events that arrive while
221
+ # armed, so arm before each check: an event that lands between an
222
+ # empty check and a later arm would never wake the watcher.
223
+ #
224
+ def drain_monitor_events
225
+ until @closed
226
+ @socket.monitor_fd
227
+ data = @socket.try_monitor_event or break
228
+ handle_monitor_event(data)
229
+ end
230
+ end
231
+
232
+
222
233
  def monitor_loop
223
234
  until @closed
224
235
  data = @socket.monitor.recv
@@ -246,7 +257,7 @@ module OMQ
246
257
  if @had_peer && @connections.empty? && !@all_peers_gone.resolved?
247
258
  @all_peers_gone.resolve(true)
248
259
  end
249
- when :subscribe_received
260
+ when :subscribe_received, :join_received
250
261
  @subscriber_joined.resolve(true) unless @subscriber_joined.resolved?
251
262
  end
252
263
 
@@ -372,14 +383,12 @@ module OMQ
372
383
 
373
384
  def extract_mechanism(h)
374
385
  mech = @options.mechanism
375
- case mech
376
- when Protocol::ZMTP::Mechanism::Null
386
+ if mech.nil? || mech.instance_of?(Protocol::ZMTP::Mechanism::Null)
377
387
  h["mechanism_type"] = "null"
388
+ elsif defined?(Protocol::ZMTP::Mechanism::Curve) && mech.instance_of?(Protocol::ZMTP::Mechanism::Curve)
389
+ extract_curve_mechanism(h, mech)
378
390
  else
379
- klass = mech.class.name
380
- if klass&.include?("Curve")
381
- extract_curve_mechanism(h, mech)
382
- end
391
+ raise ArgumentError, "Rust backend does not support security mechanism #{mech.class}"
383
392
  end
384
393
  end
385
394
 
@@ -397,6 +406,15 @@ module OMQ
397
406
  srv_key = mech.instance_variable_get(:@server_public)
398
407
  h["mechanism_server_key"] = srv_key.to_s.b if srv_key
399
408
  end
409
+
410
+ if (authenticator = mech.instance_variable_get(:@authenticator))
411
+ require "protocol/zmtp/z85"
412
+ crypto = mech.instance_variable_get(:@crypto)
413
+ h["curve_auth"] = lambda do |peer|
414
+ public_key = crypto::PublicKey.new(Protocol::ZMTP::Z85.decode(peer.public_key))
415
+ authenticator.call(Protocol::ZMTP::PeerInfo.new(public_key: public_key, identity: ""))
416
+ end
417
+ end
400
418
  end
401
419
 
402
420
 
@@ -426,8 +426,11 @@ module OMQ
426
426
 
427
427
  def apply_mechanism(builder)
428
428
  mech = @options.mechanism
429
- klass = mech.class.name
430
- return unless klass&.include?("Curve")
429
+ return if mech.nil? || mech.instance_of?(Protocol::ZMTP::Mechanism::Null)
430
+
431
+ unless defined?(Protocol::ZMTP::Mechanism::Curve) && mech.instance_of?(Protocol::ZMTP::Mechanism::Curve)
432
+ raise ArgumentError, "Rust backend does not support security mechanism #{mech.class}"
433
+ end
431
434
 
432
435
  require "protocol/zmtp/z85"
433
436
 
@@ -437,13 +440,32 @@ module OMQ
437
440
  )
438
441
 
439
442
  if mech.instance_variable_get(:@as_server)
440
- builder.curveServer(keypair)
443
+ if (authenticator = mech.instance_variable_get(:@authenticator))
444
+ validate_authenticator_classpath!
445
+ crypto = mech.instance_variable_get(:@crypto)
446
+ callback = lambda do |peer|
447
+ public_key = crypto::PublicKey.new(Protocol::ZMTP::Z85.decode(peer.publicKey.orElse(nil)))
448
+ !!authenticator.call(Protocol::ZMTP::PeerInfo.new(public_key: public_key, identity: ""))
449
+ end
450
+ builder.curveServer(keypair, callback)
451
+ else
452
+ builder.curveServer(keypair)
453
+ end
441
454
  else
442
455
  builder.curveClient(keypair, z85_key(mech.instance_variable_get(:@server_public), "server key"))
443
456
  end
444
457
  end
445
458
 
446
459
 
460
+ # OMQ.java's JNI callback threads resolve PeerInfo through the JVM
461
+ # system class loader, which cannot see JRuby's dynamically loaded jars.
462
+ def validate_authenticator_classpath!
463
+ ::Java::JavaLang::Class.forName("io.omq.PeerInfo", false, ::Java::JavaLang::ClassLoader.getSystemClassLoader)
464
+ rescue ::Java::JavaLang::ClassNotFoundException
465
+ raise ArgumentError, "JRuby CURVE authenticators require the OMQ.java jar on the JVM CLASSPATH"
466
+ end
467
+
468
+
447
469
  def z85_key(key, label)
448
470
  raw = key&.to_s&.b
449
471
  raise ArgumentError, "#{label} must be exactly 32 bytes" unless raw&.bytesize == 32
@@ -3,7 +3,7 @@
3
3
  module OMQ
4
4
  module Backend
5
5
  module Rust
6
- VERSION = "0.3.0"
6
+ VERSION = "0.3.2"
7
7
  end
8
8
  end
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omq-backend-rust
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger
@@ -29,14 +29,20 @@ dependencies:
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: '0.1'
32
+ version: '0.2'
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 0.2.5
33
36
  type: :runtime
34
37
  prerelease: false
35
38
  version_requirements: !ruby/object:Gem::Requirement
36
39
  requirements:
37
40
  - - "~>"
38
41
  - !ruby/object:Gem::Version
39
- version: '0.1'
42
+ version: '0.2'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.2.5
40
46
  description: Drop-in Rust backend for OMQ. Same socket API (REQ/REP, PUB/SUB, PUSH/PULL,
41
47
  DEALER/ROUTER, and all draft types), backed by the first-class omq-rs Ruby binding.
42
48
  Fully interoperable with the default Ruby engine.
@@ -73,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
79
  - !ruby/object:Gem::Version
74
80
  version: '0'
75
81
  requirements: []
76
- rubygems_version: 4.0.16
82
+ rubygems_version: 4.0.20
77
83
  specification_version: 4
78
84
  summary: OMQ.rs backend for OMQ.rb
79
85
  test_files: []