czmq-ffi-gen 0.14.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -188,7 +188,7 @@ module CZMQ
188
188
 
189
189
  # Set default interrupt handler, so Ctrl-C or SIGTERM will set
190
190
  # zsys_interrupted. Idempotent; safe to call multiple times.
191
- # Can be supressed by ZSYS_SIGHANDLER=false
191
+ # Can be suppressed by ZSYS_SIGHANDLER=false
192
192
  # *** This is for CZMQ internal use only and may change arbitrarily ***
193
193
  #
194
194
  # @return [void]
@@ -197,6 +197,26 @@ module CZMQ
197
197
  result
198
198
  end
199
199
 
200
+ # Check if default interrupt handler of Ctrl-C or SIGTERM was called.
201
+ # Does not work if ZSYS_SIGHANDLER is false and code does not call
202
+ # set interrupted on signal.
203
+ #
204
+ # @return [Boolean]
205
+ def self.is_interrupted()
206
+ result = ::CZMQ::FFI.zsys_is_interrupted()
207
+ result
208
+ end
209
+
210
+ # Set interrupted flag. This is done by default signal handler, however
211
+ # this can be handy for language bindings or cases without default
212
+ # signal handler.
213
+ #
214
+ # @return [void]
215
+ def self.set_interrupted()
216
+ result = ::CZMQ::FFI.zsys_set_interrupted()
217
+ result
218
+ end
219
+
200
220
  # Return 1 if file exists, else zero
201
221
  #
202
222
  # @param filename [String, #to_s, nil]
@@ -304,6 +324,22 @@ module CZMQ
304
324
  result
305
325
  end
306
326
 
327
+ # Format a string using printf formatting, returning a freshly allocated
328
+ # buffer. If there was insufficient memory, returns NULL. Free the returned
329
+ # string using zstr_free(). The hinted version allows to optimize by using
330
+ # a larger starting buffer size (known to/assumed by the developer) and so
331
+ # avoid reallocations.
332
+ #
333
+ # @param hint [Integer, #to_int, #to_i]
334
+ # @param format [String, #to_s, nil]
335
+ # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
336
+ # @return [::FFI::Pointer]
337
+ def self.sprintf_hint(hint, format, *args)
338
+ hint = Integer(hint)
339
+ result = ::CZMQ::FFI.zsys_sprintf_hint(hint, format, *args)
340
+ result
341
+ end
342
+
307
343
  # Format a string using printf formatting, returning a freshly allocated
308
344
  # buffer. If there was insufficient memory, returns NULL. Free the returned
309
345
  # string using zstr_free().
@@ -483,6 +519,52 @@ module CZMQ
483
519
  result
484
520
  end
485
521
 
522
+ # Configure the numeric prefix to each thread created for the internal
523
+ # context's thread pool. This option is only supported on Linux.
524
+ # If the environment variable ZSYS_THREAD_NAME_PREFIX is defined, that
525
+ # provides the default.
526
+ # Note that this method is valid only before any socket is created.
527
+ #
528
+ # @param prefix [Integer, #to_int, #to_i]
529
+ # @return [void]
530
+ def self.set_thread_name_prefix(prefix)
531
+ prefix = Integer(prefix)
532
+ result = ::CZMQ::FFI.zsys_set_thread_name_prefix(prefix)
533
+ result
534
+ end
535
+
536
+ # Return thread name prefix.
537
+ #
538
+ # @return [Integer]
539
+ def self.thread_name_prefix()
540
+ result = ::CZMQ::FFI.zsys_thread_name_prefix()
541
+ result
542
+ end
543
+
544
+ # Adds a specific CPU to the affinity list of the ZMQ context thread pool.
545
+ # This option is only supported on Linux.
546
+ # Note that this method is valid only before any socket is created.
547
+ #
548
+ # @param cpu [Integer, #to_int, #to_i]
549
+ # @return [void]
550
+ def self.thread_affinity_cpu_add(cpu)
551
+ cpu = Integer(cpu)
552
+ result = ::CZMQ::FFI.zsys_thread_affinity_cpu_add(cpu)
553
+ result
554
+ end
555
+
556
+ # Removes a specific CPU to the affinity list of the ZMQ context thread pool.
557
+ # This option is only supported on Linux.
558
+ # Note that this method is valid only before any socket is created.
559
+ #
560
+ # @param cpu [Integer, #to_int, #to_i]
561
+ # @return [void]
562
+ def self.thread_affinity_cpu_remove(cpu)
563
+ cpu = Integer(cpu)
564
+ result = ::CZMQ::FFI.zsys_thread_affinity_cpu_remove(cpu)
565
+ result
566
+ end
567
+
486
568
  # Configure the number of sockets that ZeroMQ will allow. The default
