Skip to content
docsv0.1.0

ProcessDefinitionRegistry

Maps a process definition's name to its built {@see ProcessDefinition} — the directory a consumer registers every process it wants callable by name (typically at boot) and the `process_instantiate` tool (see {@see \Milpa\Orchestrator\Tools\ProcessInstantiateTool}) resolves through when a caller names a definition to start. Also the seam {@see ProcessRunner} resolves a {@see SubprocessSpec::$definitionRef} through at runtime when entering a subprocess state. `register()` validates the definition-REFERENCE graph (which name's subprocess states point at which other names, transitively) stays acyclic — a process cannot, directly or through any chain of subprocess states, end up waiting on itself. This is a STATIC, name-level check, independent of {@see ProcessRunner}'s own runtime depth limit (which guards the same failure mode at the instance level, in case a cycle somehow slips past this check — e.g. a definition mutated after registration).

ProcessDefinitionRegistry::register()

public function register(string $name, Milpa\Orchestrator\ProcessDefinition $definition): void

Registers `$definition` under `$name`, overwriting any prior registration for the same name. Rolled back entirely (the registry ends up exactly as it was before this call) when the resulting definition-reference graph turns out cyclic, so a caller that catches the exception and keeps using this registry is not left with a partially-corrupted graph.

Parameters

Parameters of register()
NameTypeDescription
$namestring
$definitionMilpa\Orchestrator\ProcessDefinition

Throws

\RuntimeException when this registration completes a cycle in the definition-reference graph (`$name`, directly or transitively through any subprocess state, references itself)

ProcessDefinitionRegistry::has()

public function has(string $name): bool

Whether a definition is registered under `$name`.

Parameters

Parameters of has()
NameTypeDescription
$namestring

ProcessDefinitionRegistry::get()

public function get(string $name): Milpa\Orchestrator\ProcessDefinition

The definition registered under `$name`.

Parameters

Parameters of get()
NameTypeDescription
$namestring

Throws

\RuntimeException when no definition is registered under `$name`

ProcessDefinitionRegistry::names()

public function names(): array

Every registered definition's name, in registration order.