sfnutil

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sfnutil provides thin, idiomatic helpers over the AWS Step Functions (SFN) SDK v2: a Client wrapping *sfn.Client with convenience methods for provisioning state machines and activities, starting and inspecting executions, and the activity task-token lifecycle (poll, succeed, fail, heartbeat). It follows the awsgo *util convention.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoStateMachineName = errors.New("sfnutil: state machine name is required")

ErrNoStateMachineName is returned by helpers requiring a non-empty name.

Functions

This section is empty.

Types

type ActivityTask

type ActivityTask struct {
	TaskToken string
	Input     string
}

ActivityTask is a task polled from an activity queue. An empty TaskToken means the long poll timed out with no work — the caller should poll again.

type Client

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

Client wraps an AWS Step Functions SDK v2 client.

func NewClient

func NewClient(cfg aws.Config, optFns ...func(*sfn.Options)) *Client

NewClient builds a Client from an already-loaded aws.Config.

func NewClientDefault

func NewClientDefault(ctx context.Context, region string) (*Client, error)

NewClientDefault loads the default AWS config for the given region and returns a Client. Pass an empty region to use the SDK's default resolution.

func (*Client) CreateActivity

func (c *Client) CreateActivity(ctx context.Context, name string) (arn string, err error)

CreateActivity creates an activity (idempotent in SFN: creating one that already exists returns the existing ARN) and returns its ARN.

func (*Client) CreateStandardStateMachine

func (c *Client) CreateStandardStateMachine(ctx context.Context, name, definitionJSON, roleARN string) (arn string, err error)

CreateStandardStateMachine creates a STANDARD-type state machine and returns its ARN. STANDARD (not EXPRESS) is required for long-running, human-in-the- loop workflows.

func (*Client) DescribeExecution

func (c *Client) DescribeExecution(ctx context.Context, executionARN string) (*Execution, error)

DescribeExecution returns the current state of an execution.

func (*Client) FindStateMachineARN

func (c *Client) FindStateMachineARN(ctx context.Context, name string) (arn string, ok bool, err error)

FindStateMachineARN returns the ARN of the state machine with the given name, or ok=false if none exists. It pages through ListStateMachines.

func (*Client) PollActivityTask

func (c *Client) PollActivityTask(ctx context.Context, activityARN, workerName string) (*ActivityTask, error)

PollActivityTask long-polls for one task on the given activity. workerName is an optional identifier for observability. A returned task with an empty TaskToken indicates the poll timed out with no work available.

func (*Client) SFN

func (c *Client) SFN() *sfn.Client

SFN returns the underlying SDK client for calls not covered by a helper.

func (*Client) SendTaskFailure

func (c *Client) SendTaskFailure(ctx context.Context, taskToken, errCode, cause string) error

SendTaskFailure fails a task token with an error code and cause.

func (*Client) SendTaskHeartbeat

func (c *Client) SendTaskHeartbeat(ctx context.Context, taskToken string) error

SendTaskHeartbeat reports liveness for a long-running task token, resetting its heartbeat timeout.

func (*Client) SendTaskSuccess

func (c *Client) SendTaskSuccess(ctx context.Context, taskToken, outputJSON string) error

SendTaskSuccess completes a task token with the given JSON output.

func (*Client) StartExecution

func (c *Client) StartExecution(ctx context.Context, stateMachineARN, name, inputJSON string) (executionARN string, err error)

StartExecution starts a named execution and returns its ARN. The name is the idempotency key: SFN rejects a duplicate name with different input and is a no-op for an identical re-start, which is how run idempotency is enforced.

func (*Client) StopExecution

func (c *Client) StopExecution(ctx context.Context, executionARN, errCode, cause string) error

StopExecution aborts a running execution.

func (*Client) UpdateStateMachineDefinition

func (c *Client) UpdateStateMachineDefinition(ctx context.Context, stateMachineARN, definitionJSON, roleARN string) error

UpdateStateMachineDefinition updates an existing state machine's definition and role.

type Execution

type Execution struct {
	ARN    string
	Status types.ExecutionStatus
	Input  string
	Output string // empty unless the execution succeeded
}

Execution is a normalized view of DescribeExecution.

Jump to

Keyboard shortcuts

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