The Machine Registry is a core component of the Arvo orchestration system that manages state machine definitions throughout their lifecycle. It functions as a central repository for storing machine definitions and resolving the appropriate machine instance for incoming events.
The Registry is a critical dependency of ArvoOrchestrator
, enabling dynamic machine resolution during event processing. The behavior of the registry can be customized by implementing the IMachineRegistry
interface and injecting it during orchestrator initialization.
interface IMachineRegistry {
// Collection of registered machine instances
machines: ArvoMachine[];
// Resolves appropriate machine for given event
resolve: (event: ArvoEvent, opentelemetry: Options) => ArvoMachine;
}
The system provides a default MachineRegistry
class implementing the core interface:
// Initialize with multiple machine versions
const registry = new MachineRegistry(
machineV1, // Initial version
machineV2, // Updated version
machineV3, // Latest version
);
// Resolve machine for incoming event
const machine = registry.resolve(event, {
inheritFrom: 'CONTEXT', // OpenTelemetry context configuration
});
The registry's resolution mechanism:
The registry throws specific errors for common failure cases:
// Initialization without machines
new MachineRegistry();
// Error: Machine registry initialization failed: No machines provided
// Resolution with unknown version
registry.resolve(eventWithUnknownVersion);
// Error: Machine resolution failed: No machine found matching orchestrator
You can create custom registry implementations for specific needs:
class CustomRegistry implements IMachineRegistry {
constructor(private machines: ArvoMachine[]) {}
resolve(event: ArvoEvent, telemetry: Options): ArvoMachine {
// Custom resolution logic
return this.machines.find(/* custom matching */);
}
}
Version Management
Performance Optimization
Error Handling
Through these capabilities, the Machine Registry ensures reliable and efficient machine management within the Arvo orchestration system.