elbus 0.1.9

Local and network IPC bus
Documentation

elbus - Rust-native IPC broker

https://elbus.bma.ai/

What is elbus

elbus is a rust-native IPC broker, written in Rust/Tokio, inspired by zeromq and nanomsg. elbus is fast, flexible and very easy to use.

The library can be embedded in any Rust project or be used as a standalone server.

Documentation

Available at https://elbus.readthedocs.io/

Inter-process communication

The following communication patterns are supported out-of-the-box:

  • one-to-one messages
  • one-to-many messages
  • pub/sub

The following channels are supported:

  • async channels between threads/futures (Rust only)
  • UNIX sockets (local machine)
  • TCP sockets

In addition to Rust, elbus has also bindings for the following languages:

Rust crate: https://crates.io/crates/elbus

Client registration

A client should register with a name "group.subgroup.client" (subgroups are optional). The client's name can not start with dot (".", reserved for internal broker clients) if registered via IPC.

The client's name must be unique, otherwise the broker refuses the registration.

Broadcasts

Broadcast messages are sent to multiple clients at once. Use "?" for any part of the path, "*" as the ending for wildcards. E.g.:

"?.test.*" - the message is be sent to clients "g1.test.client1", "g1.test.subgroup.client2" etc.

Topics

Use MQTT-format for topics: "+" for any part of the path, "#" as the ending for wildcards. E.g. a client, subscribed to "+/topic/#" receives publications sent to "x/topic/event", "x/topic/sub/event" etc.

RPC layer

An optional included RPC layer for one-to-one messaging can be used. The layer is similar to JSON RPC but is optimized for byte communications.

Security and reliability model

elbus has ZERO security model in favor of simplicity and speed. Also, elbus is not designed to work via unstable connections, all clients should be connected either from the local machine or using high-speed reliable local network communications.

If you need a pub/sub server for a wide area network, try PSRT.

Examples

See examples folder.

Build a stand-alone server

cargo build --features server,rpc

The "rpc" feature is optional. When enabled for the server, it allows to initialize the default broker RPC API, spawn fifo servers, send broker announcements etc.

Some numbers

CPU: AMD Ryzen 9 5950X

Broker: 8 workers, clients: 10, payload size: 500 bytes, local IPC (single unix socket), totals:

elbus /tmp/elbus.sock benchmark -w10 --payload-size 500
stage iters/s
rpc.call 358_513
rpc.call+handle 187_043
rpc.call0 446_663
send+recv.qos.no 478_062
send+recv.qos.processed 375_817
send.qos.no 3_019_431
send.qos.processed 446_416

About the authors

Bohemia Automation / Altertech is a group of companies with 15+ years of experience in the enterprise automation and industrial IoT. Our setups include power plants, factories and urban infrastructure. Largest of them have 1M+ sensors and controlled devices and the bar raises upper and upper every day.