GroupPath
Where a group sits in a Topology, read from root down: a child the config declares, a child the consumer attached while running beneath a group with a template, or a child it attached beneath one of those, whose template carries a template of its own.
The arms are what keep an attached child apart from a declared sibling of the same name: Attached(listOf("tenants"), "x") and Declared(listOf("tenants", "x")) are different paths, and Topology.findGroupId gives them different ids. Each group has exactly one path: a child of a declared group is Attached, and a child of an attached one is Nested.
Every name is non-empty, because no topology declares or attaches an empty one; a path holding one names nothing, so it cannot be built.
Samples
val pool = draft("pool") {
group("tenants") {
lane("x")
template()
}
}
// A declared lane and an attached child share the name `x`, and their paths stay apart.
val lane = GroupPath.Declared(listOf("tenants", "x"))
val tenant = GroupPath.Attached(group = listOf("tenants"), name = "x")
val laneId = checkNotNull(pool.findGroupId(lane))
val tenantId = checkNotNull(pool.findGroupId(tenant))
check(laneId == pool.groupId("tenants", "x") && tenantId == pool.attachedChildId(listOf("tenants"), "x"))
check(laneId != tenantId)
// Back from an id: the arm says whether the last name is an attached child's.
check(pool.findPath(laneId) == lane && pool.findPath(tenantId) == tenant)
check(pool.findPath(tenantId)?.names == listOf("tenants", "x"))
check(pool.findPath(pool.groupId()) == GroupPath.Declared(emptyList()))
// Not in this topology: `null`, never an exception.
check(pool.findGroupId(GroupPath.Declared(listOf("tenants", "y"))) == null)
check(pool.findGroupId(GroupPath.Attached(listOf("tenants", "x"), "y")) == null)
check(pool.findPath(GroupId("elsewhere/tenants")) == null)Content copied to clipboard