AtCeiling

data class AtCeiling(val group: GroupId, val limit: Long) : WaitExplanation

group, on the leaf's path, has at least limit leases open beneath it, its concurrency ceiling (Topology.Node.maxConcurrent), so no pick goes to the leaf until enough of them close. A limit of 0 is a pause. When several groups on the path are at their ceilings, group is the one nearest the root: the whole subtree waits on it.

The next acquire skips the leaf for a sibling, or returns AcquireOutcome.NothingEligible when every eligible leaf is capped. Checked before the supply, so a capped leaf is told this even when the root is empty.

Samples

val tree = draft("pool") {
    lane("deploys", Weight.of(3), maxConcurrent = 1)
    lane("builds")
}
val deploys = tree.groupId("deploys")
val builds = tree.groupId("builds")
val (heddle, booted) = LocalHeddle.fromTopology(tree, LocalPolicy(defaultReservation = 1L), epoch = 0L)
check(booted.refusals.isEmpty())
heddle.reconcileCapacity(totalSlots = 4L)
val queued = setOf(deploys, builds)

val deploy = (heddle.acquire(queued, queued, startedAt = 0L) as AcquireOutcome.Acquired).lease
check(deploy.leaf == deploys)
// Deploys weigh three times as much, but one is already running, its ceiling.
check(heddle.explain(deploys, waiting = queued, eligible = queued) == WaitExplanation.AtCeiling(deploys, limit = 1L))
check(heddle.entitlement(builds, waiting = queued, totalSlots = 4L) == Rational.of(4L))
check((heddle.acquire(queued, queued, startedAt = 1L) as AcquireOutcome.Acquired).lease.leaf == builds)

heddle.complete(deploy.id, actualCost = 1L, waiting = queued)
// Deploys compete again, a third of a build ahead, as they were when they reached the ceiling.
val back = heddle.explain(deploys, waiting = queued, eligible = queued)
check(back is WaitExplanation.BehindAtLevel && back.leafSideVirtualService == Rational.of(4L, 3L) && back.front == Rational.of(5L, 4L))
check(heddle.explain(builds, waiting = queued, eligible = queued) == WaitExplanation.WouldBePickedNext)

Constructors

Link copied to clipboard
constructor(group: GroupId, limit: Long)

Properties

Link copied to clipboard
Link copied to clipboard
open override val kind: WaitExplanation.Kind

The arm, by name. Declared in the order LocalHeddle.explain checks them.

Link copied to clipboard
val limit: Long