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 ¶
- type Execution
- type Handler
- func (h *Handler) CreateStateMachine(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DeleteStateMachine(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DescribeStateMachine(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ListStateMachines(w http.ResponseWriter, r *http.Request)
- func (h *Handler) StartExecution(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Stop(ctx context.Context)
- type HistoryEvent
- type Service
- func (s *Service) Dispatch(w http.ResponseWriter, r *http.Request)
- func (s *Service) InitBus(bus *events.Bus)
- func (s *Service) InitRouter(router http.Handler)
- func (s *Service) Name() string
- func (s *Service) Operations() []op.Operation
- func (s *Service) RegisterRoutes(_ chi.Router)
- func (s *Service) Stop(ctx context.Context)
- func (s *Service) SupportedProtocols() []codec.Codec
- func (s *Service) TargetPrefix() string
- type StateMachine
- type Store
- func (st *Store) DeleteStateMachine(ctx context.Context, name string) error
- func (st *Store) GetExecution(ctx context.Context, arn string) (*Execution, error)
- func (st *Store) GetHistory(ctx context.Context, execARN string) ([]HistoryEvent, error)
- func (st *Store) GetStateMachine(ctx context.Context, name string) (*StateMachine, error)
- func (st *Store) ListExecutions(ctx context.Context, smARN string) ([]*Execution, error)
- func (st *Store) ListStateMachines(ctx context.Context) ([]*StateMachine, error)
- func (st *Store) PutExecution(ctx context.Context, exec *Execution) error
- func (st *Store) PutHistory(ctx context.Context, execARN string, events []HistoryEvent) error
- func (st *Store) PutStateMachine(ctx context.Context, sm *StateMachine) error
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)
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 (*Service) Dispatch ¶
func (s *Service) Dispatch(w http.ResponseWriter, r *http.Request)
Dispatch satisfies router.TargetDispatcher.
func (*Service) InitRouter ¶
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) Operations ¶
Operations implements router.ProtocolService.
func (*Service) RegisterRoutes ¶
RegisterRoutes satisfies router.Service. Step Functions has no path-routed endpoints.
func (*Service) Stop ¶
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 ¶
SupportedProtocols implements router.ProtocolService.
func (*Service) TargetPrefix ¶
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 ¶
DeleteStateMachine removes a state machine by name.
func (*Store) GetExecution ¶
GetExecution retrieves one execution by ARN. Returns nil, nil if not found.
func (*Store) GetHistory ¶
GetHistory returns an execution's recorded history events, oldest first.
func (*Store) GetStateMachine ¶
GetStateMachine retrieves a state machine by name. Returns nil, nil if not found.
func (*Store) ListExecutions ¶
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 ¶
PutExecution saves an execution record.
func (*Store) PutHistory ¶
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.