retry

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package retry implements the retry component — the explicit supervisor primitive that pairs with single-shot edge delivery in the SDK (since v0.10.16). Components no longer retry transient failures implicitly; flow authors wire retry into their error paths to get backoff + bounded attempts.

Topology:

llm_complete.request ──→ llm_complete
     ▲                       │
     │                       ├─ response → … rest of flow
     │                       │
     │                       └─ error ───→ retry.request
     │                                        │
     │                                        ├─ retry  ─┐
     │                                        │          │ sleeps NextDelayMs
     └────────────────────────────────────────┘          │ then loops back
                                              │
                                              └─ failed → dead-letter / alert

The component is stateless. Attempt state rides in the payload as `attempt` and is incremented on every loop. Flow authors compose the loop explicitly; the framework no longer hides retry decisions.

Index

Constants

View Source
const (
	ComponentName = "retry"
	RequestPort   = "request"
	RetryPort     = "retry"
	FailedPort    = "failed"

	BackoffExponential = "exponential"
	BackoffLinear      = "linear"
	BackoffConstant    = "constant"

	ReasonMaxAttempts  = "max_attempts"
	ReasonNotRetryable = "not_retryable"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

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

func (*Component) GetInfo

func (c *Component) GetInfo() module.ComponentInfo

func (*Component) Handle

func (c *Component) Handle(ctx context.Context, handler module.Handler, port string, msg any) module.Result

func (*Component) Instance

func (c *Component) Instance() module.Component

func (*Component) OnSettings

func (c *Component) OnSettings(_ context.Context, msg any) error

func (*Component) Ports

func (c *Component) Ports() []module.Port

type Context

type Context any

type Failed

type Failed struct {
	Context Context `json:"context,omitempty" configurable:"true" title:"Context"`
	Attempt int     `json:"attempt" title:"Attempt" description:"Final attempt count when the loop gave up."`
	Error   string  `json:"error,omitempty" title:"Last Error"`
	Reason  string  `json:"reason" title:"Reason" description:"max_attempts | not_retryable"`
}

Failed fires when the loop terminates. Two reasons: attempt limit hit, or the error was marked non-retryable.

type Request

type Request struct {
	Context   Context `` /* 176-byte string literal not displayed */
	Attempt   int     `json:"attempt" title:"Attempt" description:"Zero or absent on first arrival. Component increments it on every retry."`
	Retryable bool    `json:"retryable" title:"Retryable" description:"From the error port. False = straight to failed without sleeping."`
	Error     string  `json:"error,omitempty" title:"Last Error" description:"Last error message, forwarded to failed for the dead-letter path."`
}

Request is the input shape. Wire an error port that emits {context, error, retryable} into this — the field names match the llm_* / http_request / database error shape exactly so no transform is needed.

type Retry

type Retry struct {
	Context     Context `json:"context,omitempty" configurable:"true" title:"Context"`
	Attempt     int     `json:"attempt" title:"Attempt" description:"Incremented before emit. Next call lands here with this value."`
	NextDelayMs int     `json:"nextDelayMs" title:"Slept (ms)" description:"How long the component just slept. Informational — useful for traces."`
}

Retry fires after the backoff sleep. Wire this back into the original component's request port to re-invoke.

type Settings

type Settings struct {
	MaxAttempts    int    `` /* 178-byte string literal not displayed */
	InitialDelayMs int    `` /* 133-byte string literal not displayed */
	MaxDelayMs     int    `` /* 153-byte string literal not displayed */
	Backoff        string `` /* 196-byte string literal not displayed */
	Jitter         bool   `` /* 138-byte string literal not displayed */
}

Jump to

Keyboard shortcuts

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