AcquireOutcome

sealed interface AcquireOutcome

What LocalHeddle.acquire 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

Link copied to clipboard
data class Acquired(val lease: Lease) : AcquireOutcome, AdmitOutcome

A lease was opened.

Link copied to clipboard
data class LifetimeExhausted(val parent: GroupId) : AcquireOutcome

The reservation would carry a lifetime counter past the watermark, Long.MAX_VALUE less LocalHeddle.LIFETIME_HEADROOM (see "The lifetime limit" on LocalHeddle): the effective issuance of the edge the pick chose below parent, or, with parent the root, the root's minted supply, when the root cannot fund the reservation without minting past it. Nothing changed but the wake memory, as for NoLiveLineage.

Link copied to clipboard

No lineage of ACTIVE edges leads from the root to an eligible leaf, or to the admitted one. A group mid-reshape, a leaf behind a closing edge, a name that is not a leaf, and a group the topology does not declare leasable all land here (see "What a lease ends at" on LocalHeddle). Nothing changed, and nothing was charged.

Link copied to clipboard

No leaf was eligible for this slot: the eligible set was empty, or every leaf in it a pick could end at is beneath a node at its concurrency ceiling (Topology.Node.maxConcurrent; see "Ceilings" on LocalHeddle). LocalHeddle.explain names that node for each such leaf, as WaitExplanation.AtCeiling. Nothing changed, the wake memory included.

Link copied to clipboard

The root holds less than the reservation, and no capacity is reconciled to top it up (LocalHeddle.reconcileCapacity). Nothing changed.