stepfunctions

package
v0.0.1-alpha.30 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package stepfunctions provides emulation of AWS Step Functions. See docs/services/stepfunctions.md for the support matrix (when available).

Wire protocol: JSON 1.0 (X-Amz-Target: AWSStepFunctions.*) and RPC v2 CBOR. Implements: CreateStateMachine, DescribeStateMachine, ListStateMachines, StartExecution, DeleteStateMachine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Execution

type Execution struct {
	ExecutionArn    string     `json:"ExecutionArn"`
	StateMachineArn string     `json:"StateMachineArn"`
	Name            string     `json:"Name"`
	Input           string     `json:"Input"`
	Output          string     `json:"Output,omitempty"`
	Status          string     `json:"Status"`
	StartDate       time.Time  `json:"StartDate"`
	StopDate        *time.Time `json:"StopDate,omitempty"`
	// Error and Cause carry the AWS-shaped failure reason for a FAILED,
	// TIMED_OUT or ABORTED execution — including the loud "not supported"
	// failures Overcast raises for ASL features it does not interpret.
	Error string `json:"Error,omitempty"`
	Cause string `json:"Cause,omitempty"`
}

Execution represents a Step Functions execution.

type Handler

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

Handler holds Step Functions handler dependencies.

func (*Handler) CreateStateMachine

func (h *Handler) CreateStateMachine(w http.ResponseWriter, r *http.Request)

func (*Handler) DeleteStateMachine

func (h *Handler) DeleteStateMachine(w http.ResponseWriter, r *http.Request)

func (*Handler) DescribeStateMachine

func (h *Handler) DescribeStateMachine(w http.ResponseWriter, r *http.Request)

func (*Handler) ListStateMachines

func (h *Handler) ListStateMachines(w http.ResponseWriter, r *http.Request)

func (*Handler) StartExecution

func (h *Handler) StartExecution(w http.ResponseWriter, r *http.Request)

func (*Handler) Stop

func (h *Handler) Stop(ctx context.Context)

Stop drains in-flight executions. It first cancels them — an execution parked in a Wait would otherwise hold shutdown open for its whole budget — then waits for the goroutines to finish writing their terminal state, or until ctx expires.

Satisfies router.Stopper.

type HistoryEvent

type HistoryEvent struct {
	// Timestamp is epoch seconds with millisecond precision — the AWS JSON 1.0
	// and RPC v2 CBOR wire representation of a Step Functions timestamp, and
	// also how the event is persisted.
	Timestamp       float64 `json:"timestamp" cbor:"timestamp"`
	Type            string  `json:"type" cbor:"type"`
	ID              int64   `json:"id" cbor:"id"`
	PreviousEventID int64   `json:"previousEventId" cbor:"previousEventId"`

	ExecutionStarted   *executionStartedDetails   `json:"executionStartedEventDetails,omitempty" cbor:"executionStartedEventDetails,omitempty"`
	ExecutionSucceeded *executionSucceededDetails `json:"executionSucceededEventDetails,omitempty" cbor:"executionSucceededEventDetails,omitempty"`
	ExecutionFailed    *errorCauseDetails         `json:"executionFailedEventDetails,omitempty" cbor:"executionFailedEventDetails,omitempty"`
	ExecutionAborted   *errorCauseDetails         `json:"executionAbortedEventDetails,omitempty" cbor:"executionAbortedEventDetails,omitempty"`
	ExecutionTimedOut  *errorCauseDetails         `json:"executionTimedOutEventDetails,omitempty" cbor:"executionTimedOutEventDetails,omitempty"`

	StateEntered *stateEnteredDetails `json:"stateEnteredEventDetails,omitempty" cbor:"stateEnteredEventDetails,omitempty"`
	StateExited  *stateExitedDetails  `json:"stateExitedEventDetails,omitempty" cbor:"stateExitedEventDetails,omitempty"`

	TaskScheduled *taskScheduledDetails `json:"taskScheduledEventDetails,omitempty" cbor:"taskScheduledEventDetails,omitempty"`
	TaskStarted   *taskStartedDetails   `json:"taskStartedEventDetails,omitempty" cbor:"taskStartedEventDetails,omitempty"`
	TaskSucceeded *taskSucceededDetails `json:"taskSucceededEventDetails,omitempty" cbor:"taskSucceededEventDetails,omitempty"`
	TaskFailed    *taskErrorDetails     `json:"taskFailedEventDetails,omitempty" cbor:"taskFailedEventDetails,omitempty"`
	TaskTimedOut  *taskErrorDetails     `json:"taskTimedOutEventDetails,omitempty" cbor:"taskTimedOutEventDetails,omitempty"`

	LambdaFunctionScheduled *lambdaScheduledDetails `json:"lambdaFunctionScheduledEventDetails,omitempty" cbor:"lambdaFunctionScheduledEventDetails,omitempty"`
	LambdaFunctionSucceeded *lambdaSucceededDetails `json:"lambdaFunctionSucceededEventDetails,omitempty" cbor:"lambdaFunctionSucceededEventDetails,omitempty"`
	LambdaFunctionFailed    *errorCauseDetails      `json:"lambdaFunctionFailedEventDetails,omitempty" cbor:"lambdaFunctionFailedEventDetails,omitempty"`
	LambdaFunctionTimedOut  *errorCauseDetails      `json:"lambdaFunctionTimedOutEventDetails,omitempty" cbor:"lambdaFunctionTimedOutEventDetails,omitempty"`

	MapStateStarted *mapStateStartedDetails `json:"mapStateStartedEventDetails,omitempty" cbor:"mapStateStartedEventDetails,omitempty"`

	MapIterationStarted   *mapIterationDetails `json:"mapIterationStartedEventDetails,omitempty" cbor:"mapIterationStartedEventDetails,omitempty"`
	MapIterationSucceeded *mapIterationDetails `json:"mapIterationSucceededEventDetails,omitempty" cbor:"mapIterationSucceededEventDetails,omitempty"`
	MapIterationFailed    *mapIterationDetails `json:"mapIterationFailedEventDetails,omitempty" cbor:"mapIterationFailedEventDetails,omitempty"`
}

