Module: OMQ::Rust
- Defined in:
- lib/omq/rs/socket.rb,
lib/omq/rs/version.rb
Overview
OMQ.rs-backed Ruby socket API.
Defined Under Namespace
Classes: CHANNEL, CLIENT, DEALER, DISH, GATHER, MechanismPeerInfo, Monitor, PAIR, PEER, PUB, PULL, PUSH, RADIO, REP, REQ, ROUTER, SCATTER, SERVER, STREAM, SUB, Socket, XPUB, XSUB
Constant Summary collapse
- SOCKET_TYPES =
Supported socket type names.
%i[ req rep pub sub xpub xsub push pull dealer router pair stream client server radio dish scatter gather channel peer ].freeze
- ROUTED_TYPES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%i[server].freeze
- SINGLE_FRAME_TYPES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%i[client server scatter gather channel].freeze
- VERSION =
Ruby binding version.
"0.1.0"
Class Method Summary collapse
-
.curve_keypair ⇒ Array<String>
Generates a CurveZMQ keypair.
-
.curve_public(secret_key) ⇒ String
Derives CurveZMQ public key from a secret key.
-
.has(feature) ⇒ Boolean
Reports whether binding was compiled with a feature.
-
.io_threads ⇒ Integer
Returns number of OMQ.rs IO threads.
-
.io_threads=(count) ⇒ Integer
Sets number of OMQ.rs IO threads used by subsequently created sockets.
-
.socket(socket_type, **options) ⇒ Socket
Creates a socket for a named OMQ pattern.
-
.wrap_curve_authenticator(authenticator) ⇒ Proc
private
Adapts a public CURVE authenticator to native peer metadata.
Class Method Details
.curve_keypair ⇒ Array<String>
Generates a CurveZMQ keypair.
75 76 77 |
# File 'lib/omq/rs/socket.rb', line 75 def curve_keypair Native.curve_keypair end |
.curve_public(secret_key) ⇒ String
Derives CurveZMQ public key from a secret key.
84 85 86 |
# File 'lib/omq/rs/socket.rb', line 84 def curve_public(secret_key) Native.curve_public(secret_key) end |
.has(feature) ⇒ Boolean
Reports whether binding was compiled with a feature.
68 69 70 |
# File 'lib/omq/rs/socket.rb', line 68 def has(feature) Native.has(feature.to_s) end |
.io_threads ⇒ Integer
Returns number of OMQ.rs IO threads.
33 34 35 |
# File 'lib/omq/rs/socket.rb', line 33 def io_threads Native.io_threads end |
.io_threads=(count) ⇒ Integer
Sets number of OMQ.rs IO threads used by subsequently created sockets.
42 43 44 45 46 47 |
# File 'lib/omq/rs/socket.rb', line 42 def io_threads=(count) count = Integer(count) raise ArgumentError, "io_threads must be positive" unless count.positive? Native.send(:io_threads=, count) end |
.socket(socket_type, **options) ⇒ Socket
Creates a socket for a named OMQ pattern.
55 56 57 58 59 60 61 62 |
# File 'lib/omq/rs/socket.rb', line 55 def socket(socket_type, **) type = socket_type.to_s.downcase.to_sym unless SOCKET_TYPES.include?(type) raise ArgumentError, "unknown socket type: #{socket_type}" end const_get(type.to_s.upcase).new(**) end |
.wrap_curve_authenticator(authenticator) ⇒ Proc
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adapts a public CURVE authenticator to native peer metadata.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/omq/rs/socket.rb', line 93 def wrap_curve_authenticator(authenticator) proc do |peer| authenticator.call( MechanismPeerInfo.new( public_key: peer.fetch(:public_key), identity: peer[:identity], ), ) end end |