Expand description
The lifecycle contract past the happy path: what a shutdown must finish, and what every handle that outlives the connection must answer.
harness::lifecycle runs the ladder every broker gets with no
code of its own. The two checks here need something only the broker can say, so a broker crate
calls each of them itself:
shutdown_flushestakes the broker’sBackloganswer: whether a message waits for a subscription that opens later. It acknowledges a delivery, publishes a message and shuts down at once, then looks from another connection: the acknowledgement must hold and the message must arrive.shared_handle_closesneeds a connected form that isClone, the shareable handle some brokers hand out. A clone kept past the shutdown of the original must error, never reach a connection of its own.
§Examples
use ruststream::conformance::lifecycle;
use ruststream::memory::{MemoryBroker, MemorySource};
use ruststream::testing::Backlog;
// Every broker the factory builds reaches the same bus, the way two connections reach one
// server.
let bus = MemoryBroker::new();
lifecycle::shutdown_flushes(
move || bus.clone(),
|name| MemorySource::new(name),
|connected| connected.publisher(),
Backlog::Missed,
)
.await;
lifecycle::shared_handle_closes(
MemoryBroker::new,
|name| MemorySource::new(name),
|connected| connected.publisher(),
)
.await;Functions§
- shared_
handle_ closes - Verifies a clone of a shareable connected form closes with the original.
- shutdown_
flushes - Verifies a shutdown finishes what was handed to the broker before it: an acknowledgement and a
publish made right before
shutdown, with no wait in between.