487
569
  # is 1024. The actual limit depends on the system, and you can query it
488
570
  # by using zsys_socket_limit (). A value of zero means "maximum".
@@ -523,6 +605,26 @@ module CZMQ
523
605
  result
524
606
  end
525
607
 
608
+ # Configure whether to use zero copy strategy in libzmq. If the environment
609
+ # variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
610
+ # Otherwise the default is 1.
611
+ #
612
+ # @param zero_copy [Integer, #to_int, #to_i]
613
+ # @return [void]
614
+ def self.set_zero_copy_recv(zero_copy)
615
+ zero_copy = Integer(zero_copy)
616
+ result = ::CZMQ::FFI.zsys_set_zero_copy_recv(zero_copy)
617
+ result
618
+ end
619
+
620
+ # Return ZMQ_ZERO_COPY_RECV option.
621
+ #
622
+ # @return [Integer]
623
+ def self.zero_copy_recv()
624
+ result = ::CZMQ::FFI.zsys_zero_copy_recv()
625
+ result
626
+ end
627
+
526
628
  # Configure the threshold value of filesystem object age per st_mtime
527
629
  # that should elapse until we consider that object "stable" at the
528
630
  # current zclock_time() moment.
@@ -633,6 +735,16 @@ module CZMQ
633
735
  result
634
736
  end
635
737
 
738
+ # Test if ipv6 is available on the system. Return true if available.
739
+ # The only way to reliably check is to actually open a socket and
740
+ # try to bind it. (ported from libzmq)
741
+ #
742
+ # @return [Boolean]
743
+ def self.ipv6_available()
744
+ result = ::CZMQ::FFI.zsys_ipv6_available()
745
+ result
746
+ end
747
+
636
748
  # Set network interface name to use for broadcasts, particularly zbeacon.
637
749
  # This lets the interface be configured for test environments where required.
638
750
  # For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
@@ -696,6 +808,46 @@ module CZMQ
696
808
  result
697
809
  end
698
810
 
811
+ # Set IPv4 multicast address to use for sending zbeacon messages. By default
812
+ # IPv4 multicast is NOT used. If the environment variable
813
+ # ZSYS_IPV4_MCAST_ADDRESS is set, use that as the default IPv4 multicast
814
+ # address. Calling this function or setting ZSYS_IPV4_MCAST_ADDRESS
815
+ # will enable IPv4 zbeacon messages.
816
+ #
817
+ # @param value [String, #to_s, nil]
818
+ # @return [void]
819
+ def self.set_ipv4_mcast_address(value)
820
+ result = ::CZMQ::FFI.zsys_set_ipv4_mcast_address(value)
821
+ result
822
+ end
823
+
824
+ # Return IPv4 multicast address to use for sending zbeacon, or NULL if none was
825
+ # set.
826
+ #
827
+ # @return [String]
828
+ def self.ipv4_mcast_address()
829
+ result = ::CZMQ::FFI.zsys_ipv4_mcast_address()
830
+ result
831
+ end
832
+
833
+ # Set multicast TTL default is 1
834
+ #
835
+ # @param value [Integer, #to_int, #to_i]
836
+ # @return [void]
837
+ def self.set_mcast_ttl(value)
838
+ value = Integer(value)
839
+ result = ::CZMQ::FFI.zsys_set_mcast_ttl(value)
840
+ result
841
+ end
842
+
843
+ # Get multicast TTL
844
+ #
845
+ # @return [Integer]
846
+ def self.mcast_ttl()
847
+ result = ::CZMQ::FFI.zsys_mcast_ttl()
848
+ result
849
+ end
850
+
699
851
  # Configure the automatic use of pre-allocated FDs when creating new sockets.
700
852
  # If 0 (default), nothing will happen. Else, when a new socket is bound, the
701
853
  # system API will be used to check if an existing pre-allocated FD with a
@@ -719,6 +871,70 @@ module CZMQ
719
871
  result
720
872
  end
721
873
 
