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 Timeout ¶
type Timeout[R any] interface { failsafe.Policy[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.
This type is concurrency safe.
func With ¶
With 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.
type TimeoutBuilder ¶
type TimeoutBuilder[R any] interface { // OnTimeoutExceeded registers the listener to be called when the timeout is exceeded. OnTimeoutExceeded(listener func(event failsafe.ExecutionDoneEvent[R])) TimeoutBuilder[R] // Build returns a new Timeout using the builder's configuration. Build() Timeout[R] }
func Builder ¶
func Builder[R any](timeLimit time.Duration) TimeoutBuilder[R]
Builder returns a TimeoutBuilder 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.