SyncResourceAdapter

Resource-specific glue for the generic loop in SyncEngine. Implement one of these (plus the wire DTO mapping) to make a new resource syncable — the contract logic (ack guard, pending guard, full-snapshot reconciliation, pagination drain, fullResyncRequired) lives in the engine, not here, so it holds identically for every resource.

Type Parameters

E

entity type (carries SyncableEntity bookkeeping)

U

upsert DTO, D delete DTO, C server-change DTO

Properties

Link copied to clipboard
abstract val resourceName: String

Functions

Link copied to clipboard
abstract suspend fun activeRows(): List<E>

Active (non-deleted) rows, for full-snapshot tombstone reconciliation.

Link copied to clipboard
abstract suspend fun api(request: SyncRequest<U, D>): SyncResponse<C>
Link copied to clipboard
abstract fun changeKey(change: C): String
Link copied to clipboard
abstract suspend fun findExisting(change: C): E?
Link copied to clipboard
abstract fun isChangeDeleted(change: C): Boolean
Link copied to clipboard
abstract suspend fun pending(): List<E>
Link copied to clipboard
abstract suspend fun purgeSynced()

Drop clean synced rows for fullResyncRequired.

Link copied to clipboard
abstract suspend fun reload(entity: E): E?

Re-read the row for the ack guard (detects edits made during the in-flight request).

Link copied to clipboard
abstract fun syncKey(entity: E): String

Canonical business key; MUST equal the server's applied[].key and changeKey.

Link copied to clipboard
abstract fun toDelete(entity: E): D
Link copied to clipboard
abstract fun toEntity(change: C, existing: E?): E
Link copied to clipboard
abstract fun toUpsert(entity: E): U
Link copied to clipboard
abstract suspend fun upsert(entity: E)