zklock

package
v0.0.0-...-817d39a Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MIT 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

This section is empty.

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