ffi-rzmq-core 1.0.3 → 1.0.7
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 +5 -5
- data/.travis.yml +2 -4
- data/History.txt +8 -0
- data/README.md +3 -0
- data/ffi-rzmq-core.gemspec +2 -2
- data/lib/ffi-rzmq-core/constants.rb +66 -48
- data/lib/ffi-rzmq-core/libzmq.rb +23 -6
- data/lib/ffi-rzmq-core/libzmq4.rb +5 -0
- data/lib/ffi-rzmq-core/structures.rb +44 -7
- data/lib/ffi-rzmq-core/version.rb +1 -1
- data/lib/ffi-rzmq-core.rb +1 -1
- data/spec/libzmq_spec.rb +23 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/structures_spec.rb +17 -6
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dfb36c8fd3ba8ea7889a686282a1eea04fd42b6b418fb627a59136ebca5e9c60
|
4
|
+
data.tar.gz: 6351eccd6e2ca3e0c91a49e02672bbec65d4d33abd728e368a98abf3d975c9ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61f7bd2e38fe8025d8dd37e81e9872770c8ae367ec03305a5b155c4397503996f696af1f33987329ad2019041ddf17a4a1979df2cb0cb64e5c8bbb3852b8255c
|
7
|
+
data.tar.gz: 48c45585ef08d5a03cf76b3eb0e47cace36aacb686626bee1e2a55173b52c56ae858d5356736253d45b70b0702f69dd18e643dd5fb637e190121e78dbe652b1d
|
data/.travis.yml
CHANGED
data/History.txt
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
== 1.0.7
|
2
|
+
* Provide a wrapper function for calling context termination. Zeromq 3.x
|
3
|
+
uses zmq_ctx_destroy to terminate a context. While this function exists
|
4
|
+
in Zeromq 4.x, it is deprecated. For 4.x, we prefer to use zmq_ctx_term.
|
5
|
+
When loading the library, we define a `terminate_context` method on the
|
6
|
+
module which defaults to using the 3.x function call. If the 4.x support
|
7
|
+
loads, then this method is overwritten to use the 4.x function call.
|
8
|
+
|
data/README.md
CHANGED
@@ -10,6 +10,9 @@ hoping this encourages other library writers to create their own. Rather than du
|
|
10
10
|
wrapping code, they can just pull in this gem and build a more idiomatic library around the
|
11
11
|
basic definitions.
|
12
12
|
|
13
|
+
As of zeromq 4.2.x, this library does not yet support the `zmq_atomic_counter_*` functions or many
|
14
|
+
of the other newly exposed functions. Pull requests encouraged!
|
15
|
+
|
13
16
|
See [ffi-rzmq]
|
14
17
|
|
15
18
|
### Development
|
data/ffi-rzmq-core.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_runtime_dependency "ffi"
|
23
|
-
s.add_development_dependency "rspec"
|
22
|
+
s.add_runtime_dependency "ffi"
|
23
|
+
s.add_development_dependency "rspec"
|
24
24
|
s.add_development_dependency "rake"
|
25
25
|
end
|
@@ -37,54 +37,72 @@ module ZMQ
|
|
37
37
|
}
|
38
38
|
|
39
39
|
# Socket options
|
40
|
-
AFFINITY
|
41
|
-
IDENTITY
|
42
|
-
SUBSCRIBE
|
43
|
-
UNSUBSCRIBE
|
44
|
-
RATE
|
45
|
-
RECOVERY_IVL
|
46
|
-
SNDBUF
|
47
|
-
RCVBUF
|
48
|
-
RCVMORE
|
49
|
-
FD
|
50
|
-
EVENTS
|
51
|
-
TYPE
|
52
|
-
LINGER
|
53
|
-
RECONNECT_IVL
|
54
|
-
BACKLOG
|
55
|
-
RECONNECT_IVL_MAX
|
56
|
-
MAXMSGSIZE
|
57
|
-
SNDHWM
|
58
|
-
RCVHWM
|
59
|
-
MULTICAST_HOPS
|
60
|
-
RCVTIMEO
|
61
|
-
SNDTIMEO
|
62
|
-
IPV4ONLY
|
63
|
-
LAST_ENDPOINT
|
64
|
-
ROUTER_MANDATORY
|
65
|
-
TCP_KEEPALIVE
|
66
|
-
TCP_KEEPALIVE_CNT
|
67
|
-
TCP_KEEPALIVE_IDLE
|
68
|
-
TCP_KEEPALIVE_INTVL
|
69
|
-
TCP_ACCEPT_FILTER
|
70
|
-
DELAY_ATTACH_ON_CONNECT
|
71
|
-
XPUB_VERBOSE
|
72
|
-
ROUTER_RAW
|
73
|
-
IPV6
|
74
|
-
MECHANISM
|
75
|
-
PLAIN_SERVER
|
76
|
-
PLAIN_USERNAME
|
77
|
-
PLAIN_PASSWORD
|
78
|
-
CURVE_SERVER
|
79
|
-
CURVE_PUBLICKEY
|
80
|
-
CURVE_SECRETKEY
|
81
|
-
CURVE_SERVERKEY
|
82
|
-
PROBE_ROUTER
|
83
|
-
REQ_CORRELATE
|
84
|
-
REQ_RELAXED
|
85
|
-
CONFLATE
|
86
|
-
ZAP_DOMAIN
|
87
|
-
ROUTER_HANDOVER
|
40
|
+
AFFINITY = 4
|
41
|
+
IDENTITY = 5
|
42
|
+
SUBSCRIBE = 6
|
43
|
+
UNSUBSCRIBE = 7
|
44
|
+
RATE = 8
|
45
|
+
RECOVERY_IVL = 9
|
46
|
+
SNDBUF = 11
|
47
|
+
RCVBUF = 12
|
48
|
+
RCVMORE = 13
|
49
|
+
FD = 14
|
50
|
+
EVENTS = 15
|
51
|
+
TYPE = 16
|
52
|
+
LINGER = 17
|
53
|
+
RECONNECT_IVL = 18
|
54
|
+
BACKLOG = 19
|
55
|
+
RECONNECT_IVL_MAX = 21
|
56
|
+
MAXMSGSIZE = 22
|
57
|
+
SNDHWM = 23
|
58
|
+
RCVHWM = 24
|
59
|
+
MULTICAST_HOPS = 25
|
60
|
+
RCVTIMEO = 27
|
61
|
+
SNDTIMEO = 28
|
62
|
+
IPV4ONLY = 31
|
63
|
+
LAST_ENDPOINT = 32
|
64
|
+
ROUTER_MANDATORY = 33
|
65
|
+
TCP_KEEPALIVE = 34
|
66
|
+
TCP_KEEPALIVE_CNT = 35
|
67
|
+
TCP_KEEPALIVE_IDLE = 36
|
68
|
+
TCP_KEEPALIVE_INTVL = 37
|
69
|
+
TCP_ACCEPT_FILTER = 38
|
70
|
+
DELAY_ATTACH_ON_CONNECT = 39
|
71
|
+
XPUB_VERBOSE = 40
|
72
|
+
ROUTER_RAW = 41
|
73
|
+
IPV6 = 42
|
74
|
+
MECHANISM = 43
|
75
|
+
PLAIN_SERVER = 44
|
76
|
+
PLAIN_USERNAME = 45
|
77
|
+
PLAIN_PASSWORD = 46
|
78
|
+
CURVE_SERVER = 47
|
79
|
+
CURVE_PUBLICKEY = 48
|
80
|
+
CURVE_SECRETKEY = 49
|
81
|
+
CURVE_SERVERKEY = 50
|
82
|
+
PROBE_ROUTER = 51
|
83
|
+
REQ_CORRELATE = 52
|
84
|
+
REQ_RELAXED = 53
|
85
|
+
CONFLATE = 54
|
86
|
+
ZAP_DOMAIN = 55
|
87
|
+
ROUTER_HANDOVER = 56
|
88
|
+
TOS = 57
|
89
|
+
CONNECT_RID = 61
|
90
|
+
GSSAPI_SERVER = 62
|
91
|
+
GSSAPI_PRINCIPAL = 63
|
92
|
+
GSSAPI_SERVICE_PRINCIPAL = 64
|
93
|
+
GSSAPI_PLAINTEXT = 65
|
94
|
+
HANDSHAKE_IVL = 66
|
95
|
+
SOCKS_PROXY = 68
|
96
|
+
XPUB_NODROP = 69
|
97
|
+
BLOCKY = 70
|
98
|
+
XPUB_MANUAL = 71
|
99
|
+
XPUB_WELCOME_MSG = 72
|
100
|
+
STREAM_NOTIFY = 73
|
101
|
+
INVERT_MATCHING = 74
|
102
|
+
HEARTBEAT_IVL = 75
|
103
|
+
HEARTBEAT_TTL = 76
|
104
|
+
HEARTBEAT_TIMEOUT = 77
|
105
|
+
XPUB_VERBOSE_UNSUBSCRIBE = 78
|
88
106
|
|
89
107
|
IMMEDIATE = DELAY_ATTACH_ON_CONNECT
|
90
108
|
FAIL_UNROUTABLE = ROUTER_MANDATORY
|
data/lib/ffi-rzmq-core/libzmq.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'open3'
|
2
|
+
require 'rbconfig'
|
2
3
|
|
3
4
|
# Wraps the libzmq library and attaches to the functions that are
|
4
5
|
# common across the 3.2.x+ and 4.x APIs.
|
@@ -11,6 +12,8 @@ module LibZMQ
|
|
11
12
|
# to the usual system paths
|
12
13
|
inside_gem = File.join(File.dirname(__FILE__), '..', '..', 'ext')
|
13
14
|
local_path = FFI::Platform::IS_WINDOWS ? ENV['PATH'].split(';') : ENV['PATH'].split(':')
|
15
|
+
env_path = [ ENV['ZMQ_LIB_PATH'] ].compact
|
16
|
+
rbconfig_path = RbConfig::CONFIG["libdir"]
|
14
17
|
homebrew_path = nil
|
15
18
|
|
16
19
|
# RUBYOPT set by RVM breaks 'brew' so we need to unset it.
|
@@ -31,18 +34,28 @@ module LibZMQ
|
|
31
34
|
ENV['RUBYOPT'] = rubyopt
|
32
35
|
|
33
36
|
# Search for libzmq in the following order...
|
34
|
-
ZMQ_LIB_PATHS = ([inside_gem] + local_path + [
|
37
|
+
ZMQ_LIB_PATHS = ([inside_gem] + env_path + local_path + [rbconfig_path] + [
|
35
38
|
'/usr/local/lib', '/opt/local/lib', homebrew_path, '/usr/lib64'
|
36
39
|
]).compact.map{|path| "#{path}/libzmq.#{FFI::Platform::LIBSUFFIX}"}
|
40
|
+
|
41
|
+
# Recent versions of libzmq do not put all symbols into the global namespace so
|
42
|
+
# lazy linking can fail at runtime. Force all symbols to global namespace.
|
43
|
+
ffi_lib_flags :now, :global
|
37
44
|
ffi_lib(ZMQ_LIB_PATHS + %w{libzmq})
|
38
45
|
|
39
46
|
rescue LoadError
|
40
|
-
|
41
|
-
|
47
|
+
# Failed to load the zmq library
|
48
|
+
|
49
|
+
found_libs = ZMQ_LIB_PATHS.find_all {|path| File.file? path }
|
50
|
+
if found_libs.any?
|
42
51
|
warn "Unable to load this gem. The libzmq library exists, but cannot be loaded."
|
43
|
-
warn "
|
44
|
-
warn
|
45
|
-
|
52
|
+
warn "libzmq library was found at:"
|
53
|
+
warn found_libs.inspect
|
54
|
+
if FFI::Platform::IS_WINDOWS
|
55
|
+
warn "On Windows:"
|
56
|
+
warn "- Check that you have MSVC runtime installed or statically linked"
|
57
|
+
warn "- Check that your DLL is compiled for #{FFI::Platform::ADDRESS_SIZE} bit"
|
58
|
+
end
|
46
59
|
else
|
47
60
|
warn "Unable to load this gem. The libzmq library (or DLL) could not be found."
|
48
61
|
warn "If this is a Windows platform, make sure libzmq.dll is on the PATH."
|
@@ -116,4 +129,8 @@ module LibZMQ
|
|
116
129
|
# Monitoring API
|
117
130
|
attach_function :zmq_socket_monitor, [:pointer, :pointer, :int], :int, :blocking => true
|
118
131
|
|
132
|
+
# Wrapper function for context termination
|
133
|
+
def self.terminate_context(context)
|
134
|
+
zmq_ctx_destroy(context)
|
135
|
+
end
|
119
136
|
end
|
@@ -14,4 +14,9 @@ module LibZMQ
|
|
14
14
|
# Will return -1 with errno set to ENOSUP otherwise
|
15
15
|
attach_function :zmq_curve_keypair, [:pointer, :pointer], :int, :blocking => true
|
16
16
|
|
17
|
+
# Wrapper function for context termination
|
18
|
+
def self.terminate_context(context)
|
19
|
+
zmq_ctx_term(context)
|
20
|
+
end
|
21
|
+
|
17
22
|
end
|
@@ -1,14 +1,51 @@
|
|
1
1
|
module LibZMQ
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
:vsm_data, [:uint8, 30]
|
3
|
+
def self.version_number
|
4
|
+
10000 * version[:major] + 100 * version[:minor] + version[:patch]
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.version_string
|
8
|
+
"%d.%d.%d" % version.values_at(:major, :minor, :patch)
|
10
9
|
end
|
11
10
|
|
11
|
+
raise "zmq library version not supported: #{version_string}" if version_number < 030200
|
12
|
+
|
13
|
+
# here are the typedefs for zmsg_msg_t for all known releases of libzmq
|
14
|
+
# grep 'typedef struct zmq_msg_t' */include/zmq.h
|
15
|
+
# zeromq-3.2.2/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
16
|
+
# zeromq-3.2.3/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
17
|
+
# zeromq-3.2.4/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
18
|
+
# zeromq-3.2.5/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
19
|
+
# zeromq-4.0.0/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
20
|
+
# zeromq-4.0.1/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
21
|
+
# zeromq-4.0.2/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
22
|
+
# zeromq-4.0.3/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
23
|
+
# zeromq-4.0.4/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
24
|
+
# zeromq-4.0.5/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
25
|
+
# zeromq-4.0.6/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
26
|
+
# zeromq-4.0.7/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
|
27
|
+
# zeromq-4.1.0/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [48];} zmq_msg_t;
|
28
|
+
# zeromq-4.1.1/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [64];} zmq_msg_t;
|
29
|
+
# zeromq-4.1.2/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [64];} zmq_msg_t;
|
30
|
+
# zeromq-4.1.3/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [64];} zmq_msg_t;
|
31
|
+
# zeromq-4.1.4/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [64];} zmq_msg_t;
|
32
|
+
# libzmq/include/zmq.h: typedef union zmq_msg_t {unsigned char _ [64]; void *p; } zmq_msg_t;
|
33
|
+
|
34
|
+
def self.size_of_zmq_msg_t
|
35
|
+
if version_number < 040100
|
36
|
+
32
|
37
|
+
elsif version_number < 040101
|
38
|
+
48
|
39
|
+
else
|
40
|
+
64
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Declare Message with correct size and alignment
|
45
|
+
class Message < FFI::Union
|
46
|
+
layout :'_', [:uint8, LibZMQ.size_of_zmq_msg_t],
|
47
|
+
:p, :pointer
|
48
|
+
end
|
12
49
|
|
13
50
|
# Create the basic mapping for the poll_item_t structure so we can
|
14
51
|
# access those fields via Ruby.
|
data/lib/ffi-rzmq-core.rb
CHANGED
data/spec/libzmq_spec.rb
CHANGED
@@ -45,4 +45,27 @@ describe LibZMQ do
|
|
45
45
|
expect(LibZMQ).to respond_to(:zmq_socket_monitor)
|
46
46
|
end
|
47
47
|
|
48
|
+
if LibZMQ.version3?
|
49
|
+
|
50
|
+
describe '.terminate_context' do
|
51
|
+
it 'calls the 3.x zmq_ctx_destroy function' do
|
52
|
+
context_dbl = double('context')
|
53
|
+
|
54
|
+
expect(LibZMQ).to receive(:zmq_ctx_destroy).with(context_dbl)
|
55
|
+
LibZMQ.terminate_context(context_dbl)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
elsif LibZMQ.version4?
|
60
|
+
|
61
|
+
describe '.terminate_context' do
|
62
|
+
it 'calls the 4.x zmq_ctx_destroy function' do
|
63
|
+
context_dbl = double('context')
|
64
|
+
|
65
|
+
expect(LibZMQ).to receive(:zmq_ctx_term).with(context_dbl)
|
66
|
+
LibZMQ.terminate_context(context_dbl)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
48
71
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/structures_spec.rb
CHANGED
@@ -2,13 +2,24 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LibZMQ do
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
if LibZMQ.version_number >= 040101
|
6
|
+
|
7
|
+
it "the msg_t struct wrapped in Message is 64 bytes" do
|
8
|
+
LibZMQ::Message.size == 64
|
9
|
+
end
|
10
|
+
|
11
|
+
elsif LibZMQ.version_number < 040100
|
12
|
+
|
13
|
+
it "the msg_t struct wrapped in Message is 32 bytes" do
|
14
|
+
LibZMQ::Message.size == 32
|
15
|
+
end
|
16
|
+
|
17
|
+
elsif LibZMQ.version_number == 040100
|
18
|
+
|
19
|
+
it "the msg_t struct wrapped in Message is 48 bytes" do
|
20
|
+
LibZMQ::Message.size == 32
|
21
|
+
end
|
7
22
|
|
8
|
-
expect(message[:content]).to_not be_nil
|
9
|
-
expect(message[:flags]).to_not be_nil
|
10
|
-
expect(message[:vsm_size]).to_not be_nil
|
11
|
-
expect(message[:vsm_data]).to_not be_nil
|
12
23
|
end
|
13
24
|
|
14
25
|
it "wraps poll_item_t in a PollItem" do
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-rzmq-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuck Remes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- ".gitignore"
|
65
65
|
- ".travis.yml"
|
66
66
|
- Gemfile
|
67
|
+
- History.txt
|
67
68
|
- LICENSE
|
68
69
|
- README.md
|
69
70
|
- Rakefile
|
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
103
|
version: '0'
|
103
104
|
requirements: []
|
104
105
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.7.3
|
106
107
|
signing_key:
|
107
108
|
specification_version: 4
|
108
109
|
summary: This gem provides only the FFI wrapper for the ZeroMQ (0mq) networking library.
|