types

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

重试策略

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrHookProgress

type ErrHookProgress func(curTryIndex int, totalTry int, err error)

错误 curTryIndex 重试进度 totalTry 重试总数 err 错误信息

type FixIntervalRetry

type FixIntervalRetry struct {
	Interval time.Duration
	Max      int
	CurIndex int
}

func (*FixIntervalRetry) Clear

func (f *FixIntervalRetry) Clear()

func (*FixIntervalRetry) IsOver

func (f *FixIntervalRetry) IsOver() bool

func (*FixIntervalRetry) Next

func (f *FixIntervalRetry) Next() (time.Duration, bool)

func (*FixIntervalRetry) Reset

func (f *FixIntervalRetry) Reset(Interval time.Duration, Max int)

type FixIntervalRetryManager

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

func GetInstallFixIntervalRetryManager

func GetInstallFixIntervalRetryManager() *FixIntervalRetryManager

func (*FixIntervalRetryManager) Get

func (f *FixIntervalRetryManager) Get(Interval time.Duration, Max int) (*FixIntervalRetry, error)

func (*FixIntervalRetryManager) Put

type ICache

type ICache interface {
	Get(ctx context.Context, key string) (any, error)
	Set(ctx context.Context, key string, value any, expiration time.Duration) error
	Delete(ctx context.Context, key string) error
	//删除所有的缓存
	Clear(ctx context.Context, errHonk ErrHookProgress)
	//销毁
	Destroy(ctx context.Context)
}

本地缓存接口

type IRedisCache

type IRedisCache interface {
	ICache
	GetRedis() (*redis.Cmdable, uint8)
	//#region hash
	HSet(ctx context.Context, hashName string, key string, value any) error
	HGet(ctx context.Context, hashName string, key string) (any, error)
	HLength(ctx context.Context, hashName string) (int64, error)
	HDelete(ctx context.Context, hashName string, key string) error
	HExpire(ctx context.Context, hashName string, expiration time.Duration) error
	HKeys(ctx context.Context, hashName string) ([]string, error)
	HGetAll(ctx context.Context, hashName string) (map[string]string, error)

	//#region list
	ListPush(ctx context.Context, listName string, value ...any) error
	ListPop(ctx context.Context, listName string) (string, error)
	ListUnshift(ctx context.Context, listName string, value ...any) error
	ListShift(ctx context.Context, listName string) (string, error)
	LLength(ctx context.Context, listName string) (int64, error)
}

Redis缓存接口

type IRetryStrategy

type IRetryStrategy interface {
	//①,重试的间隔; ②,要不要重试
	Next() (time.Duration, bool)
}

Jump to

Keyboard shortcuts

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