timeout

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 7 Imported by: 29

Documentation

Overview

Package timeout provides a Timeout policy.

Index

Constants

This section is empty.

Variables

View Source
var ErrExceeded = errors.New("timeout exceeded")

ErrExceeded is returned when an execution exceeds a configured timeout.

Functions

This section is empty.

Types

type Builder

type Builder[R any] interface {
	// OnTimeoutExceeded registers the listener to be called when the timeout is exceeded.
	OnTimeoutExceeded(listener func(event failsafe.ExecutionDoneEvent[R])) Builder[R]

	// Build returns a new Timeout using the builder's configuration.
	Build() Timeout[R]
}

Builder builds Timeout instances.

R is the execution result type. This type is not concurrency safe.

func NewBuilder added in v0.7.0

func NewBuilder[R any](timeLimit time.Duration) Builder[R]

NewBuilder returns a Builder for execution result type R which builds Timeouts for the timeLimit. The Timeout will cancel executions if they exceed a time limit. Any policies composed inside the timeout, such as retries, will also be canceled. If the execution is configured with a Context, a child context will be created for the execution and canceled when the Timeout is exceeded.

type Timeout

type Timeout[R any] interface {
	failsafe.ResultAgnosticPolicy[R]
}

Timeout is a Policy that cancels executions if they exceed a time limit. Any policies composed inside the timeout, such as retries, will also be canceled. If the execution is configured with a Context, a child context will be created for the execution and canceled when the Timeout is exceeded.

R is the execution result type. This type is concurrency safe.

func New added in v0.7.0

func New[R any](timeLimit time.Duration) Timeout[R]

New returns a new Timeout for execution result type R and the timeLimit. The Timeout will cancel executions if they exceed a time limit. Any policies composed inside the timeout, such as retries, will also be canceled. If the execution is configured with a Context, a child context will be created for the execution and canceled when the Timeout is exceeded.

Jump to

Keyboard shortcuts

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