pub trait SyncFixture {
type Peer: SyncPeer;
const COMPACTION: Capability = _;
const REOPEN: Capability = _;
// Required methods
fn connect(&self) -> impl Future<Output = Self::Peer>;
fn refusals(
&self,
peer: &Self::Peer,
) -> impl Future<Output = RefusalsOf<Self::Peer>>;
// Provided methods
fn compact_recorded_before(
&self,
_peer: &Self::Peer,
cutoff: RecordedAt,
) -> impl Future<Output = Result<(), Violation>> { ... }
fn reopen(&self) -> impl Future<Output = Reopened> { ... }
}Expand description
One isolated far side, and a way to reach it.
One fixture instance is one isolated backing peer, 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
SyncPeer, so a !Send peer — the Durable
Object’s, which holds its transport behind an Rc — is a valid fixture.
That is SY-17’s rule: the suite compiles against a !Send fixture peer,
which this crate’s tests/local_sync_conformance.rs does.
§One peer handle per rule
A fixture yields peers, never a peer set, and every rule in
rules holds exactly one (SY-8). A rule that needed two
would be testing the runner. The model family (sync_model, behind the
proptest feature) is the exception, and says so: it plays the runner
itself over one fixture per node, so each call of the opener it is given
must build a fresh, isolated peer.
Provided Associated Constants§
Sourceconst COMPACTION: Capability = _
const COMPACTION: Capability = _
Whether this fixture can make its peer forget a prefix of its log, as
a peer with a retention window does. SY-32’s rule,
retention_gap_is_reported_not_silent,
needs it, and reports Skipped
with the stated reason when it is declined.
Nothing in the port compacts, so the operation is the adapter’s.
Sourceconst REOPEN: Capability = _
const REOPEN: Capability = _
Whether this fixture can close and reopen its backing peer, discarding every handle’s process-level state.
happenstance_testkit::ProjectionFixture::REOPEN for the peer port, and
CF-17 governs it in the same words: a fixture declaring it supported
MUST make reopen discard that state over a medium
that outlives the process’s hold on it, and MUST state the mechanism —
which pool is closed, which client is rebuilt. A fixture over a peer
with no medium outside the process MUST decline it, with that as its
stated reason.
It is read by exactly one rule,
ack_never_confirms_a_non_durable_event,
which reads SY-31’s durably seen across a reopen. Without one the rule
can only drop the acking handle and connect another, so a peer that
keeps what it acknowledged in memory every handle shares passes it.
§Defaulted, and checked
Defaulted to a declension, in UNSTATED_SYNC_REOPEN’s words, so the
item is additive to every fixture written before it: a default may
decline on an author’s behalf, never declare. A fixture that inherits
it is told so in its own CI by sync_declensions_are_stated, which
sync_peer_conformance! emits.
§What declaring it does not prove
An override that answers Reopened::Discarded and discards nothing is
indistinguishable, through the port, from an honest one. So the rule
rejects a peer that loses a confirmed event across a reopen, and
cannot reject a fixture that only claims to reopen; the declaration
MUST above carries that hazard, as it does for the projection port.
Required Associated Types§
Required Methods§
Sourcefn connect(&self) -> impl Future<Output = Self::Peer>
fn connect(&self) -> impl Future<Output = Self::Peer>
A handle onto this fixture’s backing peer.
Sourcefn refusals(
&self,
peer: &Self::Peer,
) -> impl Future<Output = RefusalsOf<Self::Peer>>
fn refusals( &self, peer: &Self::Peer, ) -> impl Future<Output = RefusalsOf<Self::Peer>>
Drives peer into every refusal it can produce, and declares the
[FailureClass] each one is (SY-36).
Only the adapter knows which of its failures can be provoked and what
each calls for, so the fixture both provokes and declares, and the rule
every_refusal_states_its_class
compares what the error says against what the fixture said. A required
method rather than a default returning nothing, because a fixture that
declined it silently would pass that rule against nothing.
§Errors
A Violation if the fixture cannot build a provocation — its own
failure, reported under SY-36 because that is the rule that asked.
Provided Methods§
Sourcefn compact_recorded_before(
&self,
_peer: &Self::Peer,
cutoff: RecordedAt,
) -> impl Future<Output = Result<(), Violation>>
fn compact_recorded_before( &self, _peer: &Self::Peer, cutoff: RecordedAt, ) -> impl Future<Output = Result<(), Violation>>
Makes peer forget the longest prefix of its log, in its forwarding
order, in which every event was recorded before cutoff, as the
fixture’s adapter compacts on a retention window (SY-32).
cutoff is a window predicate on each event’s
RecordedAt, never an order: RecordedAt orders nothing. A fixture
that declares COMPACTION supported overrides this.
§Errors
The provided body always returns a Violation of SY-32 naming the
two ways to reach it: a fixture that declares the capability and does
not compact, or a rule that compacts without checking it.
Sourcefn reopen(&self) -> impl Future<Output = Reopened>
fn reopen(&self) -> impl Future<Output = Reopened>
Closes and reopens the backing peer, discarding every outstanding handle’s process-level state, and says whether it did.
After an override returns Reopened::Discarded, a fresh
connect must observe exactly what the peer durably
holds. Handles obtained before the call may stop working; a rule drops
every one before it calls this.
§The provided body says it reopened nothing
It returns Reopened::Nothing, and the rule reports a violation on
that answer before it reads anything back. A fixture that declares
REOPEN supported and forgets this override therefore
fails on every run, with a message naming this method: the projection
port’s shape, not the event-store port’s panicking one, so the failure
lands in the rule and no panic is in this crate’s library code.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".