redisdsync

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = &bootstrap.Module{
	Name:       "distributed",
	Precedence: bootstrap.DistributedLockPrecedence,
	Options: []fx.Option{
		fx.Provide(provideSyncManager),
	},
	Modules: []*bootstrap.Module{dsync.Module},
}

Functions

func Use

func Use()

Types

type RedisLock

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

func (*RedisLock) Key

func (l *RedisLock) Key() string

func (*RedisLock) Lock

func (l *RedisLock) Lock(ctx context.Context) error

func (*RedisLock) Lost

func (l *RedisLock) Lost() <-chan struct{}

func (*RedisLock) Release

func (l *RedisLock) Release() error

func (*RedisLock) TryLock

func (l *RedisLock) TryLock(ctx context.Context) error

type RedisLockOption

type RedisLockOption struct {
	Context context.Context
	Name    string
	Valuer  dsync.LockValuer
	// AutoExpiry how long the acquired lock expires (released) in case the application crashes.
	// It's recommended to keep this value larger than 5 seconds
	// Default is 10 seconds
	AutoExpiry time.Duration
	// RetryDelay how long we wait after a retryable error (usually network error)
	// Default is 500 milliseconds
	RetryDelay time.Duration
	// TimeoutFactor used to calculate redis CMD timeout when acquiring, extending and releasing lock.
	// timeout = AutoExpiry * TimeoutFactor
	// Note: the value should be smaller than 0.5 and recommended to be between 0.01 to 0.1 depending on the AutoExpiry.
	// Default is 0.05
	TimeoutFactor float64
	// MaxExtendRetries how many times we attempt to extend the lock before give up.
	// Default is 3
	MaxExtendRetries int
}

type RedisLockOptions

type RedisLockOptions func(opt *RedisLockOption)

type RedisSyncManager

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

func NewRedisSyncManager

func NewRedisSyncManager(appCtx *bootstrap.ApplicationContext, opts ...RedisSyncOptions) *RedisSyncManager

func (*RedisSyncManager) Lock

func (m *RedisSyncManager) Lock(key string, opts ...dsync.LockOptions) (dsync.Lock, error)

func (*RedisSyncManager) Start

func (m *RedisSyncManager) Start(_ context.Context) error

func (*RedisSyncManager) Stop

type RedisSyncOption

type RedisSyncOption struct {
	// Clients are go-redis/v8 clients.
	// Each client should be able to connect to an independent Redis master/cluster/sentinel-master to form quorum
	Clients []redislib.UniversalClient
	// TTL see RedisLockOption.AutoExpiry
	TTL time.Duration
	// RetryDelay see RedisLockOption.RetryDelay
	RetryDelay time.Duration
	// TimeoutFactor see RedisLockOption.TimeoutFactor
	TimeoutFactor float64
}

type RedisSyncOptions

type RedisSyncOptions func(opt *RedisSyncOption)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