Documentation
¶
Overview ¶
Package orchestration provides DAG-based resource lifecycle management.
Index ¶
- func GetOutput[T any](reg *OutputRegistry, handlerName string, key string) (T, bool)
- func Register[TInput any, TOutput any](r *Reconciler, handler Lifecycle[TInput, TOutput], ...)
- type InputResolver
- type Lifecycle
- type LockEntry
- type LockFile
- type OutputRegistry
- type Reconciler
- type Snapshot
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOutput ¶
func GetOutput[T any](reg *OutputRegistry, handlerName string, key string) (T, bool)
GetOutput retrieves a typed output from the registry. Returns zero value if not found or type mismatch.
func Register ¶
func Register[TInput any, TOutput any]( r *Reconciler, handler Lifecycle[TInput, TOutput], resolver InputResolver[TInput], deps ...string, )
Register adds a typed resource with its input resolver and dependency list.
Types ¶
type InputResolver ¶
type InputResolver[TInput any] func(reg *OutputRegistry) ([]TInput, error)
InputResolver resolves inputs for a handler using outputs from upstream handlers.
type Lifecycle ¶
type Lifecycle[TInput any, TOutput any] interface { // Name returns the handler name for identification Name() string // Key generates a unique key for the given input Key(input TInput) string // Create provisions the resource using the given input Create(ctx context.Context, input TInput) (TOutput, error) // Destroy removes the resource using its output Destroy(ctx context.Context, output TOutput) error // Check verifies the resource status from its output Check(ctx context.Context, output TOutput) (Status, error) // Recover discovers a resource from its input when no lock entry exists Recover(ctx context.Context, input TInput) (TOutput, Status, error) }
Lifecycle defines how to create, destroy, and check a specific resource type. TInput represents the full input (including upstream outputs). TOutput represents the runtime output after resource creation. Change detection is handled by the framework via input hashing — no Equals() needed.
type LockEntry ¶
type LockEntry struct {
Key string `json:"key"`
Data any `json:"data"`
HandlerName string `json:"handler_name"`
InputHash string `json:"input_hash,omitempty"`
}
LockEntry represents a persisted resource snapshot in moley.lock.
type LockFile ¶
type LockFile struct {
Entries []LockEntry `json:"entries"`
// contains filtered or unexported fields
}
LockFile manages persistent storage of resource snapshots in moley.lock.
func LoadLockFile ¶
LoadLockFile loads moley.lock from disk and acquires an exclusive file lock. Returns an empty LockFile if the file is missing or corrupt.
func (*LockFile) PurgeOrphans ¶
PurgeOrphans removes lock entries whose handler name is not in the registered set.
type OutputRegistry ¶
type OutputRegistry struct {
// contains filtered or unexported fields
}
OutputRegistry holds outputs keyed by handler name + resource key.
type Reconciler ¶
type Reconciler struct {
// contains filtered or unexported fields
}
Reconciler manages the lifecycle of multiple typed resources in dependency order.
func NewReconciler ¶
func NewReconciler() (*Reconciler, error)
NewReconciler creates a new reconciler backed by the lock file registry.