Documentation ¶
Index ¶
Constants ¶
const StartState = "start"
StartState is a constant for defining the slug of the start state for all StateMachines.
Variables ¶
This section is empty.
Functions ¶
func CleanInput ¶
CleanInput converts the input string to only the following: - Lowercase Letters (a-z) - Numbers (0-9) - Spaces ( )
Uppercase letters are converted to lowercase letters, but any character outside of what is noted above is stripped from the string. Double (or more) spaces are converted into a single space.
func Step ¶
func Step(platform, uuid string, input interface{}, InputTransformer InputTransformer, store Store, emitter Emitter, stateMap StateMap)
Step performs a single step through a StateMachine.
This function handles the nuance of the logic for a single step through a state machine. ALL fsm-target's should call Step directly, and not attempt to handle the process of stepping through the StateMachine, so all platforms function with the same logic.
Types ¶
type BuildState ¶
BuildState is a function that generates a State with access to a specific Emitter and Traverser
type Emitter ¶
type Emitter interface {
Emit(interface{}) error
}
Emitter is a generic interface to output arbitrary data. Emit is generally called from State.EntryAction.
type InputTransformer ¶
InputTransformer converts the input of a platform to an *Intent.
type Intent ¶
type Intent struct { Slug string PlatformSlugs map[string]string Slots map[string]*Type Utterances []string }
Intent is an event that occurs that can trigger a transition
func TextInputTransformer ¶
TextInputTransformer is an implementation of an InputTransformer which handles text as the input type.
type State ¶
type State struct { Slug string Entry func(isReentry bool) error ValidIntents func() []*Intent Transition func(*Intent, map[string]string) *State }
State represents an individual state in a larger state machine
type StateMachine ¶
type StateMachine []BuildState
StateMachine is an array of all BuildState functions
type StateMap ¶ added in v0.2.1
type StateMap map[string]BuildState
StateMap is a k:v map for all BuildState functions in a StateMachine. This is exclusively utilized by the internal workings of targets.
func GetStateMap ¶
func GetStateMap(stateMachine StateMachine) StateMap
GetStateMap converts a StateMachine into a StateMap
type Store ¶
type Store interface { FetchTraverser(uuid string) (Traverser, error) CreateTraverser(uuid string) (Traverser, error) }
A Store is a generic interface responsible for managing The fetching and creation of traversers
type Traverser ¶
type Traverser interface { // UUID UUID() string SetUUID(string) // Platform Platform() string SetPlatform(string) // State CurrentState() string SetCurrentState(string) // Data Upsert(key string, value interface{}) Fetch(key string) interface{} Delete(key string) }
A Traverser is an individual that is traversing the StateMachine. This interface that is responsible for managing the state of that individual