874
+ # Print formatted string. Format is specified by variable names
875
+ # in Python-like format style
876
+ #
877
+ # "%(KEY)s=%(VALUE)s", KEY=key, VALUE=value
878
+ # become
879
+ # "key=value"
880
+ #
881
+ # Returns freshly allocated string or NULL in a case of error.
882
+ # Not enough memory, invalid format specifier, name not in args
883
+ #
884
+ # @param format [String, #to_s, nil]
885
+ # @param args [Zhash, #__ptr]
886
+ # @return [::FFI::AutoPointer]
887
+ def self.zprintf(format, args)
888
+ args = args.__ptr if args
889
+ result = ::CZMQ::FFI.zsys_zprintf(format, args)
890
+ result = ::FFI::AutoPointer.new(result, LibC.method(:free))
891
+ result
892
+ end
893
+
894
+ # Return error string for given format/args combination.
895
+ #
896
+ # @param format [String, #to_s, nil]
897
+ # @param args [Zhash, #__ptr]
898
+ # @return [::FFI::AutoPointer]
899
+ def self.zprintf_error(format, args)
900
+ args = args.__ptr if args
901
+ result = ::CZMQ::FFI.zsys_zprintf_error(format, args)
902
+ result = ::FFI::AutoPointer.new(result, LibC.method(:free))
903
+ result
904
+ end
905
+
906
+ # Print formatted string. Format is specified by variable names
907
+ # in Python-like format style
908
+ #
909
+ # "%(KEY)s=%(VALUE)s", KEY=key, VALUE=value
910
+ # become
911
+ # "key=value"
912
+ #
913
+ # Returns freshly allocated string or NULL in a case of error.
914
+ # Not enough memory, invalid format specifier, name not in args
915
+ #
916
+ # @param format [String, #to_s, nil]
917
+ # @param args [Zconfig, #__ptr]
918
+ # @return [::FFI::AutoPointer]
919
+ def self.zplprintf(format, args)
920
+ args = args.__ptr if args
921
+ result = ::CZMQ::FFI.zsys_zplprintf(format, args)
922
+ result = ::FFI::AutoPointer.new(result, LibC.method(:free))
923
+ result
924
+ end
925
+
926
+ # Return error string for given format/args combination.
927
+ #
928
+ # @param format [String, #to_s, nil]
929
+ # @param args [Zconfig, #__ptr]
930
+ # @return [::FFI::AutoPointer]
931
+ def self.zplprintf_error(format, args)
932
+ args = args.__ptr if args
933
+ result = ::CZMQ::FFI.zsys_zplprintf_error(format, args)
934
+ result = ::FFI::AutoPointer.new(result, LibC.method(:free))
935
+ result
936
+ end
937
+
722
938
  # Set log identity, which is a string that prefixes all log messages sent
723
939
  # by this process. The log identity defaults to the environment variable
724
940
  # ZSYS_LOGIDENT, if that is set.
@@ -0,0 +1,16 @@
1
+ module CZMQ
2
+ module FFI
3
+
4
+ # @return [Boolean] whether the CZMQ DRAFT API is available
5
+ #
6
+ def self.has_draft?
7
+ # NOTE: We use some function that is currently declared DRAFT. Another one
8
+ # might be needed in future versions.
9
+ zsock_new_server(nil)
10
+ true
11
+ rescue NotImplementedError, NoMethodError
12
+ false
13
+ end
14
+
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  module CZMQ
2
2
  module FFI
3
- GEM_VERSION = "0.14.0"
3
+ GEM_VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -5,8 +5,7 @@ module CZMQ::FFI::LibZMQ
5
5
 
6
6
  lib_name = 'libzmq'
7
7
  lib_dirs = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
8
- env_path = ENV['LIBZMQ_PATH']
9
- lib_dirs = [*env_path.split(':'), *lib_dirs] if env_path
8
+ lib_dirs = [*ENV['LIBZMQ_PATH'].split(':'), *lib_dirs] if ENV['LIBZMQ_PATH']
10
9
  lib_paths = lib_dirs.map { |path| "#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}" }
11
10
  ffi_lib lib_paths + [lib_name]
12
11
 
@@ -17,4 +16,32 @@ module CZMQ::FFI::LibZMQ
17
16
  attach_function :zmq_strerror, [:int], :string, **opts
18
17
  attach_function :zmq_errno, [], :int, **opts
19
18
  attach_function :zmq_version, [:pointer, :pointer, :pointer], :void, **opts
19
+ attach_function :zmq_has, [:pointer], :int, **opts
20
+
21
+
22
+ # get ZMQ version
23
+ ptrs = Array.new(3) { ::FFI::MemoryPointer.new(:int) }
24
+ zmq_version(*ptrs)
25
+ VERSION = ptrs.map { |n| n.get_int(0) }.join(".").freeze
26
+
27
+
28
+ # @param capability [Symbol, String] the name of the capability
29
+ # @return [Boolean] whether the capability is supported
30
+ #
31
+ def self.has?(capability)
32
+ ptr = FFI::MemoryPointer.from_string(capability.to_s.downcase)
33
+ zmq_has(ptr) == 1
34
+ end
35
+
36
+
37
+ # @return [Boolean] whether the DRAFT API is supported
38
+ def self.has_draft?
39
+ has? :draft
40
+ end
41
+
42
+
43
+ # @return [Boolean] whether CURVE is supported
44
+ def self.has_curve?
45
+ has? :curve
46
+ end
20
47
  end
