
Offline-first reliable outgoing-action queue ensuring persistent, ordered delivery with background orchestration, conflict resolution, priorities, atomic batching, throttling, encryption, observability, multi-user partitioning and audit.
KSync is a robust, offline-first synchronization library for Kotlin Multiplatform. It ensures your client-side actions eventually reach the server by managing a persistent queue with background orchestration and conflict resolution.
Most "offline" apps just cache data. KSync focuses on outgoing actions. Whether it's a "Like", a "Comment", or "Create Post", KSync ensures that even if the user is in a tunnel, on a plane, or has a flaky connection, their intent is preserved persistently and synchronized as soon as possible.
@Serializable
data class CreatePostAction(
override val id: String,
val title: String,
override val mergeKey: String? = "post-$id"
) : SyncAction
class CreatePostWorker(private val api: MyApi) : SyncWorker<CreatePostAction> {
override val workerIdentifier = "POST"
override suspend fun execute(action: CreatePostAction): SyncResult {
return try {
api.createPost(action)
SyncResult.Success
} catch (e: Exception) {
SyncResult.Retry // KSync will handle backoff
}
}
}val ksync = KSync.init(context) {
// Register your workers here
registerWorker(CreatePostWorker(api))
}// Type-safe enqueue. KSync knows which worker to use based on action type.
ksync.enqueue(
action = CreatePostAction(id = "uuid", title = "Hello World")
)
// Observe pending actions
val pendingActions: Flow<List<QueuedAction>> = ksync.observePendingActions()priority and dependsOn directly in your SyncAction.groupId for "all-or-nothing" sequential processing.mergeKey.userId for multi-account applications.SyncStats and SyncObserver for granular monitoring of your sync health.Apache License 2.0
KSync is a robust, offline-first synchronization library for Kotlin Multiplatform. It ensures your client-side actions eventually reach the server by managing a persistent queue with background orchestration and conflict resolution.
Most "offline" apps just cache data. KSync focuses on outgoing actions. Whether it's a "Like", a "Comment", or "Create Post", KSync ensures that even if the user is in a tunnel, on a plane, or has a flaky connection, their intent is preserved persistently and synchronized as soon as possible.
@Serializable
data class CreatePostAction(
override val id: String,
val title: String,
override val mergeKey: String? = "post-$id"
) : SyncAction
class CreatePostWorker(private val api: MyApi) : SyncWorker<CreatePostAction> {
override val workerIdentifier = "POST"
override suspend fun execute(action: CreatePostAction): SyncResult {
return try {
api.createPost(action)
SyncResult.Success
} catch (e: Exception) {
SyncResult.Retry // KSync will handle backoff
}
}
}val ksync = KSync.init(context) {
// Register your workers here
registerWorker(CreatePostWorker(api))
}// Type-safe enqueue. KSync knows which worker to use based on action type.
ksync.enqueue(
action = CreatePostAction(id = "uuid", title = "Hello World")
)
// Observe pending actions
val pendingActions: Flow<List<QueuedAction>> = ksync.observePendingActions()priority and dependsOn directly in your SyncAction.groupId for "all-or-nothing" sequential processing.mergeKey.userId for multi-account applications.SyncStats and SyncObserver for granular monitoring of your sync health.Apache License 2.0