machine

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: Apache-2.0 Imports: 12 Imported by: 5

README

Step Machine

machine is an implementation of the AWS State Machine specification. The primary goal of this implementation is to enable testing of state machines and code together.

Continuing Development

Step at the moment is still very beta, and its API will likely change more before it stabilizes. If you have ideas for improvements please reach out.

Some of the TODOs left for the library are:

  1. Support for Parallel States
  2. Better Validations e.g. making sure all states are reachable and executable
  3. Client side visualization of state machine and execution using GraphViz

Documentation

Overview

State Machine implementation

State Machine Parser

Index

Constants

This section is empty.

Variables

View Source
var EmptyStateMachine = `{
  "StartAt": "WIN",
  "States": { "WIN": {"Type": "Succeed"}}
}`

EmptyStateMachine is a small Valid StateMachine

Functions

func DefaultHandler

func DefaultHandler(_ context.Context, input interface{}) (interface{}, error)

func Validate

func Validate(sm_json *string) error

Global Methods

Types

type Execution

type Execution struct {
	Output     map[string]interface{}
	OutputJSON string
	Error      error

	LastOutput     map[string]interface{} // interim output
	LastOutputJSON string
	LastError      error // interim error

	ExecutionHistory []HistoryEvent
}

func (*Execution) EnteredEvent

func (sm *Execution) EnteredEvent(s state.State, input interface{})

func (*Execution) ExitedEvent

func (sm *Execution) ExitedEvent(s state.State, output interface{})

func (*Execution) Failed

func (sm *Execution) Failed()

func (*Execution) Path

func (sm *Execution) Path() []string

Path returns the Path of States, ignoreing TaskFn states

func (*Execution) SetLastOutput

func (sm *Execution) SetLastOutput(output interface{}, err error)

func (*Execution) SetOutput

func (sm *Execution) SetOutput(output interface{}, err error)

func (*Execution) Start

func (sm *Execution) Start()

func (*Execution) Succeeded

func (sm *Execution) Succeeded()

type HistoryEvent

type HistoryEvent struct {
	sfn.HistoryEvent
}

type StateMachine

type StateMachine struct {
	Comment *string `json:",omitempty"`

	StartAt *string

	States States
}

StateMachine the core struct for the machine

func FromJSON

func FromJSON(raw []byte) (*StateMachine, error)

func ParseFile

func ParseFile(file string) (*StateMachine, error)

Takes a file, and a map of Task Function s

func (*StateMachine) DefaultLambdaContext

func (sm *StateMachine) DefaultLambdaContext(lambda_name string) context.Context

func (*StateMachine) Execute

func (sm *StateMachine) Execute(input interface{}) (*Execution, error)

func (*StateMachine) FindTask

func (sm *StateMachine) FindTask(name string) (*state.TaskState, error)

func (*StateMachine) SetDefaultHandler

func (sm *StateMachine) SetDefaultHandler()

func (*StateMachine) SetResource

func (sm *StateMachine) SetResource(lambda_arn *string)

func (*StateMachine) SetTaskFnHandlers

func (sm *StateMachine) SetTaskFnHandlers(tfs *handler.TaskHandlers) error

func (*StateMachine) SetTaskHandler

func (sm *StateMachine) SetTaskHandler(task_name string, resource_fn interface{}) error

func (*StateMachine) Tasks

func (sm *StateMachine) Tasks() map[string]*state.TaskState

func (*StateMachine) Validate

func (sm *StateMachine) Validate() error

type States

type States map[string]state.State

States is the collection of states

func (*States) UnmarshalJSON

func (sm *States) UnmarshalJSON(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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