Skip to main content

IngestFixture

Trait IngestFixture 

Source
pub trait IngestFixture {
    type Store: EventStore + IngestStore;

    const MID_GROUP_FAULT: Capability = _;
    const MAX_EVENT_DATA_LEN: Option<usize> = None;
    const MAX_TAGS_PER_EVENT: Option<usize> = None;
    const MAX_METADATA_LEN: Option<usize> = None;
    const MAX_TAGS_PER_BATCH: Option<usize> = None;

    // Required method
    fn connect(&self) -> impl Future<Output = Self::Store>;

    // Provided method
    fn arm_mid_group_fault(
        &self,
        after: usize,
    ) -> impl Future<Output = Result<(), Violation>> { ... }
}
Expand description

One isolated backing store that both appends and ingests, and a way to reach it.

One fixture instance is one isolated backing store, and each connect is one handle onto it: the event-store family’s contract, one port over. A rule calls the opener it is given for a fresh instance, so no rule sees another’s events.

§No Send, on purpose

Not trait_variant-derived, and bounded on the bare EventStore and IngestStore, so a !Send store, the Durable Object’s, is a valid fixture. This crate’s tests/local_ingest_conformance.rs mounts one.

§Capabilities are defaulted items

Every item past connect has a default, so each one added is additive to every implementation written before it, as happenstance_testkit::Fixture’s capabilities are:

  • MID_GROUP_FAULT and arm_mid_group_fault, which SY-30’s rule needs. Declined by default, in this crate’s words, and ingest_declensions_are_stated rejects a fixture that keeps them.
  • Three per-event ceilings, which SY-18’s ingest rule holds to every event an ingest writes. None by default: facts, not trades.
  • One per-call ceiling, MAX_TAGS_PER_BATCH, which VT-36’s ingest rule holds to the whole call, compensation included. None by default, for the same reason.

Provided Associated Constants§

Source

const MID_GROUP_FAULT: Capability = _

Whether this fixture can make its store fail between two rows of one ingest group.

SY-30 says a group lands whole, and a conformant store decides every refusal before it writes, so the case left is a fault inside the write. Nothing in the port reaches between two rows of one ingest, so the injection is the adapter’s: a trigger, a constraint armed for one write.

A store that can absorb every fault its fixture could arm, and commit the group anyway, declines: the rule requires an armed ingest to fail, or it has not shown that a failure leaves nothing behind.

Source

const MAX_EVENT_DATA_LEN: Option<usize> = None

The largest data payload, in bytes, the store accepts in one event, or None for no ceiling.

A fact about the store rather than a trade, so an Option rather than a Capability. It must mirror the adapter’s own constant, never a literal restated here, or the rule checks the fixture and not the store.

Source

const MAX_TAGS_PER_EVENT: Option<usize> = None

The most tags the store accepts on one event, or None for no ceiling. Mirrored, as MAX_EVENT_DATA_LEN is.

Source

const MAX_METADATA_LEN: Option<usize> = None

The largest metadata, in bytes, the store accepts on one event, or None for no ceiling. Mirrored, as MAX_EVENT_DATA_LEN is. Zero is a legal declaration, because the contract guarantees no metadata capacity.

Source

const MAX_TAGS_PER_BATCH: Option<usize> = None

The most tags, summed over every foreign event and every compensation event of one ingest call, the store accepts, or None for no ceiling beyond what its per-event ceiling and its call length already imply.

Mirrored from the adapter’s own constant, as MAX_EVENT_DATA_LEN is. Stating a number commits the store to landing a call that carries exactly that many and to refusing one more as IngestError::ExceedsStoreLimit { limit: StoreLimit::TagsPerBatch, .. }, class Split, with nothing written. The call is the batch: its groups and their compensation count together (VT-36, ADR-0100). It must be at least MAX_TAGS_PER_EVENT, or a call of one event within its own ceiling is refused as a batch with nothing left to split.

Required Associated Types§

Source

type Store: EventStore + IngestStore

The store under test: an event store that also ingests.

Required Methods§

Source

fn connect(&self) -> impl Future<Output = Self::Store>

A handle onto this fixture’s one backing store.

An implementation in test code may panic when the environment cannot connect, as the event-store family’s fixtures do: the suite has nothing to report about a store it never reached.

Provided Methods§

Source

fn arm_mid_group_fault( &self, after: usize, ) -> impl Future<Output = Result<(), Violation>>

Arms the store so that its next ingest fails while writing the after + 1-th row it writes in that call.

Foreign rows and compensation rows both count, in the store’s own write order; a row it skips is not written and is not counted. Arming reaches handles already connected. The fault may stay armed for the fixture’s life: no rule writes to an armed fixture except with the one ingest it armed for.

§Errors

The provided body returns a Violation of SY-30, naming the two ways to reach it: a fixture that declares MID_GROUP_FAULT supported and does not override this, or a rule that did not check the capability first. An override returns one when its environment cannot arm the fault.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§