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 +4 -4
- data/README.md +0 -2
- data/lib/omq/{ffi → backend/libzmq}/engine.rb +24 -22
- data/lib/omq/{ffi/libzmq.rb → backend/libzmq/native.rb} +7 -5
- data/lib/omq/backend/libzmq.rb +3 -4
- metadata +4 -5
- data/lib/omq/ffi.rb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 843563bc4103e7c6a306887b213e563a94ba1d67ab2dda5f5d5e59e74466e90d
|
|
4
|
+
data.tar.gz: fcc4f468fc2c69e7c22870f5e69d57b99a3721ab031c4ae8dd4eb4316850ce1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
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::
|
|
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
|
|
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
|
-
|
|
690
|
+
end
|
|
690
691
|
|
|
691
692
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
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
|
|
7
|
-
# Minimal libzmq FFI bindings — only what OMQ needs.
|
|
8
|
-
#
|
|
6
|
+
module Backend
|
|
9
7
|
module Libzmq
|
|
10
|
-
|
|
11
|
-
|
|
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
|
data/lib/omq/backend/libzmq.rb
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "omq"
|
|
4
|
-
require_relative "
|
|
5
|
-
require_relative "
|
|
4
|
+
require_relative "libzmq/native"
|
|
5
|
+
require_relative "libzmq/engine"
|
|
6
6
|
|
|
7
|
-
OMQ::Backend.register(:libzmq, OMQ::
|
|
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.
|
|
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/
|
|
50
|
-
- lib/omq/
|
|
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
|
|
71
|
+
summary: libzmq backend for OMQ
|
|
73
72
|
test_files: []
|
data/lib/omq/ffi.rb
DELETED