czmq-ffi-gen 0.15.0 → 0.16.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.
@@ -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]
@@ -324,6 +324,22 @@ module CZMQ
324
324
  result
325
325
  end
326
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
+
327
343
  # Format a string using printf formatting, returning a freshly allocated
328
344
  # buffer. If there was insufficient memory, returns NULL. Free the returned
329
345
  # string using zstr_free().
@@ -503,6 +519,52 @@ module CZMQ
503
519
  result
504
520
  end
505
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
+
506
568
  # Configure the number of sockets that ZeroMQ will allow. The default
507
569
  # is 1024. The actual limit depends on the system, and you can query it
508
570
  # by using zsys_socket_limit (). A value of zero means "maximum".
@@ -543,6 +605,26 @@ module CZMQ
543
605
  result
544
606
  end
545
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
+
546
628
  # Configure the threshold value of filesystem object age per st_mtime
547
629
  # that should elapse until we consider that object "stable" at the
548
630
  # current zclock_time() moment.
@@ -739,6 +821,70 @@ module CZMQ
739
821
  result
740
822
  end
741
823
 
824
+ # Print formatted string. Format is specified by variable names
825
+ # in Python-like format style
826
+ #
827
+ # "%(KEY)s=%(VALUE)s", KEY=key, VALUE=value
828
+ # become
829
+ # "key=value"
830
+ #
831
+ # Returns freshly allocated string or NULL in a case of error.
832
+ # Not enough memory, invalid format specifier, name not in args
833
+ #
834
+ # @param format [String, #to_s, nil]
835
+ # @param args [Zhash, #__ptr]
836
+ # @return [::FFI::AutoPointer]
837
+ def self.zprintf(format, args)
838
+ args = args.__ptr if args
839
+ result = ::CZMQ::FFI.zsys_zprintf(format, args)
840
+ result = ::FFI::AutoPointer.new(result, LibC.method(:free))
841
+ result
842
+ end
843
+
844
+ # Return error string for given format/args combination.
845
+ #
846
+ # @param format [String, #to_s, nil]
847
+ # @param args [Zhash, #__ptr]
848
+ # @return [::FFI::AutoPointer]
849
+ def self.zprintf_error(format, args)
850
+ args = args.__ptr if args
851
+ result = ::CZMQ::FFI.zsys_zprintf_error(format, args)
852
+ result = ::FFI::AutoPointer.new(result, LibC.method(:free))
853
+ result
854
+ end
855
+
856
+ # Print formatted string. Format is specified by variable names
857
+ # in Python-like format style
858
+ #
859
+ # "%(KEY)s=%(VALUE)s", KEY=key, VALUE=value
860
+ # become
861
+ # "key=value"
862
+ #
863
+ # Returns freshly allocated string or NULL in a case of error.
864
+ # Not enough memory, invalid format specifier, name not in args
865
+ #
866
+ # @param format [String, #to_s, nil]
867
+ # @param args [Zconfig, #__ptr]
868
+ # @return [::FFI::AutoPointer]
869
+ def self.zplprintf(format, args)
870
+ args = args.__ptr if args
871
+ result = ::CZMQ::FFI.zsys_zplprintf(format, args)
872
+ result = ::FFI::AutoPointer.new(result, LibC.method(:free))
873
+ result
874
+ end
875
+
876
+ # Return error string for given format/args combination.
877
+ #
878
+ # @param format [String, #to_s, nil]
879
+ # @param args [Zconfig, #__ptr]
880
+ # @return [::FFI::AutoPointer]
881
+ def self.zplprintf_error(format, args)
882
+ args = args.__ptr if args
883
+ result = ::CZMQ::FFI.zsys_zplprintf_error(format, args)
884
+ result = ::FFI::AutoPointer.new(result, LibC.method(:free))
885
+ result
886
+ end
887
+
742
888
  # Set log identity, which is a string that prefixes all log messages sent
743
889
  # by this process. The log identity defaults to the environment variable
744
890
  # 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.15.0"
3
+ GEM_VERSION = "0.16.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,6 +1,3 @@
1
- require_relative "gem_version"
2
- require_relative "libzmq"
3
-
4
1
  module CZMQ
5
2
  module FFI
6
3
  # CZMQ library version
@@ -10,10 +7,6 @@ module CZMQ
10
7
  LIBRARY_VERSION = CZMQ_VERSION
11
8
 
12
9
  # 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
10
+ ZMQ_VERSION = LibZMQ::VERSION
18
11
  end
19
12
  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.15.0
4
+ version: 0.16.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: 2018-03-04 00:00:00.000000000 Z
11
+ date: 2019-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -16,56 +16,56 @@ 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
26
+ version: '1.11'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.10'
33
+ version: '2.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: '1.10'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3.9'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '3.9'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -110,6 +110,12 @@ files:
110
110
  - lib/czmq-ffi-gen/czmq/ffi/zframe.rb
111
111
  - lib/czmq-ffi-gen/czmq/ffi/zhash.rb
112
112
  - lib/czmq-ffi-gen/czmq/ffi/zhashx.rb
113
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb
114
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_request.rb
115
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_response.rb
116
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_server.rb
117
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_server_connection.rb
118
+ - lib/czmq-ffi-gen/czmq/ffi/zhttp_server_options.rb
113
119
  - lib/czmq-ffi-gen/czmq/ffi/ziflist.rb
114
120
  - lib/czmq-ffi-gen/czmq/ffi/zlist.rb
115
121
  - lib/czmq-ffi-gen/czmq/ffi/zlistx.rb
@@ -123,9 +129,9 @@ files:
123
129
  - lib/czmq-ffi-gen/czmq/ffi/ztimerset.rb
124
130
  - lib/czmq-ffi-gen/czmq/ffi/ztrie.rb
125
131
  - lib/czmq-ffi-gen/czmq/ffi/zuuid.rb
132
+ - lib/czmq-ffi-gen/czmq_ffi_extensions.rb
126
133
  - lib/czmq-ffi-gen/errors.rb
127
134
  - lib/czmq-ffi-gen/gem_version.rb
128
- - lib/czmq-ffi-gen/legacy.rb
129
135
  - lib/czmq-ffi-gen/libzmq.rb
130
136
  - lib/czmq-ffi-gen/signals.rb
131
137
  - lib/czmq-ffi-gen/vendor.rb
@@ -149,8 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
155
  - !ruby/object:Gem::Version
150
156
  version: '0'
151
157
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.6.8
158
+ rubygems_version: 3.0.3
154
159
  signing_key:
155
160
  specification_version: 4
156
161
  summary: The low-level Ruby binding for CZMQ (generated using zproject)
@@ -1,16 +0,0 @@
1
- module CZMQ::FFI
2
- if available?
3
- opts = {
4
- blocking: true # only necessary on MRI to deal with the GIL.
5
- }
6
-
7
- ##
8
- # NOTE: this is to support the current stable release, CZMQ 3.0.2
9
- #
10
- # attach zsys_has_curve (as zproc_has_curve), if zproc_has_curve isn't
11
- # available
12
- unless methods.include? :zproc_has_curve
13
- attach_function :zproc_has_curve, :zsys_has_curve, [], :bool, **opts
14
- end
15
- end
16
- end