RestoreResult
What LocalHeddle.decode found in a stored snapshot.
Samples
val tree = twoLanes()
val heavy = tree.groupId("heavy")
val light = tree.groupId("light")
val policy = LocalPolicy(defaultReservation = 3L)
val (heddle, booted) = LocalHeddle.fromTopology(tree, policy, epoch = 0L)
check(booted.refusals.isEmpty())
heddle.reconcileCapacity(totalSlots = 2L)
val queued = setOf(heavy, light)
val running = (heddle.acquire(queued, queued, startedAt = 100L) as AcquireOutcome.Acquired).lease
// Under your scheduling lock: take the snapshot. Encoding and storing it can happen off the lock.
val stored = Json.encodeToString(LocalHeddleSnapshot.serializer(), heddle.persist())
// After the restart: decode, then restore under a later epoch, your persisted boot counter.
val decoded = LocalHeddle.decode(stored, Json)
check(decoded is RestoreResult.Restored)
val restarted = LocalHeddle.restore(decoded.snapshot, policy, epoch = decoded.snapshot.epoch + 1)
// The lease that was running is still open, and settles as it would have.
check(restarted.complete(running.id, actualCost = 3L, waiting = queued) == LeaseOutcome.Done(charged = 3L, overrun = 0L, unrecorded = 0L))
// New leases are named under the new epoch, so none can repeat an old id.
check((restarted.acquire(queued, queued, startedAt = 120L) as AcquireOutcome.Acquired).lease.id.epoch == 1L)Content copied to clipboard
Inheritors
Types
Link copied to clipboard
The bytes are not a snapshot of a supported format, or hold one that is inconsistent: reason says which.
Link copied to clipboard
The bytes held a snapshot this release reads. Start an engine from it with LocalHeddle.restore.
Link copied to clipboard