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

Embed the library (Rust / Python / Node)

The core engine is a Rust library, and 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. Behaviour and reliability match the Rust engine regardless of which language calls in.

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

The config-first workflow

The natural way to embed the library is to design the route as config, then load that exact config from your code. Design and test a route in the desktop UI (or hand-write the YAML), export the JSON/YAML, and load it — the running route behaves identically to the --config CLI form.

Constructor names are kept aligned across languages (Python snake_case, Node 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: 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.

Rust

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.

The MessageConsumer and MessagePublisher traits (in mq_bridge::traits) are the core abstractions. See the Rust docs on docs.rs for the full API.

See also