Skip to main content

RestoreFixture

Trait RestoreFixture 

Source
pub trait RestoreFixture {
    type Peer: SyncPeer;

    // Required methods
    fn connect(&self) -> impl Future<Output = Self::Peer>;
    fn append_local(
        &self,
        events: &[Event],
    ) -> impl Future<Output = Result<(), Violation>>;
    fn back_up(&self) -> impl Future<Output = Result<(), Violation>>;
    fn restore(&self) -> impl Future<Output = Result<(), Violation>>;
}
Expand description

One isolated far side whose storage can be backed up and restored, and a way to reach it.

One fixture instance is one isolated backing store, and each connect is one peer onto it: the other families’ contract. What this family adds is the operator’s half of the store’s life: a writer of the store’s own events, a backup and a restore. A peer port has none of the three, so the fixture supplies them.

§Why a trait of its own

Not a capability on SyncFixture: a peer that issues no identity of its own, such as happenstance_sync::MemorySyncPeer, which holds only what it was pushed, has nothing a restore could reissue, and every rule of that family is held against peers built on it. Here the three methods are required, so mounting the family is the declaration that the store can be restored.

§No Send, on purpose

Bounded on the bare SyncPeer, as SyncFixture is, so a !Send peer is a valid fixture.

§Errors

Every method but connect returns a Violation of VT-6 when the fixture cannot do what it was asked. That is the fixture’s own failure, reported under the clause of the rule that asked, as SY-36’s provocations are.

Required Associated Types§

Source

type Peer: SyncPeer

The peer adapter under test.

Required Methods§

Source

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

A fresh peer onto this fixture’s store, as a process started now would open one.

An implementation in test code may panic when the environment cannot connect, as the other families’ fixtures do.

Source

fn append_local( &self, events: &[Event], ) -> impl Future<Output = Result<(), Violation>>

Appends events to the store as one local write, as the store’s own writer would: each event takes an identity the store mints.

§Errors

A Violation of VT-6 if the store refuses the write.

Source

fn back_up(&self) -> impl Future<Output = Result<(), Violation>>

Takes a backup of the store’s storage as it stands now: everything a point-in-time restore to this moment would bring back, the store’s identity among it.

§Errors

A Violation of VT-6 if the backup cannot be taken.

Source

fn restore(&self) -> impl Future<Output = Result<(), Violation>>

Puts the store’s storage back to the last back_up, as an operator’s restore would, and then takes every step the adapter documents a deployment must take after a restore.

For an adapter that mints its identity once, that is VT-6’s re-mint, run the way its documentation says to run it. An adapter that detects a restore, or mints on every open, documents no step, and does nothing here past the restore itself. The rule drops every peer it connected before it asks for the restore, and connects a fresh one after it, as a deployment stops its writers first and restarts what held the store.

§Errors

A Violation of VT-6 if there is no backup to restore, or the restore or a documented step fails.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§