omq-backend-libzmq 0.3.2 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 963a9597aa1a5a4cd0b922dd332dcd34cabbf542072f9a985cb03b087df1c2f0
4
- data.tar.gz: b76aa34f22c78f6639407562269f585c542f14cd940d7fa00619e028c646f746
3
+ metadata.gz: 843563bc4103e7c6a306887b213e563a94ba1d67ab2dda5f5d5e59e74466e90d
4
+ data.tar.gz: fcc4f468fc2c69e7c22870f5e69d57b99a3721ab031c4ae8dd4eb4316850ce1a
5
5
  SHA512:
6
- metadata.gz: 21d10c3acef17a021ef16f641b7283d96e693ff1f816a9ffe99a05007ef2b82fe105e8f70920b636d43001b38a4fc09f05355407865b03d0729ded39da6bd5c9
7
- data.tar.gz: 4cadea7bb6b143111b25c6995cdce2479d0d83bcab5ea463e08b356a7de8009d5eaa05548eab8b145185f2219a9fe1b4be4e75de9fc0843b94f870f8f6a53c3f
6
+ metadata.gz: 9a54a205da7d453941a0db82c1fa0eb90ca1b76f1eb28abe3acf267ec39b80eb5297140fe87e6df17424bb588f885d769f82acf4af646d2179026342757d85a5
7
+ data.tar.gz: 25f085f1e132596938c1cd3ee85b23485598b13b98e9bb6f1cf0783aa60c2259c441c828b1bd6191cf998b48e28da51e8bd0e22aeac31859d33992fc86b4864e
data/README.md CHANGED
@@ -22,8 +22,6 @@ socket API, options, and Async integration remain identical. A dedicated
22
22
  I/O thread per socket handles all libzmq operations because libzmq
23
23
  sockets are not thread-safe.
24
24
 
25
- `require "omq/ffi"` and `backend: :ffi` remain supported for compatibility.
26
-
27
25
  ## Interop
28
26
 
29
27
  libzmq and native Ruby backends are wire-compatible. You can mix them
@@ -4,15 +4,16 @@ require "async"
4
4
  require "uri"
5
5
 
6
6
  module OMQ
7
- module FFI
8
- # FFI Engine — wraps a libzmq socket to implement the OMQ Engine contract.
9
- #
10
- # A dedicated I/O thread owns the zmq_socket exclusively (libzmq sockets
11
- # are not thread-safe). Send and recv flow through queues, with an IO pipe
12
- # to wake the Async fiber scheduler.
13
- #
14
- class Engine
15
- L = Libzmq
7
+ module Backend
8
+ module Libzmq
9
+ # Engine — wraps a libzmq socket to implement the OMQ Engine contract.
10
+ #
11
+ # A dedicated I/O thread owns the zmq_socket exclusively (libzmq sockets
12
+ # are not thread-safe). Send and recv flow through queues, with an IO pipe
13
+ # to wake the Async fiber scheduler.
14
+ #
15
+ class Engine
16
+ L = Native
16
17
 
17
18
 
18
19
  # @return [Options] socket options
@@ -34,7 +35,7 @@ module OMQ
34
35
  alias on_io_thread? on_io_thread
35
36
  # @param value [Boolean] enables or disables automatic reconnection
36
37
  attr_writer :reconnect_enabled
37
- # @note Monitor events are not yet emitted by the FFI backend; these
38
+ # @note Monitor events are not yet emitted by the libzmq backend; these
38
39
  # writers exist so Socket#monitor can attach without raising. Wiring
39
40
  # libzmq's zmq_socket_monitor is a TODO.
40
41
  attr_writer :monitor_queue, :verbose_monitor
@@ -117,7 +118,7 @@ module OMQ
117
118
  @on_io_thread = false
118
119
  @fatal_error = nil
119
120
 
120
- @zmq_socket = L.zmq_socket(OMQ::FFI.context, L::SOCKET_TYPES.fetch(@socket_type))
121
+ @zmq_socket = L.zmq_socket(OMQ::Backend::Libzmq.context, L::SOCKET_TYPES.fetch(@socket_type))
121
122
  raise "zmq_socket failed: #{L.zmq_strerror(L.zmq_errno)}" if @zmq_socket.null?
122
123
 
123
124
  apply_options
@@ -247,7 +248,7 @@ module OMQ
247
248
 
