SyncDriver class
Full-duplex reliable-sync loop driver (spec § SyncDriver).
One driver drives one peer connection over a caller-supplied IpcSink / IpcSource pair. It composes the three pure-protocol pieces into the loop shape the spec pins:
- resync-on-reconnect — onReconnect arms a replay of the unacked outbox suffix from the peer's ack cursor and re-advertises our receiver cursor, so a dropped-frame gap converges;
- drain — pop host-enqueued outbound data frames, DurableOutbox.append each before sending (at-least-once durability), send via the sink;
- retain-on-fail — a send error leaves the frame in the outbox (unacked) and stops the drain; it is re-sent on the next reconnect;
- receive — read inbound frames, route control frames (OutboxAck → advance retention; ResyncRequest → answer with a provider snapshot) and feed data frames through the ResyncCoordinator.
The driver owns no threads, no clock source, and no storage engine — the host injects all three (Clock, the transport pair, the outbox) and decides the tick cadence.
Constructors
- SyncDriver({required IpcSink sink, required IpcSource source, required DurableOutbox outbox, required Clock clock, required SnapshotProvider provider, Epoch lastEpoch = 0})
-
A driver whose receiver has already applied through
lastEpoch(0 = fresh; a Snapshot seeds the first epoch — resume otherwise).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- outbox → DurableOutbox
-
The underlying outbox (diagnostics / durable-store flush).
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
enqueue(
Epoch epoch, IpcMessage msg) → void -
Stage an outbound data frame at
epochfor the next tick's drain.epochis the frame's accepted-event count (Delta.epoch/Snapshot.epoch); it becomes the outbox retention key. -
isStalled(
) → bool - Whether the sink is currently stalled (last send failed, awaiting reconnect).
-
lastEpoch(
) → int - The receiver's current applied epoch.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onReconnect(
) → void - Signal that the transport was re-established; the next tick replays the unacked outbox suffix and re-advertises our receiver cursor.
-
stalledFor(
int now) → int -
Millis the sink has been stalled as of
now, or0when healthy — a backoff signal for the host scheduler (which owns cadence/backoff policy). -
tick(
) → Progress - Run one loop pass. See the class docs for the resync → drain → retain → receive shape. Sink failures retain-and-stall (not an error); only an inbound source read failure throws DriverError.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited