util

package
v1.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultInterval = time.Duration(10) // 10 ms
	DefaultTimes    = int32(3)          // 重试3次
)

Variables

This section is empty.

Functions

func EmptyErrHandleFunc

func EmptyErrHandleFunc(err error) bool

EmptyErrHandleFunc 空处理逻辑 默认都需要重试

func Retry

func Retry(ctx context.Context, fun RetryFunc, opts ...RetryConfigOptional) error

Retry 重试逻辑

Types

type ErrHandleFunc

type ErrHandleFunc func(err error) bool

ErrHandleFunc 错误处理句柄

type RetryConfig

type RetryConfig struct {
	// contains filtered or unexported fields
}

RetryConfig 定义retry的配置类

type RetryConfigOptional

type RetryConfigOptional func(c *RetryConfig)

定义retry的optional

func WithErrHandle

func WithErrHandle(ehFunc ErrHandleFunc) RetryConfigOptional

WithErrHandle 设置错误处理handle

func WithInterval

func WithInterval(interval time.Duration) RetryConfigOptional

WithInterval 设置重试的间隔时长

func WithTimes

func WithTimes(times int32) RetryConfigOptional

WithTimes 设置重试次数

type RetryFunc

type RetryFunc func(ctx context.Context) error

定义通用的func

Jump to

Keyboard shortcuts

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