Documentation
¶
Overview ¶
Package timeout provides a Timeout policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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
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
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.