Help us shape the future of Go! Take the 2026 Go Developer Survey

stepfunctions

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package stepfunctions emulates AWS Step Functions over JSON 1.0: state machines, activities and an ASL interpreter that runs each execution in the background (Lambda and service integrations, callbacks, Retry/Catch, Parallel, Map, intrinsics) and records its full history.

Index

Constants

This section is empty.

Variables

View Source
var MaxWait = 60 * time.Second

MaxWait caps every real sleep (Wait states and Retry backoff) so local runs never stall. This is on purpose, a known difference from AWS (a Wait of 3600 seconds ends after 60), listed in docs/reference/coverage.yaml. Do not remove it without the owner's say-so.

View Source
var RetrySpeedup = 1.0

RetrySpeedup divides Retry intervals: 10 makes retries ten times faster than on AWS.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	ARN     string            `json:"arn"`
	Name    string            `json:"name"`
	Account string            `json:"account"`
	Region  string            `json:"region"`
	Created time.Time         `json:"created"`
	Tags    map[string]string `json:"tags,omitempty"`
}

Activity is a task queue served by external workers.

type Alias

type Alias struct {
	ARN         string    `json:"arn"`
	Name        string    `json:"name"`
	MachineARN  string    `json:"machineArn"`
	Description string    `json:"description,omitempty"`
	Routes      []route   `json:"routes"`
	Created     time.Time `json:"created"`
	Updated     time.Time `json:"updated"`
}

Alias points at one or two versions of a state machine.

type Catcher

type Catcher struct {
	ErrorEquals    []string
	ResultPath     jpath
	Next           string
	Output, Assign any // Output is JSONata only
}

Catcher is one Catch entry.

type Def

type Def struct {
	StartAt        string
	States         map[string]*State
	TimeoutSeconds int
	QueryLanguage  string
	// contains filtered or unexported fields
}

Def is a state machine, a Parallel branch or a Map item processor.

type Execution

type Execution struct {
	ARN        string           `json:"arn"`
	Name       string           `json:"name"`
	MachineARN string           `json:"machineArn"`
	Account    string           `json:"account"`
	Region     string           `json:"region"`
	Definition string           `json:"definition"` // as of the start
	RoleArn    string           `json:"roleArn"`
	Updated    time.Time        `json:"updated"`              // machine update date as of the start
	VersionARN string           `json:"versionArn,omitempty"` // when started through a version or an alias
	AliasARN   string           `json:"aliasArn,omitempty"`
	Status     string           `json:"status"`
	Input      string           `json:"input"`
	Output     string           `json:"output,omitempty"`
	Error      string           `json:"error,omitempty"`
	Cause      string           `json:"cause,omitempty"`
	Start      time.Time        `json:"start"`
	Stop       time.Time        `json:"stop,omitzero"`
	Events     []map[string]any `json:"events"`
	// contains filtered or unexported fields
}

Execution is one run of a state machine with its history.

type Machine

type Machine struct {
	ARN         string            `json:"arn"`
	Name        string            `json:"name"`
	Account     string            `json:"account"`
	Region      string            `json:"region"`
	Type        string            `json:"type"`
	Definition  string            `json:"definition"`
	RoleArn     string            `json:"roleArn"`
	Logging     json.RawMessage   `json:"logging,omitempty"`
	Tracing     json.RawMessage   `json:"tracing,omitempty"`
	Revision    string            `json:"revision"`
	LastVersion int               `json:"lastVersion,omitempty"` // the newest version number; numbers are not reused
	Created     time.Time         `json:"created"`
	Updated     time.Time         `json:"updated"`
	Tags        map[string]string `json:"tags,omitempty"`
}

Machine is a state machine.

type Retrier

type Retrier struct {
	ErrorEquals     []string
	IntervalSeconds *float64
	MaxAttempts     *int
	BackoffRate     *float64
	MaxDelaySeconds float64
}

Retrier is one Retry entry.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the Step Functions emulator.

func New

func New(hub *core.Hub) *Service

New creates the Step Functions service.

func (*Service) Close

func (s *Service) Close() error

Close stops running executions.

func (*Service) History

func (s *Service) History(executionArn string) []map[string]any

History returns an execution's events (nil when unknown).

func (*Service) Info

func (s *Service) Info() core.Info

func (*Service) Inspect

func (s *Service) Inspect(table, id string) any

Inspect shows a state machine with its recent executions, or an execution with its history.

func (*Service) Load

func (s *Service) Load(b []byte) error

Load restores state; executions that were running fail with pogi.Restarted.

func (*Service) Reset

func (s *Service) Reset()

func (*Service) Resources

func (s *Service) Resources() []core.Table

Resources lists state machines and the latest executions.

func (*Service) Save

func (s *Service) Save() ([]byte, error)

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Service) StartConsole

func (s *Service) StartConsole(account, region, smArn, input string) (string, error)

StartConsole starts an execution from the console; smArn may also be a bare name.

type State

type State struct {
	Type, Next, Default, Resource string
	End                           bool
	QueryLanguage                 string

	InputPath, OutputPath, ResultPath, ItemsPath jpath
	Parameters, ResultSelector, ItemSelector     any
	Arguments, Output, Items                     any // JSONata states
	Assign, ItemReader                           any
	Result                                       json.RawMessage
	TimeoutSeconds, HeartbeatSeconds, Seconds    num
	TimeoutSecondsPath                           string
	Retry                                        []Retrier
	Catch                                        []Catcher
	Choices                                      []map[string]any
	SecondsPath, Timestamp, TimestampPath        string
	Error, Cause, ErrorPath, CausePath           string
	Branches                                     []*Def
	Iterator, ItemProcessor                      *Def
	MaxConcurrency                               num
	MaxConcurrencyPath                           string
	ToleratedFailureCount                        num // Map: checked, not applied (a failed item still fails the Map)
	ToleratedFailurePercentage                   num
	ToleratedFailureCountPath                    string
	ToleratedFailurePercentagePath               string
	// contains filtered or unexported fields
}

State is one ASL state; the fields its type does not use stay zero.

type Version

type Version struct {
	ARN         string          `json:"arn"`
	MachineARN  string          `json:"machineArn"`
	Number      int             `json:"number"`
	Description string          `json:"description,omitempty"`
	Type        string          `json:"type"`
	Definition  string          `json:"definition"`
	RoleArn     string          `json:"roleArn"`
	Logging     json.RawMessage `json:"logging,omitempty"`
	Tracing     json.RawMessage `json:"tracing,omitempty"`
	Revision    string          `json:"revision"`
	Created     time.Time       `json:"created"`
}

Version is a published copy of a state machine.

Jump to

Keyboard shortcuts

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