跳到主要内容
本页尚未翻译

下面显示的是英文原文。

AsyncAPI

With the asyncapi feature each broker is a server of the generated document, and each FileStream channel carries its stream key in the x-ruststream-file extension.

The core builds the AsyncAPI document from the app, before anything connects. This crate adds what it knows about the two transports. A server reports the path of the stream file, or the protocol name stdio. A channel on a stream file reports the stream key behind it.

The specification lists no binding for a file transport or for stdio, and its protocol keys are a closed list. So the stream key travels in this crate's own extension, x-ruststream-file, which carries no binding version. Everything comes from the service's own declarations: the brokers, the descriptors and the destinations the mount sites resolved. The binary #[ruststream::app] writes prints the document with asyncapi gen.

Example​

The dependency line:

ruststream-sea-file = { version = "0.7", features = ["asyncapi"] }

The service registers its stream file under the label file and its pipeline under pipe, the keys of their servers in the document. cargo run --example sea_asyncapi --features asyncapi -- asyncapi gen prints the document.

#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("orders", "1.0.0"))
.with_broker_labeled("file", file_broker(), |b| {
b.include(record).out_reply(FilePublish);
})
.with_broker_labeled("pipe", stdio_broker(), |b| {
b.include(tee)
.out_reply(StdioPublish)
.out_retry(StdioPublish)
.to("lines.retry");
})
}