Skip to main content

seeking_unknown_position

Function seeking_unknown_position 

Source
pub async fn seeking_unknown_position<B, MkBroker, Src, MkSrc, Pub, MkPub, MkUnknown>(
    make_broker: MkBroker,
    make_source: MkSrc,
    make_publisher: MkPub,
    make_unknown: MkUnknown,
)
where B: Broker, MkBroker: Fn() -> B, Src: SubscriptionSource<Connected<B>> + Send, Src::Subscriber: Seekable + Send, MkSrc: Fn(&str) -> Src, Pub: Publisher, MkPub: Fn(&Connected<B>) -> Pub, MkUnknown: Fn(&str) -> <<Src::Subscriber as Seekable>::Seeker as Seeker>::Position,
Expand description

Verifies that a seek to a position the subscription’s log does not hold is refused.

The suite publishes three messages to a fresh subject and drains them, then seeks to the position make_unknown builds for that subject: one the log cannot hold after those three publishes, such as a position the broker’s retention has already evicted or one on a partition or shard the subject does not have. The seek must return an error, and the subscription must not move: its next delivery is the next publish, not a replay from wherever the broker fell back to. A broker that ends the subscription with the refusal passes as well. An error on the stream is not its end: the suite reads on, and the next delivery must still be the next publish.

A broker that answers such a seek by waiting at that position (a position past the tip) passes make_unknown a position of the other kinds.

§Examples

The in-memory broker keeps two messages here, so after three publishes the first one’s position is evicted.

use ruststream::conformance::capabilities;
use ruststream::memory::{MemoryBroker, MemoryPosition, MemorySource, Retention};
use ruststream::nonzero;

capabilities::seeking_unknown_position(
    || MemoryBroker::retaining(Retention::Messages(nonzero!(2))),
    |name| MemorySource::new(name),
    |broker| broker.publisher(),
    |_subject| MemoryPosition::sequence(0),
)
.await;

§Panics

Panics with a descriptive message if any step violates the contract.