lockerpkg

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorExtendFailed

func ErrorExtendFailed(name string, err error) error

ErrorExtendFailed .

func ErrorLockerFailed

func ErrorLockerFailed(name string, err error) error

ErrorLockerFailed .

func IsErrorExtendFailed

func IsErrorExtendFailed(err error) bool

IsErrorExtendFailed 延长锁失败

func IsErrorLockFailed

func IsErrorLockFailed(err error) bool

IsErrorLockFailed 锁失败

Types

type DistributedLocker

type DistributedLocker interface {
	// MutexLock 互斥锁,一直等待直到解锁
	MutexLock(ctx context.Context, lockName string) (Unlocker, error)
	// EasyLock 简单锁,等待解锁或者锁定时间过期后自动解锁
	EasyLock(ctx context.Context, lockName string) (Unlocker, error)
}

DistributedLocker 分布式锁

func NewDistributedLocker

func NewDistributedLocker(locker Locker) DistributedLocker

NewDistributedLocker 请确保传递进来的锁支持分布式锁

type LocalLocker

type LocalLocker interface {
	// Mutex 互斥锁,一直等待直到解锁
	Mutex(ctx context.Context, lockName string) (Unlocker, error)
	// Once 简单锁,等待解锁或者锁定时间过期后自动解锁
	Once(ctx context.Context, lockName string) (Unlocker, error)
	// Unlock 解锁
	Unlock(ctx context.Context, lockName string)
}

type Locker

type Locker interface {
	// Mutex 互斥锁,一直等待直到解锁
	Mutex(ctx context.Context, lockName string) (Unlocker, error)
	// Once 简单锁,等待解锁或者锁定时间过期后自动解锁
	Once(ctx context.Context, lockName string) (Unlocker, error)
}

Locker 加锁

func NewCacheLocker

func NewCacheLocker() Locker

NewCacheLocker ...

func NewLocalLocker

func NewLocalLocker() Locker

NewLocalLocker ...

type Unlocker

type Unlocker interface {
	Unlock(ctx context.Context) (ok bool, err error)
	Name() string
}

Unlocker 解锁

Jump to

Keyboard shortcuts

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