omq-backend-rust

CI Gem Version License: ISC Ruby

Rust-backed engine for OMQ. Same socket API, but networking runs on a Tokio runtime inside a native extension compiled via rb_sys.

Install

Requires a Rust toolchain (stable) at gem install time.

# Gemfile
gem "omq-backend-rust"
gem install omq-backend-rust

Usage

require "omq"
require "omq/rust"

Async do
  push = OMQ::PUSH.new(backend: :rust)
  pull = OMQ::PULL.new(backend: :rust)

  port = pull.bind("tcp://127.0.0.1:0").port
  push.connect("tcp://127.0.0.1:#{port}")
  push.peer_connected.wait

  push << "hello from Rust"
  p pull.receive  # => ["hello from Rust"]
ensure
  push&.close
  pull&.close
end

The :rust backend is fully interoperable with the default :ruby backend. Mix backends freely within the same process.

Supported socket types

All standard and draft ZMTP socket types: REQ/REP, PUB/SUB, PUSH/PULL, DEALER/ROUTER, XPUB/XSUB, PAIR, CLIENT/SERVER, RADIO/DISH, SCATTER/GATHER, CHANNEL.

Security mechanisms

  • NULL (default)
  • CURVE (CurveZMQ, via Nuckle)

Development

OMQ_DEV=1 bundle install
OMQ_DEV=1 bundle exec rake

License

ISC