Skip to main content

Bindable

A handler consumes from one broker and publishes through another, named by a token the target broker mints before registration.

bindable() wraps the target broker in a Bindable. bind(policy) mints a Bound token, before any scope is built. The token is a publish policy: it goes where a policy goes, .out_reply(token) for a reply and .out(marker, token) for a slot. The wrapper is what with_broker registers for the target, and startup pairs the token with that broker once it connects. The example labels its two scopes with with_broker_labeled, so a test tells them apart with broker_named. A task beside the service gets a live publisher from a token with RunningApp::publisher, as on the HTTP page.

Example​

fn app() -> impl App {
// The target broker is wrapped first, so its token exists before either scope is built.
let west = MemoryBroker::new().bindable();
let to_west = west.bind(Publish);
RustStream::new(AppInfo::new("bridge", "0.1.0"))
.with_broker_labeled("east", MemoryBroker::new(), |b| {
// Consumed in the east, answered in the west.
b.include(mirror).out_reply(to_west);
})
.with_broker_labeled("west", west, |b| {
b.include(record);
})
}