ruststream-pulsar connects a RustStream service to Apache Pulsar over the
pulsar client maintained by StreamNative. Handlers, routing,
codecs and middleware come from the framework; this crate is the transport.
Features
- Subscription types as an enum: exclusive, shared, failover and key-shared.
- Retry caps as Pulsar's own dead-letter policy, so the client counts redeliveries and moves a spent message itself.
- Validated topic names, checked when the descriptor is built.
- Multi-topic and pattern subscriptions, including topics created later.
- Start positions and repositioning:
start_at(..)on every startup, and a handler moves its subscription by message id or timestamp. - Batches assembled on the client.
- Key sharing: the partition key is a per-message setting that keyed routing and
KeySharedsubscriptions order by. - Plain Pulsar messages: headers ride message properties.
- AsyncAPI with the specification's
pulsarbinding, behind theasyncapifeature. - Tests run the production app:
TestApp::start(app())connectsPulsarBrokerin process, with no server, andTestApp::start_live(app())runs the same test against a running Pulsar.
Install
[]
= { = "0.7", = ["macros", "json"] }
= "0.7"
= { = "1", = ["derive"] }
[]
= { = "0.7", = ["testing"] }
Building requires protoc on the path.
Write a service
use Duration;
use *;
use ;
async
#[ruststream::app] generates main, so the binary understands run and asyncapi gen.
Test it
TestApp runs the app main runs, with PulsarBroker connected in process and no server.
use TestApp;
let tb = start.await?;
// `publish` returns once the handlers it woke have settled.
tb.
.message
.to
.publish
.await?;
tb.
.subscriber
.assert_called_once
.settled;
tb.
.
.assert_called_once
.with;
Documentation
- Getting started - installation and a first service against a local Pulsar.
- Guides - topics and subscriptions, subscription types and ordering, acknowledgement, retries, replay, publishing, testing and a production cluster.
- Components - one page per part of the crate: the broker, subscriptions, settlement, positions, publishing, the AsyncAPI bindings and testing.
- Architecture - how the crate sits between the
pulsarclient and the runtime. - Benchmarks - what the crate costs over the raw client.
- API reference - every item on docs.rs.
- The framework: https://powersemmi.github.io/ruststream/latest/
Minimum supported Rust version
The MSRV is 1.95, edition 2024.
Contributing
See CONTRIBUTING.md.
License
Licensed under the Apache-2.0 license.