tryLock

package
v1.0.22 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InternalCodeFailed     = 999 // 未取到锁
	InternalCodeErr        = 998 // 连接异常
	InternalCodeLockNotOwn = 997 // 不是自己的锁
	InternalCodeExLtLease  = 996 // 有效期必须大于续租+minInterval时间
)

Variables

This section is empty.

Functions

func TryLock

func TryLock(ctx context.Context, conn *connCli, key string, ex, lease int) (string, context.CancelFunc, error)

func UnLock

func UnLock(conn *connCli, cancelFunc context.CancelFunc, key, leaseId string) (bool, error)

UnLock 取消分布式锁

Types

type LockError

type LockError struct {
	Code int
	Msg  string
}

func (LockError) Error

func (le LockError) Error() string

func (LockError) GetCode

func (le LockError) GetCode() int

Jump to

Keyboard shortcuts

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