Skip to main content

backlog_matches_server

Function backlog_matches_server 

Source
pub async fn backlog_matches_server<B, MkBroker, Pub, MkPub>(
    make_broker: MkBroker,
    make_publisher: MkPub,
)
where B: InProcess, B::Connected: Subscribe, MkBroker: Fn() -> B, Pub: Publisher, MkPub: Fn(&Connected<B>) -> Pub,
Expand description

Checks that the in-process transport’s TestableBroker::backlog declaration is what the real server does with a message published before a subscription opens.

run_suite holds the in-process transport to its declaration; this holds the declaration to the server. On each transport, a fresh subject gets one message through the publisher make_publisher builds, then a subscription opened by name, then a second message. Under Backlog::Delivered the subscription receives both, the earlier one first; under Backlog::Missed it receives the later one only. The declaration is read off the in-process connected form, configured by make_broker as the server’s is. A server may refuse the first publish (a name nothing declared yet); the in-process transport must refuse it too, and on both the subscription must still open and receive the later message alone.

It connects with Broker::connect, so run it where the broker’s live suite runs.

§Examples

use ruststream::conformance::in_process;
use ruststream::memory::MemoryBroker;

in_process::backlog_matches_server(MemoryBroker::new, |connected| connected.publisher()).await;

§Panics

Panics when either transport delivers the earlier message against the declaration, when a publish or the subscription fails, or when the later message does not arrive.