@@ -1,19 +1,9 @@
1
- require_relative "gem_version"
2
- require_relative "libzmq"
3
-
4
1
  module CZMQ
5
2
  module FFI
6
3
  # CZMQ library version
7
4
  CZMQ_VERSION = VERSION
8
5
 
9
- # @deprecated Use {CZMQ_VERSION} instead.
10
- LIBRARY_VERSION = CZMQ_VERSION
11
-
12
6
  # ZMQ library version
13
- ZMQ_VERSION = begin
14
- version = Array.new(3) { ::FFI::MemoryPointer.new(:int) }
15
- LibZMQ.zmq_version(*version)
16
- version.map { |n| n.get_int(0) }.join(".")
17
- end
7
+ ZMQ_VERSION = LibZMQ::VERSION
18
8
  end
19
9
  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.14.0
4
+ version: 1.0.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: 2017-11-27 00:00:00.000000000 Z
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -16,56 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.9.10
19
+ version: '1.11'
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: 1.9.10
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.10'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.10'
26
+ version: '1.11'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - "~>"
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: '10.0'
33
+ version: '0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - "~>"
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: '10.0'
40
+ version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ">="
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '0'
47
+ version: '3.10'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ">="
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '0'
54
+ version: '3.10'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: minitest
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -110,11 +96,18 @@ files:
110
96
  - lib/czmq-ffi-gen/czmq/ffi/zframe.rb
111
97
  - lib/czmq-ffi-gen/czmq/ffi/zhash.rb
112
98
  - lib/czmq-ffi-gen/czmq/ffi/zhashx.rb
99
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb
100
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_request.rb
101
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_response.rb
102
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_server.rb
103
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_server_connection.rb
104
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_server_options.rb
113
105
  - lib/czmq-ffi-gen/czmq/ffi/ziflist.rb
114
106
  - lib/czmq-ffi-gen/czmq/ffi/zlist.rb
115
107
  - lib/czmq-ffi-gen/czmq/ffi/zlistx.rb
116
108
  - lib/czmq-ffi-gen/czmq/ffi/zloop.rb
117
109
  - lib/czmq-ffi-gen/czmq/ffi/zmsg.rb
110
+ - lib/czmq-ffi-gen/czmq/ffi/zosc.rb
118
111
  - lib/czmq-ffi-gen/czmq/ffi/zpoller.rb
119
112
  - lib/czmq-ffi-gen/czmq/ffi/zproc.rb
120
113
  - lib/czmq-ffi-gen/czmq/ffi/zsock.rb
@@ -123,17 +116,20 @@ files:
123
116
  - lib/czmq-ffi-gen/czmq/ffi/ztimerset.rb
124
117
  - lib/czmq-ffi-gen/czmq/ffi/ztrie.rb
125
118
  - lib/czmq-ffi-gen/czmq/ffi/zuuid.rb
119
+ - lib/czmq-ffi-gen/czmq_ffi_extensions.rb
126
120
  - lib/czmq-ffi-gen/errors.rb
127
121
  - lib/czmq-ffi-gen/gem_version.rb
128
- - lib/czmq-ffi-gen/legacy.rb
129
122
  - lib/czmq-ffi-gen/libzmq.rb
130
123
  - lib/czmq-ffi-gen/signals.rb
131
124
  - lib/czmq-ffi-gen/vendor.rb
132
125
  - lib/czmq-ffi-gen/versions.rb
133
- homepage: https://github.com/paddor/czmq-ffi-gen
126
+ homepage: https://rubygems.org/gems/czmq-ffi-gen
134
127
  licenses:
135
128
  - ISC
136
- metadata: {}
129
+ metadata:
130
+ homepage_uri: https://rubygems.org/gems/czmq-ffi-gen
131
+ source_code_uri: https://github.com/paddor/czmq-ffi-gen
132
+ changelog_uri: https://github.com/paddor/czmq-ffi-gen/blob/master/CHANGES.md
137
133
  post_install_message:
138
134
  rdoc_options: []
139
135
  require_paths:
@@ -142,16 +138,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
138
  requirements:
143
139
  - - ">="
144
140
  - !ruby/object:Gem::Version
145
- version: '0'
141
+ version: 2.5.0
146
142
  required_rubygems_version: !ruby/object:Gem::Requirement
147
143
  requirements:
148
144
  - - ">="
149
145
  - !ruby/object:Gem::Version
150
146
  version: '0'
151
147
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.6.8
148
+ rubygems_version: 3.2.4
154
149
  signing_key:
155
150
  specification_version: 4
156
- summary: The low-level Ruby binding for CZMQ (generated using zproject)
151
+ summary: Generated low-level Ruby binding for CZMQ
157
152
  test_files: []