rdx

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package rdx 提供适配 gocron 的 Redis 分布式任务锁。

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClientRequired 表示没有提供 Redis 客户端。
	ErrClientRequired = errx.New("redis client must not be nil")
	// ErrInvalidExpiry 表示锁租约时长不是正数。
	ErrInvalidExpiry = errx.New("redis lock expiry must be greater than zero")
	// ErrInvalidAutoExtend 表示自动续租间隔无效。
	ErrInvalidAutoExtend = errx.New("redis lock auto extend interval must be less than expiry")
	// ErrInvalidTries 表示获取锁的尝试次数不是正数。
	ErrInvalidTries = errx.New("redis lock tries must be greater than zero")
)

Functions

func New

func New(client redis.UniversalClient, config Config) (gocron.Locker, error)

New 创建带持有者校验和自动续租的 Redis 任务锁。

Types

type Config

type Config struct {
	KeyPrefix       string
	Expiry          time.Duration
	AutoExtendEvery time.Duration
	Tries           int
}

Config 定义 Redis 任务锁的命名空间和租约策略。

Jump to

Keyboard shortcuts

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