248
249
  # Captures the current Async task as the parent for I/O scheduling.
249
250
  # +parent:+ is accepted for API compatibility with the pure-Ruby
250
- # engine but has no effect: the FFI backend runs its own I/O
251
+ # engine but has no effect: the libzmq backend runs its own I/O
251
252
  # thread and doesn't participate in the Async barrier tree.
252
253
  #
253
254
  # @return [void]
@@ -686,18 +687,19 @@ module OMQ
686
687
  end
687
688
 
688
689
 
689
- end
690
+ end
690
691
 
691
692
 
692
- # Returns the shared ZMQ context (one per process, lazily initialized).
693
- #
694
- # @return [FFI::Pointer] zmq context pointer
695
- def self.context
696
- @context ||= Libzmq.zmq_ctx_new.tap do |ctx|
697
- raise "zmq_ctx_new failed" if ctx.null?
698
- at_exit do
699
- Libzmq.zmq_ctx_shutdown(ctx) rescue nil
700
- Libzmq.zmq_ctx_term(ctx) rescue nil
693
+ # Returns the shared ZMQ context (one per process, lazily initialized).
694
+ #
695
+ # @return [FFI::Pointer] zmq context pointer
696
+ def self.context
697
+ @context ||= Native.zmq_ctx_new.tap do |ctx|
698
+ raise "zmq_ctx_new failed" if ctx.null?
699
+ at_exit do
700
+ Native.zmq_ctx_shutdown(ctx) rescue nil
701
+ Native.zmq_ctx_term(ctx) rescue nil
702
+ end
701
703
  end
702
704
  end
703
705
  end
@@ -3,12 +3,13 @@
3
3
  require "ffi"
4
4
 
5
5
  module OMQ
6
- module FFI
7
- # Minimal libzmq FFI bindings — only what OMQ needs.
8
- #
6
+ module Backend
9
7
  module Libzmq
10
- extend ::FFI::Library
11
- ffi_lib ["libzmq.so.5", "libzmq.5.dylib", "libzmq"]
8
+ # Minimal libzmq FFI bindings — only what OMQ needs.
9
+ #
10
+ module Native
11
+ extend ::FFI::Library
12
+ ffi_lib ["libzmq.so.5", "libzmq.5.dylib", "libzmq"]
12
13
 
13
14
  # Context
14
15
  attach_function :zmq_ctx_new, [], :pointer
@@ -129,6 +130,7 @@ module OMQ
129
130
  errno = zmq_errno
130
131
  raise "#{label}: #{zmq_strerror(errno)} (errno #{errno})"
131
132
  end
133
+ end
132
134
  end
133
135
  end
134
136
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "omq"
4
- require_relative "../ffi/libzmq"
5
- require_relative "../ffi/engine"
4
+ require_relative "libzmq/native"
5
+ require_relative "libzmq/engine"
6
6
 
7
- OMQ::Backend.register(:libzmq, OMQ::FFI::Engine)
8
- OMQ::Backend.register(:ffi, OMQ::FFI::Engine)
7
+ OMQ::Backend.register(:libzmq, OMQ::Backend::Libzmq::Engine)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omq-backend-libzmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger
@@ -46,9 +46,8 @@ files:
46
46
  - LICENSE
47
47
  - README.md
48
48
  - lib/omq/backend/libzmq.rb
49
- - lib/omq/ffi.rb
50
- - lib/omq/ffi/engine.rb
51
- - lib/omq/ffi/libzmq.rb
49
+ - lib/omq/backend/libzmq/engine.rb
50
+ - lib/omq/backend/libzmq/native.rb
52
51
  homepage: https://github.com/zeromq/omq.rb/tree/main/gems/omq-backend-libzmq
53
52
  licenses:
54
53
  - ISC
@@ -69,5 +68,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
68
  requirements: []
70
69
  rubygems_version: 4.0.16
71
70
  specification_version: 4
72
- summary: libzmq backend for OMQ using FFI
71
+ summary: libzmq backend for OMQ
73
72
  test_files: []
data/lib/omq/ffi.rb DELETED
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Compatibility load path for the libzmq backend.
4
- #
5
- # Usage:
6
- # require "omq/ffi"
7
- # push = OMQ::PUSH.new(backend: :ffi)
8
- #
9
- # Raises LoadError if libzmq is not installed.
10
-
11
- require_relative "backend/libzmq"