retry

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Retry

func Retry(opts ...Option) middleware.Middleware

Retry 返回一个重试中间件,主要用于客户端请求

Types

type Option

type Option func(*options)

Option 是重试中间件的选项

func WithAttempts

func WithAttempts(attempts int) Option

WithAttempts 设置最大重试次数(包括首次尝试)

func WithBackoff

func WithBackoff(backoff bool) Option

WithBackoff 设置指数退避策略

func WithDelay

func WithDelay(delay time.Duration) Option

WithDelay 设置重试间隔

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger 设置日志记录器

func WithMaxDelay

func WithMaxDelay(maxDelay time.Duration) Option

WithMaxDelay 设置最大重试延迟

func WithRetryIf

func WithRetryIf(fn RetryIfFunc) Option

WithRetryIf 设置重试条件

type RetryIfFunc

type RetryIfFunc func(ctx context.Context, req, resp interface{}, err error) bool

RetryIfFunc 定义重试判断函数类型

Jump to

Keyboard shortcuts

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