Documentation
¶
Overview ¶
Package framework provides resource lifecycle management.
Index ¶
- Constants
- func AddManager[TConfig any, TState any](ro *ResourceOrchestrator, handler ResourceHandler[TConfig, TState], ...)
- func RunWithDryRunGuard[T any](config *Config, cb func() (T, error), defaultValue T) (T, error)
- type Config
- type PersistentResourceEntry
- type ReconcileOperation
- type ResourceChecker
- type ResourceCreator
- type ResourceDestroyer
- type ResourceHandler
- type ResourceManager
- type ResourceNamer
- type ResourceOperation
- type ResourceOrchestrator
- type ResourceRecord
- type ResourceRegistry
Constants ¶
const (
RegistryFile = "moley.lock"
)
Variables ¶
This section is empty.
Functions ¶
func AddManager ¶ added in v2.1.0
func AddManager[TConfig any, TState any]( ro *ResourceOrchestrator, handler ResourceHandler[TConfig, TState], configs []TConfig, )
AddManager adds a typed resource manager to the orchestrator
Types ¶
type Config ¶
type Config struct {
DryRun bool
}
Config holds configuration for framework operations.
type PersistentResourceEntry ¶ added in v2.1.0
type PersistentResourceEntry struct {
Data any `json:"data"`
HandlerName string `json:"handler_name"`
}
PersistentResourceEntry represents a persisted resource in the registry file
type ReconcileOperation ¶ added in v2.1.0
type ReconcileOperation[TConfig any, TState any] struct { // contains filtered or unexported fields }
ReconcileOperation implements ResourceOperation for typed managers
func (*ReconcileOperation[TConfig, TState]) Execute ¶ added in v2.1.0
func (tro *ReconcileOperation[TConfig, TState]) Execute(ctx context.Context) error
func (*ReconcileOperation[TConfig, TState]) Name ¶ added in v2.1.0
func (tro *ReconcileOperation[TConfig, TState]) Name() string
type ResourceChecker ¶ added in v2.1.0
type ResourceChecker[TConfig any, TState any] interface { // CheckFromState checks the resource status from its runtime state CheckFromState(ctx context.Context, state TState) (domain.State, error) // CheckFromConfig checks the resource status from its configuration CheckFromConfig(ctx context.Context, config TConfig) (TState, domain.State, error) }
type ResourceCreator ¶ added in v2.1.0
type ResourceDestroyer ¶ added in v2.1.0
type ResourceHandler ¶
type ResourceHandler[TConfig any, TState any] interface { ResourceNamer ResourceChecker[TConfig, TState] ResourceCreator[TConfig, TState] ResourceDestroyer[TState] // Equals compares two configurations for equality // Used to detect when resources need to be updated Equals(a, b TConfig) bool }
ResourceHandler provides type-safe resource lifecycle management. TConfig represents the desired configuration (immutable input) TState represents the runtime state after resource creation (mutable state)
type ResourceManager ¶
ResourceManager manages resources of a specific type with full type safety
func NewResourceManager ¶
func NewResourceManager[TConfig any, TState any]( handler ResourceHandler[TConfig, TState], registry *ResourceRegistry, ) *ResourceManager[TConfig, TState]
NewResourceManager creates a type-safe resource manager for a specific handler type
type ResourceNamer ¶ added in v2.1.0
type ResourceNamer interface {
// Name returns the resource name for identification
Name() string
}
type ResourceOperation ¶ added in v2.1.0
type ResourceOperation interface {
Execute(ctx context.Context) error
Name() string
Stop(ctx context.Context) error
}
ResourceOperation represents a resource management operation
type ResourceOrchestrator ¶ added in v2.1.0
type ResourceOrchestrator struct {
// contains filtered or unexported fields
}
ResourceOrchestrator manages the lifecycle of multiple typed resource managers
func NewResourceOrchestrator ¶ added in v2.1.0
func NewResourceOrchestrator() (*ResourceOrchestrator, error)
NewResourceOrchestrator creates a new resource orchestrator
type ResourceRecord ¶ added in v2.1.0
type ResourceRecord[TConfig any, TState any] struct { State TState `json:"state"` Config TConfig `json:"config"` }
ResourceRecord represents the business data for a managed resource (config + runtime state)
type ResourceRegistry ¶ added in v2.1.0
type ResourceRegistry struct {
Entries []PersistentResourceEntry `json:"entries"`
}
ResourceRegistry manages persistent storage of resource state
func LoadResourceRegistry ¶ added in v2.1.0
func LoadResourceRegistry() (*ResourceRegistry, error)
LoadResourceRegistry loads the resource registry from persistent storage
func (*ResourceRegistry) Add ¶ added in v2.1.0
func (rr *ResourceRegistry) Add(entry PersistentResourceEntry) error
Add adds a persistent resource entry to the registry
func (*ResourceRegistry) Remove ¶ added in v2.1.0
func (rr *ResourceRegistry) Remove(entry PersistentResourceEntry) error
Remove removes a persistent resource entry from the registry
func (*ResourceRegistry) Save ¶ added in v2.1.0
func (rr *ResourceRegistry) Save() error
Save persists the resource registry to storage