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
- VERSION =
Ruby binding version.
"0.1.1"
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 before the shared runtime starts.
-
.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.
140 141 142 |
# File 'lib/omq/rs/socket.rb', line 140 def curve_keypair Native.curve_keypair end |
.curve_public(secret_key) ⇒ String
Derives CurveZMQ public key from a secret key.
149 150 151 |
# File 'lib/omq/rs/socket.rb', line 149 def curve_public(secret_key) Native.curve_public(secret_key) end |
.has(feature) ⇒ Boolean
Reports whether binding was compiled with a feature.
133 134 135 |
# File 'lib/omq/rs/socket.rb', line 133 def has(feature) Native.has(feature.to_s) end |
.io_threads ⇒ Integer
Returns number of OMQ.rs IO threads.
96 97 98 |
# File 'lib/omq/rs/socket.rb', line 96 def io_threads Native.io_threads end |
.io_threads=(count) ⇒ Integer
Set this before materializing any socket. It does not resize a running runtime.
Sets number of OMQ.rs IO threads before the shared runtime starts.
107 108 109 110 111 112 |
# File 'lib/omq/rs/socket.rb', line 107 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.
120 121 122 123 124 125 126 127 |
# File 'lib/omq/rs/socket.rb', line 120 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.
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/omq/rs/socket.rb', line 158 def wrap_curve_authenticator(authenticator) proc do |peer| authenticator.call( MechanismPeerInfo.new( public_key: peer.fetch(:public_key), identity: peer[:identity], ), ) end end |