Skip to main content

Bindings

With the asyncapi feature the generated document speaks googlepubsub: the server's host and the ordering key a mount site fixed.

The core builds the AsyncAPI document from the app, before anything connects. This crate adds what it knows about Pub/Sub to the parts the core writes. A server reports the host clients dial, under the protocol googlepubsub. A message carries the specification's googlepubsub binding, version 0.2.0, where its mount site fixed an ordering key. The channels are the subscriptions the service reads and the topics it publishes to.

Everything comes from the service's own declarations: the broker and the publish policies. The document is published and shared, so no part of it carries a credential. The binary #[ruststream::app] writes prints the document with asyncapi gen.

Example​

The dependency line:

ruststream-gcp-pubsub = { version = "0.7", features = ["asyncapi"] }

The service registers its broker under the label pubsub, the key of its server in the document. cargo run --example pubsub_asyncapi --features asyncapi -- asyncapi gen prints the document.

fn service(broker: PubSubBroker) -> impl App<State = ()> {
RustStream::new(AppInfo::new("orders", "1.0.0")).with_broker_labeled("pubsub", broker, |b| {
// Every receipt goes out under one key, so the document states it.
b.include(receipt)
.out_reply(Publish::default().ordering_key("receipts"));
})
}

#[ruststream::app]
fn app() -> impl App<State = ()> {
service(broker())
}