---
title: "Step methods"
description: "For the Step concept, read Step."
canonical_url: "https://docs.superdurable.io/zh-Hans/reference/go/step/"
source: "docs/reference/go/step.mdx"
locale: "zh-Hans"
---

# Step methods

For the Step concept, read [Step](https://docs.superdurable.io/zh-Hans/concepts/step.md).

<a id="commit-boundary"></a>

## Commits

Dex commits each **WaitFor** call and each **Execute** call separately. Dex
Server holds the Attribute writes and Channel publications of the method. It
commits them together with the returned **Wait** or **StepDecision**, and only
after the method returns successfully. If the method fails, Dex commits none of
them. Calls to external APIs are not part of this commit.

Before it returns, a method can send
[heartbeat checkpoints](https://docs.superdurable.io/zh-Hans/reference/go/step-options.md#heartbeat) and any number of best-effort
[Stream messages](https://docs.superdurable.io/zh-Hans/concepts/primitives/stream.md). They are not part of the
method's commit. A Stream Store failure does not fail the Step.

<a id="step-execution-local"></a>

## Step execution local

**SetStepExecutionLocal** stores a value on the current Step execution.
**Execute** reads it with **GetStepExecutionLocal**. Use it to pass a value from
**WaitFor** to **Execute** when a Flow-level Attribute is more than you need.
Both methods already receive the Step input, so do not copy the input into a
local.

```go
func (noteWait) WaitFor(ctx dex.Context, input int) (*dex.Wait, error) {
	if err := ctx.SetStepExecutionLocal("note", fmt.Sprintf("approval:%d", input)); err != nil {
		return nil, err
	}
	return dex.Until(Approval.ForOne()), nil
}

func (noteWait) Execute(ctx dex.Context, _ int) (*dex.StepDecision, error) {
	var note string
	found, err := ctx.GetStepExecutionLocal("note", &note)
	if err != nil {
		return nil, err
	}
	if !found {
		return nil, fmt.Errorf("note was not set")
	}
	return dex.GracefulComplete(note), nil
}
```

Example: [examples/go/primitives/step-execution-local/workflow.go](https://github.com/superdurable/dex/tree/main/examples/go/primitives/step-execution-local/workflow.go)
