Skip to main content

SendWriteGroupStore

Trait SendWriteGroupStore 

pub trait SendWriteGroupStore: Send {
    type Error: Error + Classify + 'static;

    // Required method
    fn read_groups(
        &self,
        after: Option<SequencePosition>,
        max_events: NonZeroUsize,
    ) -> impl Future<Output = Result<GroupPage, Self::Error>> + Send;
}
Expand description

A store that can read its log back in the write groups it wrote.

Every row belongs to exactly one group: one append is one group, and one IngestGroup that lands at least one foreign event is one group, its compensation included. A group is named by the lowest local position among the rows it wrote, which is its first.

Only a runner and a store peer should hold one of these, for the reason IngestStore gives: it is replication’s view of the log, not an application’s.

§Flavours

This is the !Send flavour, and generic code should bind it (RS-20-2). Adapters that can cross threads implement SendWriteGroupStore and get this for free; the Durable Object implements this one.

Required Associated Types§

type Error: Error + Classify + 'static

How this store fails, stating a class so a runner never infers one.

Required Methods§

fn read_groups( &self, after: Option<SequencePosition>, max_events: NonZeroUsize, ) -> impl Future<Output = Result<GroupPage, Self::Error>> + Send

The write groups whose first position is above after (every group when None), in ascending first order, each whole.

Fills to max_events events and stops before the group that would take the page past it. The first group is returned whole however many events it carries, so a caller always learns what blocks it; whether it can travel is the caller’s to decide. Chaining pages with after = Some(last.first()) returns every group exactly once.

GroupPage::waiting is Waiting::Nothing only when the store saw no group past the page, and Waiting::Unknown otherwise. A store never counts: a count is a scan of the rest of the log.

§Errors

The adapter’s error; its Classify impl states the class. A stored guard the store cannot decode is one of them.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl SendWriteGroupStore for MemoryIngestStore

Available on crate feature memory only.

Writers are serialised under the lock, so a group’s rows are contiguous and a scan in position order meets each group whole, in ascending order of their first positions.

Its error is the one the shared GroupPageBuilder can raise, and the only one: the builder checks the order rather than trusting it, and this store states that check in its type rather than claiming it never fails.