Skip to main content

Module sync_drain

Module sync_drain 

Source
Expand description

Draining the offline mutation queue (sync_queue) to the server.

sync_queue had producers but no consumer: PlaybackReporter::queue_for_sync inserts a row whenever a start/stop/mark-played cannot reach the server, and nothing ever pushed one. sync_mark_processing/_completed/_failed were registered commands with no callers, so the queue only grew — the offline banner’s “N pending” climbed forever and the watch positions those rows stood for never reached Jellyfin.

Same shape as the favourites drain (DR-120), and for the same reason: a drain started by a component dies with it, so it lives in Rust and hangs off the connectivity:reconnected transition the ConnectivityMonitor already emits.

TRACES: UR-025, UR-002 | DR-131 | UT-122

Structs§

DrainReport
What a drain did, for logging and for the frontend’s “Sync now” button.
PushFailure 🔒
Why a push failed, and whether the row should be charged an attempt for it.
QueuedRow 🔒

Enums§

QueuedOp
A queued mutation, resolved from its stored operation + JSON payload.

Constants§

MAX_SYNC_ATTEMPTS
How many times a row may fail before it stops being retried.
SYNC_QUEUE_CHANGED_EVENT
Emitted after a drain so open views can re-read the queue instead of waiting for the frontend’s 10s poll.

Traits§

SyncSink
The slice of the repository the drain needs — narrow so it can be doubled in a test without forty unimplemented!() methods.

Functions§

drain_sync_queue
Push every queued mutation for this user, oldest first.
enqueue_playback_stopped
Queue a watch position that could not be reported to the server.
mark_completed 🔒
mark_deferred 🔒
Put a row back in the queue untouched apart from its error note — used when the server was simply unreachable.
mark_failed 🔒
parse_queued_op
Turn a stored row into something pushable.
read_queue 🔒
remaining_count 🔒
run_drain
Resolve app state and drain. Shared by the reconnect hook and the manual “Sync now” command.
spawn_sync_queue_drain
Drain on every offline→online transition.
sync_process_pending
Push the queue now, on the user’s say-so, instead of waiting for a reconnect.