CheckpointStore

The checkpoints of subscriptions (documentation/designs/04-subscriptions.md §1): one per (subscription group, subscription, partition), the lowest log sequence up to which every entry of the partition is completed.

A checkpoint only moves forward: save ignores a position lower than the stored one, and saving the stored one again changes nothing. That is what makes a lease handover safe without fencing: while ownership of a partition moves, the old owner may still save for a short while; its positions are never ahead of what it really completed, so the store keeps the highest completed position whichever owner wrote last, and a late, lower write from a zombie owner is harmless. Replaying from an earlier position is not a backward save: it is a new subscription.

Functions

Link copied to clipboard
abstract suspend fun list(group: String): List<Checkpoint>

Every checkpoint of group, of each subscription and partition, in no order: the subscriptions of the group that have read its stream. A subscription that starts where its service joins a stream reads it from the beginning only when no other subscription of the group did.

Link copied to clipboard
abstract suspend fun load(group: String, subscription: String, partition: Int): Long?

The checkpoint of subscription in group for partition, or null when it has none yet.

Link copied to clipboard
abstract suspend fun save(group: String, subscription: String, partition: Int, position: Long)

Moves the checkpoint to position if that is ahead of the stored one; otherwise does nothing.

Link copied to clipboard
open suspend fun saveAll(group: String, checkpoints: List<Checkpoint>)

saves each of checkpoints in group: what a subscription runtime's periodic save stores at once, one per subscription and partition whose checkpoint moved. Each is saved as save would, on its own: a failure may leave some saved and others not, which only means those are saved again later. A backend stores them in as few round trips as it can; this default saves them one by one.