Documentation
¶
Index ¶
- Variables
- type Engine
- func (e *Engine) AvailableTransitions(ctx context.Context, query interfaces.TransitionQuery) ([]WorkflowTransition, error)
- func (e *Engine) RegisterWorkflow(ctx context.Context, definition interfaces.WorkflowDefinition) error
- func (e *Engine) Transition(ctx context.Context, input interfaces.TransitionInput) (*interfaces.TransitionResult, error)
- type Option
- type WorkflowDefinition
- type WorkflowTransition
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnknownEntityType indicates no workflow definition exists for the requested entity. ErrUnknownEntityType = errors.New("workflow: entity type not registered") // ErrInvalidTransition indicates the requested transition is not allowed. ErrInvalidTransition = errors.New("workflow: transition not allowed") // ErrMissingTransition indicates neither a transition name nor target state were supplied. ErrMissingTransition = errors.New("workflow: transition name or target state required") // ErrNilEntityID signals input validation failure. ErrNilEntityID = errors.New("workflow: entity id required") )
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is a simple in-memory workflow engine that executes deterministic state transitions.
func (*Engine) AvailableTransitions ¶
func (e *Engine) AvailableTransitions(ctx context.Context, query interfaces.TransitionQuery) ([]WorkflowTransition, error)
AvailableTransitions returns the transitions reachable from the supplied state.
func (*Engine) RegisterWorkflow ¶
func (e *Engine) RegisterWorkflow(ctx context.Context, definition interfaces.WorkflowDefinition) error
RegisterWorkflow installs a workflow definition for the supplied entity type.
func (*Engine) Transition ¶
func (e *Engine) Transition(ctx context.Context, input interfaces.TransitionInput) (*interfaces.TransitionResult, error)
Transition applies a workflow transition for an entity.
type WorkflowDefinition ¶
type WorkflowDefinition = interfaces.WorkflowDefinition
WorkflowDefinition mirrors interfaces.WorkflowDefinition for return paths.
type WorkflowTransition ¶
type WorkflowTransition = interfaces.WorkflowTransition
WorkflowTransition mirrors interfaces.WorkflowTransition while keeping the package self-contained for consumers of AvailableTransitions.
Click to show internal directories.
Click to hide internal directories.