HistoryEvent is one execution-history entry. It is persisted as-is and returned by GetExecutionHistory, so the JSON tags are both the storage format and the wire format.

type Service

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

Service implements router.Service and router.TargetDispatcher for Step Functions.

func New

func New(cfg *config.Config, store state.Store, logger *zap.Logger, clk clock.Clock) *Service

New returns a configured Step Functions Service.

func (*Service) Dispatch

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

Dispatch satisfies router.TargetDispatcher.

func (*Service) InitBus

func (s *Service) InitBus(bus *events.Bus)

InitBus wires the event bus for state machine lifecycle events.

func (*Service) InitRouter

func (s *Service) InitRouter(router http.Handler)

InitRouter wires Overcast's root router so Task states can reach the other emulated services. Storing the handle is all this does — no I/O — so it is safe to call from router.New(). Until it is called, a Task state fails the execution loudly rather than being skipped.

func (*Service) Name

func (s *Service) Name() string

Name satisfies router.Service.

func (*Service) Operations

func (s *Service) Operations() []op.Operation

Operations implements router.ProtocolService.

func (*Service) RegisterRoutes

func (s *Service) RegisterRoutes(_ chi.Router)

RegisterRoutes satisfies router.Service. Step Functions has no path-routed endpoints.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context)

Stop satisfies router.Stopper. Executions run on their own goroutines, so shutdown cancels them and waits for each to write its terminal state, or until ctx expires.

func (*Service) SupportedProtocols

func (s *Service) SupportedProtocols() []codec.Codec

SupportedProtocols implements router.ProtocolService.

func (*Service) TargetPrefix

func (s *Service) TargetPrefix() string

TargetPrefix satisfies router.TargetDispatcher. The AWS SDK sends "AWSStepFunctions." as the target prefix; "AmazonStates." is an older alias.

type StateMachine

type StateMachine struct {
	Name       string    `json:"Name"`
	ARN        string    `json:"ARN"`
	Definition string    `json:"Definition"`
	RoleArn    string    `json:"RoleArn"`
	Type       string    `json:"Type"` // "STANDARD" or "EXPRESS"
	Status     string    `json:"Status"`
	CreatedAt  time.Time `json:"CreatedAt"`
}

StateMachine represents a Step Functions state machine.

type Store

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

Store wraps state.Store with Step Functions-specific helpers.

func (*Store) DeleteStateMachine

func (st *Store) DeleteStateMachine(ctx context.Context, name string) error

DeleteStateMachine removes a state machine by name.

func (*Store) GetExecution

func (st *Store) GetExecution(ctx context.Context, arn string) (*Execution, error)

GetExecution retrieves one execution by ARN. Returns nil, nil if not found.

func (*Store) GetHistory

func (st *Store) GetHistory(ctx context.Context, execARN string) ([]HistoryEvent, error)

GetHistory returns an execution's recorded history events, oldest first.

func (*Store) GetStateMachine

func (st *Store) GetStateMachine(ctx context.Context, name string) (*StateMachine, error)

GetStateMachine retrieves a state machine by name. Returns nil, nil if not found.

func (*Store) ListExecutions

func (st *Store) ListExecutions(ctx context.Context, smARN string) ([]*Execution, error)

ListExecutions returns every execution of one state machine, newest first.

Execution ARNs embed the state machine name, so the store key prefix scopes the scan to that machine rather than walking every execution in the region. A record that cannot be decoded is skipped rather than failing the whole list — one corrupt row must not take out the page.

func (*Store) ListStateMachines

func (st *Store) ListStateMachines(ctx context.Context) ([]*StateMachine, error)

ListStateMachines returns all state machines.

func (*Store) PutExecution

func (st *Store) PutExecution(ctx context.Context, exec *Execution) error

PutExecution saves an execution record.

func (*Store) PutHistory

func (st *Store) PutHistory(ctx context.Context, execARN string, events []HistoryEvent) error

PutHistory saves an execution's history in one write. The interpreter accumulates events in memory and calls this once, so a long execution costs a single store write rather than one per state transition.

func (*Store) PutStateMachine

func (st *Store) PutStateMachine(ctx context.Context, sm *StateMachine) error

PutStateMachine saves a state machine record.

Jump to

Keyboard shortcuts

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