Skip to main content

ConvergenceFixture

Trait ConvergenceFixture 

Source
pub trait ConvergenceFixture {
    type Projection: Projection;
    type Codec: Codec;

    // Required methods
    fn projection(&self) -> Self::Projection;
    fn codec(&self) -> &Self::Codec;
    fn authored(&self) -> [Vec<EventOf<Self>>; 2];
    fn store(&self) -> impl Future<Output = Result<StoreOf<Self>, Violation>>;
    fn read_model(
        &self,
        store: &StoreOf<Self>,
    ) -> impl Future<Output = Result<Vec<u8>, Violation>>;
}
Expand description

One projection, the events two origins authored, and a way to read what it committed.

The convergence family’s fixture, and a different shape from the peer and ingest families’ because its subject is different: not an adapter but a typed fold. The rule replays the two origins’ events in two interleavings and runs a fresh projection over each into a fresh store, so every method that builds something is called once per interleaving and must build it anew.

§No convergence bound here, on purpose (SY-22)

Projection is bounded on Projection alone. The declaration is required by the rule, convergent_projection_is_interleaving_independent, in its own where-clause, so a fixture over an undeclared projection can be written and cannot be handed to it. That where-clause is the exclusion SY-22 asks for, and CostLayersFixture is the honest case it excludes.

§The events are the check’s strength

The rule reorders what it is given and nothing else, so a fold that depends on arrival order is caught only by events whose order it depends on. Hand it two origins that disagree about something the fold keeps — the same key written from both sides, a quantity one consumes from the other — or the rule passes a fold it should not.

Required Associated Types§

Source

type Projection: Projection

The projection under test, in either flavour.

Source

type Codec: Codec

The codec its events are written with.

Required Methods§

Source

fn projection(&self) -> Self::Projection

A fresh projection, in the state it starts a rebuild in.

Source

fn codec(&self) -> &Self::Codec

The codec the rule encodes the events with and the runner decodes them with.

Source

fn authored(&self) -> [Vec<EventOf<Self>>; 2]

The events each origin authored, in authorship order: origin one’s, then origin two’s.

Neither may be empty. An origin with nothing to interleave makes the two interleavings the same log, and a check over one log is decorative, so the rule refuses that case rather than passing it.

Source

fn store(&self) -> impl Future<Output = Result<StoreOf<Self>, Violation>>

A fresh, empty store that shares nothing with any other it returned.

§Errors

A Violation if the store cannot be opened: the fixture’s own failure, reported under the clause of the rule that asked.

Source

fn read_model( &self, store: &StoreOf<Self>, ) -> impl Future<Output = Result<Vec<u8>, Violation>>

The read model store holds, as bytes the rule compares.

Everything the projection wrote and nothing else: not the checkpoint, which is a position in the replica’s own log.

§Errors

A Violation if the store cannot be read, as for store.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§