czmq-ffi-gen 0.3.0 → 0.4.0
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/CHANGES.md +6 -0
- data/README.md +4 -2
- data/lib/czmq-ffi-gen.rb +1 -0
- data/lib/czmq-ffi-gen/czmq/ffi.rb +22 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zproc.rb +294 -0
- data/lib/czmq-ffi-gen/gem_version.rb +1 -1
- data/lib/czmq-ffi-gen/signals.rb +27 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4753723af1305df12590a3f43a5cedc724d3d8af
|
4
|
+
data.tar.gz: 502e1643c0f83b02f414e4211bba56b91cef9817
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a309f48d12a153ab625476d187e635df2ec9e592da1442a4928557e329bb7e2be7123f58976926fb6f1a9b1b5023c5a690455e59873a2ee99591450cf7babf04
|
7
|
+
data.tar.gz: 969c75a924e8bf90f0b66de5f5cb3faad2d050a6e7e5d1e142cf371796bdb62771ca3a139529ce93bb7b6441b4233de8fe495faa6323032e41197a9a679d45e7
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -56,11 +56,13 @@ Tested with these:
|
|
56
56
|
|
57
57
|
This gem requires the presence of the CZMQ library, which in turn requires the
|
58
58
|
ZMQ library. For **security mechanisms** like CURVE, you'll need
|
59
|
-
[libsodium](https://github.com/jedisct1/libsodium).
|
59
|
+
[libsodium](https://github.com/jedisct1/libsodium) and at least ZMQ 4.0.
|
60
60
|
|
61
61
|
On OSX using homebrew, run:
|
62
62
|
|
63
|
-
$ brew install libsodium
|
63
|
+
$ brew install libsodium
|
64
|
+
$ brew install zmq --with-libsodium
|
65
|
+
$ brew install czmq
|
64
66
|
|
65
67
|
If you're running Linux, go check [this page](http://zeromq.org/distro:_start)
|
66
68
|
to get more help. Make sure to install CZMQ, not only ZMQ.
|
data/lib/czmq-ffi-gen.rb
CHANGED
@@ -404,6 +404,28 @@ module CZMQ
|
|
404
404
|
|
405
405
|
require_relative 'ffi/zpoller'
|
406
406
|
|
407
|
+
attach_function :zproc_czmq_version, [], :int, **opts
|
408
|
+
attach_function :zproc_interrupted, [], :bool, **opts
|
409
|
+
attach_function :zproc_has_curve, [], :bool, **opts
|
410
|
+
attach_function :zproc_hostname, [], :pointer, **opts
|
411
|
+
attach_function :zproc_daemonize, [:string], :void, **opts
|
412
|
+
attach_function :zproc_run_as, [:string, :string, :string], :void, **opts
|
413
|
+
attach_function :zproc_set_io_threads, [:size_t], :void, **opts
|
414
|
+
attach_function :zproc_set_max_sockets, [:size_t], :void, **opts
|
415
|
+
attach_function :zproc_set_biface, [:string], :void, **opts
|
416
|
+
attach_function :zproc_biface, [], :string, **opts
|
417
|
+
attach_function :zproc_set_log_ident, [:string], :void, **opts
|
418
|
+
attach_function :zproc_set_log_sender, [:string], :void, **opts
|
419
|
+
attach_function :zproc_set_log_system, [:bool], :void, **opts
|
420
|
+
attach_function :zproc_log_error, [:string, :varargs], :void, **opts
|
421
|
+
attach_function :zproc_log_warning, [:string, :varargs], :void, **opts
|
422
|
+
attach_function :zproc_log_notice, [:string, :varargs], :void, **opts
|
423
|
+
attach_function :zproc_log_info, [:string, :varargs], :void, **opts
|
424
|
+
attach_function :zproc_log_debug, [:string, :varargs], :void, **opts
|
425
|
+
attach_function :zproc_test, [:bool], :void, **opts
|
426
|
+
|
427
|
+
require_relative 'ffi/zproc'
|
428
|
+
|
407
429
|
attach_function :zsock_new, [:int], :pointer, **opts
|
408
430
|
attach_function :zsock_new_pub, [:string], :pointer, **opts
|
409
431
|
attach_function :zsock_new_sub, [:string, :string], :pointer, **opts
|
@@ -0,0 +1,294 @@
|
|
1
|
+
################################################################################
|
2
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
3
|
+
# Please refer to the README for information about making permanent changes. #
|
4
|
+
################################################################################
|
5
|
+
|
6
|
+
module CZMQ
|
7
|
+
module FFI
|
8
|
+
|
9
|
+
# process configuration and status
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zproc
|
12
|
+
# Raised when one tries to use an instance of {Zproc} after
|
13
|
+
# the internal pointer to the native object has been nullified.
|
14
|
+
class DestroyedError < RuntimeError; end
|
15
|
+
|
16
|
+
# Boilerplate for self pointer, initializer, and finalizer
|
17
|
+
class << self
|
18
|
+
alias :__new :new
|
19
|
+
end
|
20
|
+
# Attaches the pointer _ptr_ to this instance and defines a finalizer for
|
21
|
+
# it if necessary.
|
22
|
+
# @param ptr [::FFI::Pointer]
|
23
|
+
# @param finalize [Boolean]
|
24
|
+
def initialize(ptr, finalize = true)
|
25
|
+
@ptr = ptr
|
26
|
+
if @ptr.null?
|
27
|
+
@ptr = nil # Remove null pointers so we don't have to test for them.
|
28
|
+
elsif finalize
|
29
|
+
@finalizer = self.class.create_finalizer_for @ptr
|
30
|
+
ObjectSpace.define_finalizer self, @finalizer
|
31
|
+
end
|
32
|
+
end
|
33
|
+
# @return [Proc]
|
34
|
+
def self.create_finalizer_for(ptr)
|
35
|
+
Proc.new do
|
36
|
+
"WARNING: "\
|
37
|
+
"Objects of type #{self} cannot be destroyed implicitly. "\
|
38
|
+
"Please call the correct destroy method with the relevant arguments."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
# @return [Boolean]
|
42
|
+
def null?
|
43
|
+
!@ptr or @ptr.null?
|
44
|
+
end
|
45
|
+
# Return internal pointer
|
46
|
+
# @return [::FFI::Pointer]
|
47
|
+
def __ptr
|
48
|
+
raise DestroyedError unless @ptr
|
49
|
+
@ptr
|
50
|
+
end
|
51
|
+
# So external Libraries can just pass the Object to a FFI function which expects a :pointer
|
52
|
+
alias_method :to_ptr, :__ptr
|
53
|
+
# Nullify internal pointer and return pointer pointer.
|
54
|
+
# @note This detaches the current instance from the native object
|
55
|
+
# and thus makes it unusable.
|
56
|
+
# @return [::FFI::MemoryPointer] the pointer pointing to a pointer
|
57
|
+
# pointing to the native object
|
58
|
+
def __ptr_give_ref
|
59
|
+
raise DestroyedError unless @ptr
|
60
|
+
ptr_ptr = ::FFI::MemoryPointer.new :pointer
|
61
|
+
ptr_ptr.write_pointer @ptr
|
62
|
+
__undef_finalizer if @finalizer
|
63
|
+
@ptr = nil
|
64
|
+
ptr_ptr
|
65
|
+
end
|
66
|
+
# Undefines the finalizer for this object.
|
67
|
+
# @note Only use this if you need to and can guarantee that the native
|
68
|
+
# object will be freed by other means.
|
69
|
+
# @return [void]
|
70
|
+
def __undef_finalizer
|
71
|
+
ObjectSpace.undefine_finalizer self
|
72
|
+
@finalizer = nil
|
73
|
+
end
|
74
|
+
|
75
|
+
# Returns CZMQ version as a single 6-digit integer encoding the major
|
76
|
+
# version (x 10000), the minor version (x 100) and the patch.
|
77
|
+
#
|
78
|
+
# @return [Integer]
|
79
|
+
def self.czmq_version()
|
80
|
+
result = ::CZMQ::FFI.zproc_czmq_version()
|
81
|
+
result
|
82
|
+
end
|
83
|
+
|
84
|
+
# Returns true if the process received a SIGINT or SIGTERM signal.
|
85
|
+
# It is good practice to use this method to exit any infinite loop
|
86
|
+
# processing messages.
|
87
|
+
#
|
88
|
+
# @return [Boolean]
|
89
|
+
def self.interrupted()
|
90
|
+
result = ::CZMQ::FFI.zproc_interrupted()
|
91
|
+
result
|
92
|
+
end
|
93
|
+
|
94
|
+
# Returns true if the underlying libzmq supports CURVE security.
|
95
|
+
#
|
96
|
+
# @return [Boolean]
|
97
|
+
def self.has_curve()
|
98
|
+
result = ::CZMQ::FFI.zproc_has_curve()
|
99
|
+
result
|
100
|
+
end
|
101
|
+
|
102
|
+
# Return current host name, for use in public tcp:// endpoints.
|
103
|
+
# If the host name is not resolvable, returns NULL.
|
104
|
+
#
|
105
|
+
# @return [::FFI::AutoPointer]
|
106
|
+
def self.hostname()
|
107
|
+
result = ::CZMQ::FFI.zproc_hostname()
|
108
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
109
|
+
result
|
110
|
+
end
|
111
|
+
|
112
|
+
# Move the current process into the background. The precise effect
|
113
|
+
# depends on the operating system. On POSIX boxes, moves to a specified
|
114
|
+
# working directory (if specified), closes all file handles, reopens
|
115
|
+
# stdin, stdout, and stderr to the null device, and sets the process to
|
116
|
+
# ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there
|
117
|
+
# was an error.
|
118
|
+
#
|
119
|
+
# @param workdir [String, #to_s, nil]
|
120
|
+
# @return [void]
|
121
|
+
def self.daemonize(workdir)
|
122
|
+
result = ::CZMQ::FFI.zproc_daemonize(workdir)
|
123
|
+
result
|
124
|
+
end
|
125
|
+
|
126
|
+
# Drop the process ID into the lockfile, with exclusive lock, and
|
127
|
+
# switch the process to the specified group and/or user. Any of the
|
128
|
+
# arguments may be null, indicating a no-op. Returns 0 on success,
|
129
|
+
# -1 on failure. Note if you combine this with zsys_daemonize, run
|
130
|
+
# after, not before that method, or the lockfile will hold the wrong
|
131
|
+
# process ID.
|
132
|
+
#
|
133
|
+
# @param lockfile [String, #to_s, nil]
|
134
|
+
# @param group [String, #to_s, nil]
|
135
|
+
# @param user [String, #to_s, nil]
|
136
|
+
# @return [void]
|
137
|
+
def self.run_as(lockfile, group, user)
|
138
|
+
result = ::CZMQ::FFI.zproc_run_as(lockfile, group, user)
|
139
|
+
result
|
140
|
+
end
|
141
|
+
|
142
|
+
# Configure the number of I/O threads that ZeroMQ will use. A good
|
143
|
+
# rule of thumb is one thread per gigabit of traffic in or out. The
|
144
|
+
# default is 1, sufficient for most applications. If the environment
|
145
|
+
# variable ZSYS_IO_THREADS is defined, that provides the default.
|
146
|
+
# Note that this method is valid only before any socket is created.
|
147
|
+
#
|
148
|
+
# @param io_threads [Integer, #to_int, #to_i]
|
149
|
+
# @return [void]
|
150
|
+
def self.set_io_threads(io_threads)
|
151
|
+
io_threads = Integer(io_threads)
|
152
|
+
result = ::CZMQ::FFI.zproc_set_io_threads(io_threads)
|
153
|
+
result
|
154
|
+
end
|
155
|
+
|
156
|
+
# Configure the number of sockets that ZeroMQ will allow. The default
|
157
|
+
# is 1024. The actual limit depends on the system, and you can query it
|
158
|
+
# by using zsys_socket_limit (). A value of zero means "maximum".
|
159
|
+
# Note that this method is valid only before any socket is created.
|
160
|
+
#
|
161
|
+
# @param max_sockets [Integer, #to_int, #to_i]
|
162
|
+
# @return [void]
|
163
|
+
def self.set_max_sockets(max_sockets)
|
164
|
+
max_sockets = Integer(max_sockets)
|
165
|
+
result = ::CZMQ::FFI.zproc_set_max_sockets(max_sockets)
|
166
|
+
result
|
167
|
+
end
|
168
|
+
|
169
|
+
# Set network interface name to use for broadcasts, particularly zbeacon.
|
170
|
+
# This lets the interface be configured for test environments where required.
|
171
|
+
# For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
|
172
|
+
# the default when there is no specified interface. If the environment
|
173
|
+
# variable ZSYS_INTERFACE is set, use that as the default interface name.
|
174
|
+
# Setting the interface to "*" means "use all available interfaces".
|
175
|
+
#
|
176
|
+
# @param value [String, #to_s, nil]
|
177
|
+
# @return [void]
|
178
|
+
def self.set_biface(value)
|
179
|
+
result = ::CZMQ::FFI.zproc_set_biface(value)
|
180
|
+
result
|
181
|
+
end
|
182
|
+
|
183
|
+
# Return network interface to use for broadcasts, or "" if none was set.
|
184
|
+
#
|
185
|
+
# @return [String]
|
186
|
+
def self.biface()
|
187
|
+
result = ::CZMQ::FFI.zproc_biface()
|
188
|
+
result
|
189
|
+
end
|
190
|
+
|
191
|
+
# Set log identity, which is a string that prefixes all log messages sent
|
192
|
+
# by this process. The log identity defaults to the environment variable
|
193
|
+
# ZSYS_LOGIDENT, if that is set.
|
194
|
+
#
|
195
|
+
# @param value [String, #to_s, nil]
|
196
|
+
# @return [void]
|
197
|
+
def self.set_log_ident(value)
|
198
|
+
result = ::CZMQ::FFI.zproc_set_log_ident(value)
|
199
|
+
result
|
200
|
+
end
|
201
|
+
|
202
|
+
# Sends log output to a PUB socket bound to the specified endpoint. To
|
203
|
+
# collect such log output, create a SUB socket, subscribe to the traffic
|
204
|
+
# you care about, and connect to the endpoint. Log traffic is sent as a
|
205
|
+
# single string frame, in the same format as when sent to stdout. The
|
206
|
+
# log system supports a single sender; multiple calls to this method will
|
207
|
+
# bind the same sender to multiple endpoints. To disable the sender, call
|
208
|
+
# this method with a null argument.
|
209
|
+
#
|
210
|
+
# @param endpoint [String, #to_s, nil]
|
211
|
+
# @return [void]
|
212
|
+
def self.set_log_sender(endpoint)
|
213
|
+
result = ::CZMQ::FFI.zproc_set_log_sender(endpoint)
|
214
|
+
result
|
215
|
+
end
|
216
|
+
|
217
|
+
# Enable or disable logging to the system facility (syslog on POSIX boxes,
|
218
|
+
# event log on Windows). By default this is disabled.
|
219
|
+
#
|
220
|
+
# @param logsystem [Boolean]
|
221
|
+
# @return [void]
|
222
|
+
def self.set_log_system(logsystem)
|
223
|
+
logsystem = !(0==logsystem||!logsystem) # boolean
|
224
|
+
result = ::CZMQ::FFI.zproc_set_log_system(logsystem)
|
225
|
+
result
|
226
|
+
end
|
227
|
+
|
228
|
+
# Log error condition - highest priority
|
229
|
+
#
|
230
|
+
# @param format [String, #to_s, nil]
|
231
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
232
|
+
# @return [void]
|
233
|
+
def self.log_error(format, *args)
|
234
|
+
result = ::CZMQ::FFI.zproc_log_error(format, *args)
|
235
|
+
result
|
236
|
+
end
|
237
|
+
|
238
|
+
# Log warning condition - high priority
|
239
|
+
#
|
240
|
+
# @param format [String, #to_s, nil]
|
241
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
242
|
+
# @return [void]
|
243
|
+
def self.log_warning(format, *args)
|
244
|
+
result = ::CZMQ::FFI.zproc_log_warning(format, *args)
|
245
|
+
result
|
246
|
+
end
|
247
|
+
|
248
|
+
# Log normal, but significant, condition - normal priority
|
249
|
+
#
|
250
|
+
# @param format [String, #to_s, nil]
|
251
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
252
|
+
# @return [void]
|
253
|
+
def self.log_notice(format, *args)
|
254
|
+
result = ::CZMQ::FFI.zproc_log_notice(format, *args)
|
255
|
+
result
|
256
|
+
end
|
257
|
+
|
258
|
+
# Log informational message - low priority
|
259
|
+
#
|
260
|
+
# @param format [String, #to_s, nil]
|
261
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
262
|
+
# @return [void]
|
263
|
+
def self.log_info(format, *args)
|
264
|
+
result = ::CZMQ::FFI.zproc_log_info(format, *args)
|
265
|
+
result
|
266
|
+
end
|
267
|
+
|
268
|
+
# Log debug-level message - lowest priority
|
269
|
+
#
|
270
|
+
# @param format [String, #to_s, nil]
|
271
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
272
|
+
# @return [void]
|
273
|
+
def self.log_debug(format, *args)
|
274
|
+
result = ::CZMQ::FFI.zproc_log_debug(format, *args)
|
275
|
+
result
|
276
|
+
end
|
277
|
+
|
278
|
+
# Self test of this class.
|
279
|
+
#
|
280
|
+
# @param verbose [Boolean]
|
281
|
+
# @return [void]
|
282
|
+
def self.test(verbose)
|
283
|
+
verbose = !(0==verbose||!verbose) # boolean
|
284
|
+
result = ::CZMQ::FFI.zproc_test(verbose)
|
285
|
+
result
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
################################################################################
|
292
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
293
|
+
# Please refer to the README for information about making permanent changes. #
|
294
|
+
################################################################################
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module CZMQ
|
2
|
+
module FFI
|
3
|
+
|
4
|
+
attach_function :zsys_handler_set, [:pointer], :void, blocking: true
|
5
|
+
|
6
|
+
# This is used to disable CZMQ's signal handling so blocking calls can be
|
7
|
+
# interrupted using Ctrl-C.
|
8
|
+
module Signals
|
9
|
+
module_function
|
10
|
+
|
11
|
+
@default_handling_disabled = false
|
12
|
+
|
13
|
+
# Disables default SIGINT/SIGTERM handling in CZMQ.
|
14
|
+
# @return [void]
|
15
|
+
def disable_default_handling
|
16
|
+
FFI.zsys_handler_set(nil)
|
17
|
+
@default_handling_disabled = true
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [Boolean] whether the CZMQ's default signal handling has been
|
21
|
+
# disabled
|
22
|
+
def default_handling_disabled?
|
23
|
+
@default_handling_disabled
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: czmq-ffi-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrik Wenger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -111,12 +111,14 @@ files:
|
|
111
111
|
- lib/czmq-ffi-gen/czmq/ffi/zloop.rb
|
112
112
|
- lib/czmq-ffi-gen/czmq/ffi/zmsg.rb
|
113
113
|
- lib/czmq-ffi-gen/czmq/ffi/zpoller.rb
|
114
|
+
- lib/czmq-ffi-gen/czmq/ffi/zproc.rb
|
114
115
|
- lib/czmq-ffi-gen/czmq/ffi/zsock.rb
|
115
116
|
- lib/czmq-ffi-gen/czmq/ffi/zstr.rb
|
116
117
|
- lib/czmq-ffi-gen/czmq/ffi/ztrie.rb
|
117
118
|
- lib/czmq-ffi-gen/czmq/ffi/zuuid.rb
|
118
119
|
- lib/czmq-ffi-gen/gem_version.rb
|
119
120
|
- lib/czmq-ffi-gen/library_version.rb
|
121
|
+
- lib/czmq-ffi-gen/signals.rb
|
120
122
|
homepage: https://github.com/paddor/czmq-ffi-gen
|
121
123
|
licenses:
|
122
124
|
- ISC
|