consul

package
v0.0.0-...-7b2e207 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LockTTL = 10 * time.Second

LockTTL defines max time to live of a lock.

View Source
var WaitForLock = 5 * time.Second

WaitForLock defines the about of time to wait to acquire a lock

Functions

This section is empty.

Types

type Lock

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

Lock provides lock functionalities based on consul sessions.It implements The Lock interface.

func NewLock

func NewLock(key string) (*Lock, error)

NewLock creates a consul lock instance

func NewLockWithTTL

func NewLockWithTTL(key string, ttl time.Duration) (*Lock, error)

NewLockWithTTL creates a consul lock instance

func (*Lock) Acquire

func (l *Lock) Acquire() error

Acquire acquires a lock. Returns error if it failed to acquire the lock. If the lock object has a session that is still tired to the locked key, nil is returned.

func (*Lock) GetState

func (l *Lock) GetState() map[string]interface{}

GetState returns the lock state

func (*Lock) IsAcquirer

func (l *Lock) IsAcquirer() error

IsAcquirer checks whether this lock instance is the acquirer of the lock on a specific key

func (*Lock) Release

func (l *Lock) Release() error

Release invalidates the lock previously acquired. Returns nil if when lock is not held

func (*Lock) SetState

func (l *Lock) SetState(state map[string]interface{})

SetState sets the lock state

Jump to

Keyboard shortcuts

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