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 ¶
- Variables
- type ActivityTask
- type Client
- func (c *Client) CreateActivity(ctx context.Context, name string) (arn string, err error)
- func (c *Client) CreateStandardStateMachine(ctx context.Context, name, definitionJSON, roleARN string) (arn string, err error)
- func (c *Client) DescribeExecution(ctx context.Context, executionARN string) (*Execution, error)
- func (c *Client) FindStateMachineARN(ctx context.Context, name string) (arn string, ok bool, err error)
- func (c *Client) PollActivityTask(ctx context.Context, activityARN, workerName string) (*ActivityTask, error)
- func (c *Client) SFN() *sfn.Client
- func (c *Client) SendTaskFailure(ctx context.Context, taskToken, errCode, cause string) error
- func (c *Client) SendTaskHeartbeat(ctx context.Context, taskToken string) error
- func (c *Client) SendTaskSuccess(ctx context.Context, taskToken, outputJSON string) error
- func (c *Client) StartExecution(ctx context.Context, stateMachineARN, name, inputJSON string) (executionARN string, err error)
- func (c *Client) StopExecution(ctx context.Context, executionARN, errCode, cause string) error
- func (c *Client) UpdateStateMachineDefinition(ctx context.Context, stateMachineARN, definitionJSON, roleARN string) error
- type Execution
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 NewClientDefault ¶
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 ¶
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 ¶
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) SendTaskFailure ¶
SendTaskFailure fails a task token with an error code and cause.
func (*Client) SendTaskHeartbeat ¶
SendTaskHeartbeat reports liveness for a long-running task token, resetting its heartbeat timeout.
func (*Client) SendTaskSuccess ¶
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 ¶
StopExecution aborts a running execution.