simple

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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 New

func New(opts ...Option) *Engine

New constructs a workflow engine seeded with the default page workflow.

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

Transition applies a workflow transition for an entity.

type Option

type Option func(*Engine)

Option configures the engine.

func WithClock

func WithClock(clock func() time.Time) Option

WithClock overrides the clock used for transition timestamps (primarily for testing).

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL