Documentation
¶
Index ¶
- func DefaultRetryPolicy() resiliencecontract.RetryPolicy
- func Do(ctx context.Context, c runtimecontract.Container, fn func() error) error
- func DoWithResult(ctx context.Context, c runtimecontract.Container, fn func() (any, error)) (any, error)
- func Get(c runtimecontract.Container) (resiliencecontract.Retry, error)
- func GetOrPanic(c runtimecontract.Container) resiliencecontract.Retry
- func IsRetryable(c runtimecontract.Container, err error) (bool, error)
- type Retry
- type RetryConfig
- type RetryPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRetryPolicy ¶
func DefaultRetryPolicy() resiliencecontract.RetryPolicy
DefaultRetryPolicy returns the built-in default retry policy. DefaultRetryPolicy 返回默认重试策略。
func Do ¶
Do executes a function with the retry service from the container. Do 使用容器中的重试服务执行函数。
Example:
err := retry.Do(ctx, c, func() error {
return callRemote(ctx)
})
func DoWithResult ¶
func DoWithResult(ctx context.Context, c runtimecontract.Container, fn func() (any, error)) (any, error)
DoWithResult executes a function with result using the retry service from the container. DoWithResult 使用容器中的重试服务执行带返回值的函数。
func Get ¶
func Get(c runtimecontract.Container) (resiliencecontract.Retry, error)
Get returns the unified retry service from the container. Get 从容器获取统一重试服务。
func GetOrPanic ¶
func GetOrPanic(c runtimecontract.Container) resiliencecontract.Retry
GetOrPanic returns the unified retry service from the container and panics on failure. GetOrPanic 从容器获取统一重试服务,失败 panic。
func IsRetryable ¶
func IsRetryable(c runtimecontract.Container, err error) (bool, error)
IsRetryable reports whether the given error is retryable. IsRetryable 判断错误是否可重试。
Types ¶
type Retry ¶
type Retry = resiliencecontract.Retry
Retry is the top-level alias of the retry contract. Retry 是重试契约的顶层别名。
type RetryConfig ¶
type RetryConfig = resiliencecontract.RetryConfig
RetryConfig is the top-level alias of the retry config contract. RetryConfig 是重试配置契约的顶层别名。
type RetryPolicy ¶
type RetryPolicy = resiliencecontract.RetryPolicy
RetryPolicy is the top-level alias of the retry policy contract. RetryPolicy 是重试策略契约的顶层别名。