LeaseOutcome
What LocalHeddle.extend, LocalHeddle.shrink, LocalHeddle.complete or LocalHeddle.cancel did.
Samples
val pool = draft("pool") {
lane("live")
lane("paused", maxConcurrent = 0)
lane("retiring")
}
val live = pool.groupId("live")
val paused = pool.groupId("paused")
val retiring = pool.groupId("retiring")
val policy = LocalPolicy(defaultReservation = 3L)
val (heddle, booted) = LocalHeddle.fromTopology(pool, policy, epoch = 0L)
check(booted.refusals.isEmpty())
heddle.reconcileCapacity(totalSlots = 2L)
// A ceiling of 0 pauses a lane: with only it eligible for this slot, there is nobody to pick.
val all = setOf(live, paused, retiring)
check(heddle.acquire(waiting = all, eligible = setOf(paused), startedAt = 0L) == AcquireOutcome.NothingEligible)
check(heddle.explain(paused, waiting = all, eligible = all) == WaitExplanation.AtCeiling(paused, limit = 0L))
// A reload removes `retiring` while its lease runs: the extend is refused, the complete settles.
val lease = (heddle.acquire(setOf(retiring), setOf(retiring), startedAt = 0L) as AcquireOutcome.Acquired).lease
val without = draft("pool") {
lane("live")
lane("paused", maxConcurrent = 0)
}
check(heddle.apply(without, generation = 1L).refusals.single() is StepRefusal.Draining)
check(heddle.extend(lease.id, amount = 3L, waiting = emptySet()) is LeaseOutcome.PathDraining)
check(heddle.complete(lease.id, actualCost = 3L, waiting = emptySet()) == LeaseOutcome.Done(charged = 3L, overrun = 0L, unrecorded = 0L))
// Settled once, the id is unknown to this engine; after a restart it is from an older epoch.
check(heddle.complete(lease.id, actualCost = 3L, waiting = emptySet()) == LeaseOutcome.Unknown)
val restarted = LocalHeddle.restore(heddle.persist(), policy, epoch = 1L)
check(restarted.complete(lease.id, actualCost = 3L, waiting = emptySet()) == LeaseOutcome.Stale(currentEpoch = 1L))
// Keep every weight's denominator at or below 30,719. A finer one is refused when it is
// applied, and the rest of the reload lands.
val finer = draft("pool") {
lane("live")
lane("paused", maxConcurrent = 0)
lane("fine", Weight.of(1, 30_720))
lane("coarse", Weight.of(1, 2))
}
val refused = restarted.apply(finer, generation = 2L).refusals.single()
check(refused is StepRefusal.Refused && refused.child == finer.groupId("fine"))
val coarse = finer.groupId("coarse")
check(restarted.acquire(setOf(coarse), setOf(coarse), startedAt = 10L) is AcquireOutcome.Acquired)Inheritors
Types
The operation applied. charged is the cost the ledger recorded for the lease, and overrun how much of the cost lay beyond the reservation. unrecorded is what the ledger recorded on no edge, so charged + unrecorded is the cost a LocalHeddle.complete was given.
An extend refused because the lease's path is draining: edge, the first edge of it below the root that is no longer ACTIVE, takes no new delegation (a reload is removing it). The lease and the ledger are unchanged. The lease still settles: LocalHeddle.complete and LocalHeddle.cancel are never refused.
No open lease has this id, and it is from another epoch than currentEpoch. Nothing changed.
An extend the root could not fund, with no capacity reconciled to top it up (LocalHeddle.reconcileCapacity). The lease and the ledger are unchanged.
No open lease has this id, and it is from this engine's own epoch. Nothing changed.