CustomCheckpointRequestConnector

A PowerSyncBackendConnector capable of requesting checkpoints.

Extend this class instead of PowerSyncBackendConnector when uploads are processed asynchronously by the backend (for example through a message queue): The sync client as part of the PowerSync Kotlin SDK generates a checkpoint request id and hands it to your backend via this class, which is responsible for creating a matching checkpoint once the uploads preceding the request have been processed. For more details, see asynchronous backend uploads.

To use this connector, using com.powersync.sync.CheckpointMode.Requests is required. Note that this requires PowerSync service version 1.24.0 or later.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
abstract suspend fun fetchCredentials(): PowerSyncCredentials?

Get credentials for PowerSync.

Link copied to clipboard

Get credentials current cached, or fetch new credentials if none are available.

Link copied to clipboard

Immediately invalidate credentials.

Link copied to clipboard
abstract suspend fun postCheckpointRequest(clientId: String, requestId: Long): Long

Posts a client-generated checkpoint request to the backend and returns the effective checkpoint request state.

Link copied to clipboard
open fun prefetchCredentials(): Job

Fetch a new set of credentials and cache it.

Link copied to clipboard
suspend fun updateCredentials()

If no other task is currently fetching credentials, calls fetchCredentials again and caches the result internally.

Link copied to clipboard
abstract suspend fun uploadData(database: PowerSyncDatabase)

Upload local changes to the app backend.