poll

package
v0.19.766 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NonRetryableError = errors.New("non-retryable")
	ExhaustedError    = errors.New("exhausted attempts new")
	ContinueAsNewErr  = errors.New("continue as new")
)

Functions

func Poll

func Poll(ctx workflow.Context, v *validator.Validate, opts PollOpts) error

Types

type PollOpts

type PollOpts struct {
	MaxTS           time.Time     `validate:"required"`
	InitialInterval time.Duration `validate:"required"`
	MaxInterval     time.Duration `validate:"required"`
	BackoffFactor   float64       `validate:"required"`
	// If set to > 0, Poll with return the ContinueAsNewErr after every N attempts.
	ContinueAsNewAfterAttempts int      `validate:"min=0"`
	Fn                         PollerFn `validate:"required"`

	PostAttemptHook func(workflow.Context, time.Duration) error
}

type PollerFn

type PollerFn func(context workflow.Context) error

NOTE(jm): we use this pattern in many workflows, and while we do want to move to using signals to make it easier to control flow, this approach is still common.

Setting ContinueAsNewAfterAttempts to >0 will return ContinueAsNewErr after the given number of attempts. Use this to return workflow.ContinueAsNewErr to temporal for doing continue-as-new polling.

Jump to

Keyboard shortcuts

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