etcdlock

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDefault

func InitDefault(endpoints ...string) func()

InitDefault 初始化默认锁

Types

type EtcdLock

type EtcdLock struct {
	Cli *clientv3.Client
	// contains filtered or unexported fields
}

EtcdLock 基于ETCD KV的分布式锁

func D

func D() *EtcdLock

D 返回默认锁

func NewDistributedLock

func NewDistributedLock(c *clientv3.Client) (*EtcdLock, func())

NewDistributedLock 创建新分布式对象

func (*EtcdLock) Lock

func (el *EtcdLock) Lock(op string) (func(), error)

Lock 加锁等待

func (*EtcdLock) LockWithTimeout

func (el *EtcdLock) LockWithTimeout(op string, duration time.Duration) (func(), error)

LockWithTimeout 加锁等待到超时

func (*EtcdLock) Release

func (el *EtcdLock) Release()

Release 清理锁

Jump to

Keyboard shortcuts

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