lock

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lock provides distributed locking

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLockTimeout = errors.New("lock timeout")
)

Functions

This section is empty.

Types

type AcquireOption

type AcquireOption func(o *AcquireOptions)

func TTL

TTL sets the lock ttl

func Wait

func Wait(t time.Duration) AcquireOption

Wait sets the wait time

type AcquireOptions

type AcquireOptions struct {
	TTL  time.Duration
	Wait time.Duration
}

type Lock

type Lock interface {
	// Acquire a lock with given id
	Acquire(id string, opts ...AcquireOption) error
	// Release the lock with given id
	Release(id string) error
}

Lock is a distributed locking interface

type Option

type Option func(o *Options)

func Nodes

func Nodes(a ...string) Option

Nodes sets the addresses the underlying lock implementation

func Prefix

func Prefix(p string) Option

Prefix sets a prefix to any lock ids used

type Options

type Options struct {
	Nodes  []string
	Prefix string
}

Directories

Path Synopsis
Package etcd is an etcd implementation of lock
Package etcd is an etcd implementation of lock
Package http adds a http lock implementation
Package http adds a http lock implementation
server
Package server implements the sync http server
Package server implements the sync http server
Package memory provides a sync.Mutex implementation of the lock for local use
Package memory provides a sync.Mutex implementation of the lock for local use

Jump to

Keyboard shortcuts

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