template
Gives this group a template for the children the app attaches while running, each with weight and at most maxConcurrent leases open on it at once (null for no ceiling): the ceiling caps each child on its own, not all of them together. A group with a template may declare no children of its own. Call it at most once per group: a group has one template.
Each child the app attaches here is a leaf unless template is set: then each one is a group, never leased itself, and the app attaches children beneath it with what template gives them (Topology.ChildTemplate.template). Everything below an attached child is attached, to any depth the templates nest.
Parameters
the template of each attached child's own attached children; null when each attached child is a leaf.
Throws
when this group already has a template.
Samples
val ci = draft("ci") {
// Each repository weighs 2 beside the nightly lane, and each author caps at one job.
group("repos") { template(Weight.of(2), template = Topology.ChildTemplate(Weight.ONE, maxConcurrent = 1L)) }
lane("nightly")
}
val (heddle, booted) = LocalHeddle.fromTopology(ci, LocalPolicy(defaultReservation = 1L), epoch = 0L)
check(booted.refusals.isEmpty())
heddle.reconcileCapacity(totalSlots = 4L)
// Attaching an author attaches its repository too, in the same unit.
val kuilt = GroupPath.Attached(listOf("repos"), "kuilt")
val alice = GroupPath.Nested(kuilt, "alice")
check(heddle.attach(alice, generation = 1L).refusals.isEmpty())
val aliceId = checkNotNull(ci.findGroupId(alice))
check(aliceId == GroupId("ci/repos/!kuilt/!alice") && ci.findPath(aliceId) == alice)
// Work is charged to the author; the repository itself is never leased.
val kuiltId = checkNotNull(ci.findGroupId(kuilt))
check(heddle.admit(kuiltId, waiting = setOf(kuiltId), startedAt = 0L) == AcquireOutcome.NoLiveLineage(kuiltId))
val lease = (heddle.acquire(setOf(aliceId), setOf(aliceId), startedAt = 0L) as AcquireOutcome.Acquired).lease
check(lease.leaf == aliceId)
// Detaching the repository closes alice too, and waits for her running job.
val detached = heddle.detach(kuilt)
check(detached.refusals.isNotEmpty() && detached.refusals.all { it is StepRefusal.Draining })
check(heddle.complete(lease.id, actualCost = 1L, waiting = emptySet()) is LeaseOutcome.Done)
check(heddle.detach(kuilt).refusals.isEmpty())