Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrIllegalState is a sentinel error indicating that the state machine is in an illegal state. ErrIllegalState = errors.New("illegal state") // ErrDuplicateEdge is a sentinel error indicating that a duplicate edge has been defined by the consumer. ErrDuplicateEdge = errors.New("duplicate edge") // ErrCouldNotTransition is a sentinel error indicating that one could not transition from the current state ErrCouldNotTransition = errors.New("could not transition from current state") // ErrCannotHaveDiffParents is a sentinel error indicating that a state cannot have different parents ErrCannotHaveDiffParents = errors.New("state cannot have diff parent") // ErrNoOutEdges is a sentinel error indicating that a state has no outgoing edges ErrNoOutEdges = errors.New("no out edges") )
Functions ¶
This section is empty.
Types ¶
type Builder ¶
func (*Builder[S, E]) Build ¶
func (b *Builder[S, E]) Build() (stateMachine StateMachine[S, E], err error)
Build builds the Default State Machine. Internally ensures that indices are set on the edges for optimized adjacency list traversal
func (*Builder[S, E]) ConfigureState ¶
func (b *Builder[S, E]) ConfigureState(state S) StateConfigurator[S, E]
func (*Builder[S, E]) ConfigureSubState ¶
func (b *Builder[S, E]) ConfigureSubState(subState S, parentState S) StateConfigurator[S, E]
type Event ¶
type Event interface { ~string constraints.Ordered // if it is not used in a map then remove this }
type Resource ¶
type Resource[S State, E Event] interface { GetNamespace() string GetName() string // CurrentState returns the current state of the resource. It should be set at initialization to the initial state. // It is the resource implementor's responsibility to ensure this is concurrent safe. CurrentState() S // SetTransition records the given transition and also changes the current state of the resource. // It is the resource implementor's responsibility to ensure this is concurrent safe. SetTransition(transition Transition[S, E]) }
type State ¶
type State interface { ~string constraints.Ordered }
type StateConfigurator ¶
type StateConfigurator[S State, E Event] interface { ConfigureState(state S) StateConfigurator[S, E] ConfigureSubState(subState S, parentState S) StateConfigurator[S, E] Target(targetState S, events ...E) StateConfigurator[S, E] TargetWithGuard(targetState S, event E, guardLabel string, guardPredicate Guard[S, E]) StateConfigurator[S, E] Build() (StateMachine[S, E], error) }
type StateMachine ¶
Click to show internal directories.
Click to hide internal directories.