go-micro: github.com/micro/go-micro/sync/lock Index | Files | Directories

package lock

import "github.com/micro/go-micro/sync/lock"

Package lock provides distributed locking


Package Files

lock.go options.go


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

type AcquireOption Uses

type AcquireOption func(o *AcquireOptions)

func TTL Uses

func TTL(t time.Duration) AcquireOption

TTL sets the lock ttl

func Wait Uses

func Wait(t time.Duration) AcquireOption

Wait sets the wait time

type AcquireOptions Uses

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

type Lock Uses

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 Uses

type Option func(o *Options)

func Nodes Uses

func Nodes(a ...string) Option

Nodes sets the addresses the underlying lock implementation

func Prefix Uses

func Prefix(p string) Option

Prefix sets a prefix to any lock ids used

type Options Uses

type Options struct {
    Nodes  []string
    Prefix string


etcdPackage etcd is an etcd implementation of lock
httpPackage http adds a http lock implementation
http/serverPackage server implements the sync http server
memoryPackage memory provides a sync.Mutex implementation of the lock for local use

Package lock imports 2 packages (graph) and is imported by 28 packages. Updated 2020-01-30. Refresh now. Tools for package owners.