pub trait DescribeServer: Broker {
// Required method
fn describe_server(&self) -> ServerSpec;
}Expand description
A broker that describes itself as an AsyncAPI server.
Broker crates implement this so their connection coordinates land in the generated AsyncAPI
document and the broker carries a stable identity when registered with
with_broker_labeled; it can also be wired on
manually with RustStream::server. A broker without a
network address (the in-memory broker) describes itself with
ServerSpec::in_process, so it still gets a label / identity for multi-broker routing.
§The host is a coordinate, not the configuration
A description carries the host and port clients connect to, and nothing else the broker was configured with. Credentials in particular never appear in it: the document is generated to be published and shared, so a password that reaches it has left the service.
A broker configured from a URL therefore describes itself with
ServerSpec::from_url, which drops the userinfo, rather than trimming the scheme off the URL
and passing the rest to ServerSpec::new. A broker that configures several addresses joins
them from ServerSpec::host_from_url.
§Examples
use ruststream::{Broker, ConnectedBroker, DescribeServer, ServerSpec};
impl DescribeServer for AmqpBroker {
fn describe_server(&self) -> ServerSpec {
// `amqp://svc:secret@broker:5672/prod` is described as `broker:5672`.
ServerSpec::from_url(&self.url, "amqp")
}
}Required Methods§
Sourcefn describe_server(&self) -> ServerSpec
fn describe_server(&self) -> ServerSpec
Returns the server coordinates for this broker.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".