Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Language bindings API

The core engine is a Rust library, but the same engine ships as native bindings for Python and Node.js. The Tokio runtime, broker I/O, routing, and batching all stay in Rust; the binding is a thin layer for handlers and configuration.

LanguagePackageInstall
Rustmq-bridgecargo add mq-bridge
Pythonmq-bridge-pypip install mq-bridge-py
Node.jsmq-bridgenpm install mq-bridge

The core of the library are the MessageConsumer and MessagePublisher traits, found in mq_bridge::traits.

Config loaders

Constructor names are kept aligned across languages, so a config loader reads the same in either binding (Python uses snake_case, Node uses camelCase):

PurposePythonNode.js
Load a route from a YAML/JSON fileRoute.from_fileRoute.fromFile
Load from an in-memory YAML/JSON stringRoute.from_strRoute.fromStr
Load from a parsed dict / JS objectRoute.from_configRoute.fromConfig
Build a publisher endpointthe matching Publisher.*the matching Publisher.*

The name argument is optional in both: pass it to select one entry from a routes:/publishers: document, or omit it to treat the config as a single bare route/endpoint body.

This is the natural companion to the configuration-first workflow: design and test a route in the UI, export the JSON/YAML, then load that exact config from your code. See the Embed the library tutorial for full examples in each language.

Rust API surface

The Rust crate exposes the full engine. The main types:

  • Route::new(input, output) — a pipeline from one endpoint to one endpoint, with .with_batch_size(n), .with_handler(h), .add_handler(kind, f), .deploy(name) / .run().
  • Endpoint — protocol adapters (Endpoint::new_memory, Endpoint::null, …) plus the serde-configured variants.
  • Publisher::new(endpoint) — publish into a route’s input or any endpoint.
  • Handlers: CommandHandler (1-to-1/1-to-0), EventHandler (terminal 1-to-N), and TypeHandler (dispatches on the kind metadata field, deserializing payloads).
  • CanonicalMessage — the unified message type all handlers work with; msg!(&value, "kind") builds one with a kind.

See Core concepts and Learn the architecture for the handler model, and the Rust docs on docs.rs for the full API.

Notes

  • The Python binding holds up under load on the third-party http-arena.com requests-per-second HTTP benchmark (a live leaderboard — rankings shift over time).
  • A binding is a thin layer: routing, batching, and broker I/O stay in Rust regardless of which language calls in, so behaviour and reliability match the Rust engine.