Steps API
turbine.Do
func Do[R any](ctx turbine.Context, fn func(context.Context) (R, error), opts ...StepOption) (R, error)Execute a durable step. The result is recorded in SQLite and replayed on recovery.
Options:
| Option | Description |
|---|---|
WithStepName(name) | Name for the step |
WithStepMaxRetries(n) | Max retry attempts |
WithBackoffFactor(f) | Exponential backoff multiplier |
WithBaseInterval(d) | Initial delay between retries |
WithMaxInterval(d) | Maximum delay between retries |
WithoutCheckpoint() | Skip persisting result, step re-executes on recovery (details) |
turbine.DoAsync
func DoAsync[R any](ctx turbine.Context, fn Step[R], opts ...StepOption) (chan AsyncResult[R], error)Execute a step asynchronously. Returns a channel that receives the result.
turbine.Sleep
func Sleep(ctx turbine.Context, duration time.Duration) errorDurable sleep. Survives crashes and restarts, on recovery, sleeps only the remaining duration. To wait for an event instead of a fixed time, use turbine.Recv.
turbine.SleepUntil
func SleepUntil(ctx turbine.Context, t time.Time) errorDurable sleep until t, returns at once if t has passed. The first target is recorded, so a restart wakes at the same time even if t is computed again from time.Now().
turbine.Pause
func Pause(ctx turbine.Context, duration time.Duration) errorAlias for turbine.Sleep.
turbine.WaitForApproval
func WaitForApproval(ctx turbine.Context, opts ...ApprovalOption) (ApprovalResult, error)Block until an approval or rejection is received (via dashboard or API). See Approvals.
Options:
| Option | Description |
|---|---|
WithApprovalTimeout(d) | Max wait duration (default: indefinite) |
Context Helpers
turbine.LoggerFrom(ctx context.Context) *slog.Logger
turbine.AppFrom(ctx context.Context) core.AppAccess the logger and app from within step functions.
turbine.SetAppStatus
func SetAppStatus(ctx context.Context, label, color string) errorSet app status from within a step.
turbine.SendProduct
func SendProduct(ctx context.Context, fileName string, data io.Reader, metadata map[string]any) errorStore a product file from within a step.
turbine.SendNotification
func SendNotification(ctx context.Context, name, message string) errorSend an ad-hoc message to a configured notification channel by name. Disabled channels are a silent no-op. Also available as rt.SendNotification(name, message) from host code.