Documentation
¶
Index ¶
- Variables
- func Register(name string, exec Executable) errordeprecated
- func RegisterFactory(name string, factory Factory) errordeprecated
- func RegisterUnit(name string, exec Executable) errordeprecated
- func RegisterUnitFactory(name string, factory Factory) errordeprecated
- type ContextMap
- type ControlSignal
- type ControlSignalError
- type Executable
- type ExecutableUnit
- type ExecutionResult
- type Executor
- type Factory
- type Input
- type Node
- type Registration
- type Registry
- func (r *Registry) Clone() *Registry
- func (r *Registry) Names() []string
- func (r *Registry) New(name string) (Executable, bool)
- func (r *Registry) Register(name string, factory Factory) error
- func (r *Registry) RegisterAll(registrations ...Registration) error
- func (r *Registry) RegisterInstance(name string, exec Executable) error
- func (r *Registry) RegisterOrReplace(name string, factory Factory) error
- func (r *Registry) RegisterUnit(name string, exec Executable) error
- func (r *Registry) RegisterUnitFactory(name string, factory Factory) error
- func (r *Registry) Registrations() []Registration
- type Unit
Constants ¶
This section is empty.
Variables ¶
var DefaultRegistry = NewRegistry()
DefaultRegistry is retained for source compatibility with applications that registered units globally. New worker services clone it during construction and never share its mutable state.
Deprecated: create a Registry and pass it through worker.Options.UnitRegistry.
var ErrAlreadyRegistered = errors.New("unit already registered")
Functions ¶
func Register
deprecated
func Register(name string, exec Executable) error
Deprecated: register on an application-owned Registry instead.
func RegisterFactory
deprecated
func RegisterUnit
deprecated
func RegisterUnit(name string, exec Executable) error
Deprecated: register on an application-owned Registry instead.
func RegisterUnitFactory
deprecated
Types ¶
type ContextMap ¶
type ContextMap map[string]*ExecutionResult
type ControlSignal ¶
type ControlSignal string
const ( ControlBreak ControlSignal = "break" ControlContinue ControlSignal = "continue" ControlGoto ControlSignal = "goto" )
type ControlSignalError ¶
type ControlSignalError struct {
Signal ControlSignal
Target string
}
func (*ControlSignalError) Error ¶
func (e *ControlSignalError) Error() string
type Executable ¶
type Executable interface {
GetUnitMeta() *Unit
Execute(ctx context.Context, state ContextMap, self *Node) (*ExecutionResult, error)
}
func Find
deprecated
func Find(name string) (Executable, bool)
Deprecated: resolve from an application-owned Registry instead.
type ExecutableUnit ¶
type ExecutableUnit = Executable
type ExecutionResult ¶
type ExecutionResult struct {
NodeName string `json:"node_name,omitempty"`
Data any `json:"data,omitempty"`
Variables map[string]any `json:"variables,omitempty"`
DeleteVariables []string `json:"delete_variables,omitempty"`
Stream bool `json:"stream,omitempty"`
Raw any `json:"raw,omitempty"`
Error string `json:"error,omitempty"`
Control ControlSignal `json:"control,omitempty"`
ControlTarget string `json:"control_target,omitempty"`
}
func SimpleResult ¶
func SimpleResult(data any) *ExecutionResult
type Executor ¶
type Executor struct {
Registry *Registry
Credentials credential.Resolver
}
func NewExecutor ¶
func NewExecutorWithCredentials ¶
func NewExecutorWithCredentials(reg *Registry, credentials credential.Resolver) *Executor
func (*Executor) Execute ¶
func (e *Executor) Execute(ctx context.Context, task executor.ExecuteTask) (executor.ExecuteResult, error)
type Factory ¶
type Factory func() Executable
type Registration ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) RegisterAll ¶
func (r *Registry) RegisterAll(registrations ...Registration) error
RegisterAll validates the complete batch before changing the registry.
func (*Registry) RegisterInstance ¶
func (r *Registry) RegisterInstance(name string, exec Executable) error
func (*Registry) RegisterOrReplace ¶
RegisterOrReplace makes replacement explicit for applications that support hot swapping. Normal startup composition should use Register.
func (*Registry) RegisterUnit ¶
func (r *Registry) RegisterUnit(name string, exec Executable) error
func (*Registry) RegisterUnitFactory ¶
func (*Registry) Registrations ¶
func (r *Registry) Registrations() []Registration
Registrations returns a stable snapshot that can be installed into another registry without sharing mutable registry state.