zklock

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: CC0-1.0 Imports: 8 Imported by: 0

README

This package is copied and modified from https://github.com/nladuo/go-zk-lock

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAcquireLock = errors.New("lock is already acquired by another client")

Functions

func Close

func Close()

Close close connection

func Connect

func Connect(_hosts []string, zkTimeOut time.Duration) error

Connect conncet to ZK cluster

func PConnect

func PConnect(_hosts []string, zkTimeOut time.Duration) error

PConnect connect to ZK cluster

Types

type Dlocker

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

Dlocker distributed locker

func NewLocker

func NewLocker(path string, timeout time.Duration) (*Dlocker, error)

NewLocker create instance of ZK lock

func (*Dlocker) Lock

func (d *Dlocker) Lock() error

Lock just list mutex.Lock()

func (*Dlocker) TryLock

func (d *Dlocker) TryLock() error

TryLock try lock and return error immediately if fail

func (*Dlocker) Unlock

func (d *Dlocker) Unlock() error

Unlock just list mutex.Unlock(), return false when zookeeper connection error or locker timeout

Jump to

Keyboard shortcuts

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