dlm

package
v0.0.0-...-baf8ae7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockGroup

type LockGroup interface {
	TryObtain(ctx context.Context, member string) (bool, error)
	Unlock(ctx context.Context, member string) error
	Expired(ctx context.Context) ([]string, error)
}

type LockGroupManager

type LockGroupManager interface {
	Group(key string, ttl time.Duration) LockGroup
}

type LockManager

type LockManager interface {
	TryObtain(ctx context.Context, key string, ttl time.Duration) (bool, error)
	Unlock(ctx context.Context, key string) error
}

LockManager The CompareAndSwap implementation used by the LockManager should NOT block. It only locks if the key was not already locked, and returns whether it has been locked or not.

func New

func New(conf supervisor.DLMConfig, connPool *supervisor.ConnPool) (LockManager, error)

type RedisLockGroup

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

func (*RedisLockGroup) Expired

func (g *RedisLockGroup) Expired(ctx context.Context) ([]string, error)

func (*RedisLockGroup) TryObtain

func (g *RedisLockGroup) TryObtain(ctx context.Context, member string) (bool, error)

func (*RedisLockGroup) Unlock

func (g *RedisLockGroup) Unlock(ctx context.Context, member string) error

type RedisLockManager

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

func NewRedisLockManager

func NewRedisLockManager(client redis.UniversalClient) *RedisLockManager

func (*RedisLockManager) Group

func (m *RedisLockManager) Group(key string, ttl time.Duration) LockGroup

func (*RedisLockManager) TryObtain

func (m *RedisLockManager) TryObtain(ctx context.Context, key string, ttl time.Duration) (bool, error)

func (*RedisLockManager) Unlock

func (m *RedisLockManager) Unlock(ctx context.Context, key string) error

Jump to

Keyboard shortcuts

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