Documentation
¶
Overview ¶
Package fallback provides a Fallback policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶ added in v0.7.0
type Builder[R any] interface { failsafe.FailurePolicyBuilder[Builder[R], R] // OnFallbackExecuted registers the listener to be called when a Fallback has executed. The provided event will contain // the execution result and error returned by the Fallback. OnFallbackExecuted(listener func(event failsafe.ExecutionDoneEvent[R])) Builder[R] // Build returns a new Fallback using the builder's configuration. Build() Fallback[R] }
Builder builds Fallback instances.
- By default, any error is considered a failure and will be handled by the policy. You can override this by specifying your own handle conditions. The default error handling condition will only be overridden by another condition that handles errors such as HandleErrors or HandleIf. Specifying a condition that only handles results, such as HandleResult will not replace the default error handling condition.
- If multiple handle conditions are specified, any condition that matches an execution result or error will trigger policy handling.
R is the execution result type. This type is not concurrency safe.
func NewBuilderWithError ¶ added in v0.7.0
NewBuilderWithError returns a Builder for execution result type R which builds Fallbacks that return the error when an execution fails.
func NewBuilderWithFunc ¶ added in v0.7.0
NewBuilderWithFunc returns a Builder for execution result type R which builds Fallbacks that use the fallbackFn to handle failed executions.
func NewBuilderWithResult ¶ added in v0.7.0
NewBuilderWithResult returns a Builder for execution result type R which builds Fallbacks that return the result when an execution fails.
type Fallback ¶
Fallback is a Policy that handles failures using a fallback function, result, or error.
R is the execution result type. This type is concurrency safe.
func NewWithError ¶ added in v0.7.0
NewWithError returns a Fallback for execution result type R that returns the err when an execution fails.
func NewWithFunc ¶ added in v0.7.0
NewWithFunc returns a Fallback for execution result type R that uses fallbackFunc to handle a failed execution.
func NewWithResult ¶ added in v0.7.0
NewWithResult returns a Fallback for execution result type R that returns the result when an execution fails.