lock

package
v0.0.0-...-39cffea Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Locker

type Locker interface {
	Trylock(ctx context.Context, key string, ops ...Options) (Unlocker, context.Context, error)
}

Locker is an interface that have a trylock method. It will lock on the specific key, different key will not be interfered.

func New

func New(cli *clientv3.Client, opts ...Options) Locker

New will create a new Locker

type Options

type Options func(opt *options)

Options config Locker

func WithTTL

func WithTTL(ttl time.Duration) Options

WithTTL configs the Locker with a timeout value, if the Locker cant get the lock when the ttl expiration, then Lock will fail. If the Locker get the lock in ttl, the ttl will be ignored.

type Unlocker

type Unlocker func()

Unlocker is a func that can unlock the lock from the outside pkg

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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