Documentation
¶
Index ¶
- type BaseHandler
- func (h *BaseHandler[T]) FlushState(ctx context.Context, report *automa.Report, intent models.Intent, ...) (*automa.Report, error)
- func (h *BaseHandler[T]) HandleIntent(ctx context.Context, intent models.Intent, inputs models.UserInputs[T], ...) (*automa.Report, error)
- func (h *BaseHandler[T]) ValidateIntent(intent models.Intent, inputs models.UserInputs[T], target models.TargetType) error
- type IntentHandler
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseHandler ¶
type BaseHandler[T any] struct { Runtime *rsl.RuntimeResolver }
BaseHandler holds the three dependencies that every node-type handler needs: a StateManager for reading and writing state, the rsl Runtime, and the reality Checker for live machine-state queries.
Embed this struct in any concrete handler to inherit RefreshRuntimeState and FlushState without re-implementing them.
type BlockNodeHandler struct {
BaseHandler
install *BlockNodeInstallHandler
upgrade *BlockNodeUpgradeHandler
reset *BlockNodeResetHandler
uninstall *BlockNodeUninstallHandler
}
func NewBaseHandler ¶
func NewBaseHandler[T any](reg *rsl.RuntimeResolver) (BaseHandler[T], error)
NewBaseHandler validates the required dependencies and returns a populated BaseHandler. All fields are required; any nil returns an error.
func (*BaseHandler[T]) FlushState ¶
func (h *BaseHandler[T]) FlushState( ctx context.Context, report *automa.Report, intent models.Intent, effectiveInputs *models.UserInputs[T], callback func(full *state.State, effInputs models.UserInputs[T]) error, ) (*automa.Report, error)
FlushState is the exported generic flush used by all node handlers.
func (*BaseHandler[T]) HandleIntent ¶
func (h *BaseHandler[T]) HandleIntent( ctx context.Context, intent models.Intent, inputs models.UserInputs[T], ac IntentHandler[T], callback func(full *state.State, effInputs models.UserInputs[T]) error, ) (*automa.Report, error)
HandleIntent is the shared generic handler. It performs the following steps:
- Validates the intent and user inputs.
- Sets user inputs into the runtime state for effective-value resolution.
- Refreshes the runtime state to ensure it's up-to-date before workflow execution.
- Delegates to the per-action handler to prepare effective inputs and build the workflow, then executes it.
- Flushes the updated state to disk, performing three live refreshes before persistence.
The callback parameter is an optional function that allows per-action handlers to apply additional mutations to the full state before it is flushed to disk.
func (*BaseHandler[T]) ValidateIntent ¶
func (h *BaseHandler[T]) ValidateIntent(intent models.Intent, inputs models.UserInputs[T], target models.TargetType) error
type IntentHandler ¶
type IntentHandler[I any] interface { // PrepareEffectiveInputs resolves the winning value for each field from the // three sources (config default, current deployed state, user input) and // applies all field-level validators (immutability, override guards, etc.). // The returned inputs are fully resolved and safe to pass to BuildWorkflow. PrepareEffectiveInputs(intent models.Intent, inputs models.UserInputs[I]) (*models.UserInputs[I], error) // BuildWorkflow validates action-level preconditions (e.g. "must be deployed // before upgrade") and returns the ready-to-execute WorkflowBuilder. BuildWorkflow( currentState state.State, inputs models.UserInputs[I], ) (*automa.WorkflowBuilder, error) // HandleIntent is the one-stop shop for handling an intent end-to-end. It calls // PrepareEffectiveInputs and BuildWorkflow in sequence, returning the final // report or any error encountered along the way. This is the method that // should be called by the router; the other two are for internal handler use // and unit testing. HandleIntent( ctx context.Context, intent models.Intent, inputs models.UserInputs[I], ) (*automa.Report, error) }
IntentHandler is the contract every per-action, per-node-type handler must satisfy. [I any] is the node-specific inputs struct (e.g. models.BlockNodeInputs).
Splitting at this boundary means:
- Each handler is independently unit-testable with zero routing boilerplate.
- Adding a new action (e.g. ActionMigrate) is a new file, not a new switch arm.
- Adding a new node type (MirrorNode) is a new package, not a new God struct.