memory

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: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LockTTL = time.Duration(10 * time.Second)

LockTTL defines max time to live of a lock.

Functions

func StartLockWatcher

func StartLockWatcher() func()

StartLockWatcher starts a go routine that checks the locked key list and removes expired locks. Returns a function to stop the lock watcher

Types

type Lock

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

Lock provides lock functionalities backed by memory.

func NewLock

func NewLock(key string) *Lock

NewLock creates a consul lock instance

func NewLockWithTTL

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

NewLockWithTTL creates a consul lock instance

func (*Lock) Acquire

func (l *Lock) Acquire() error

Acquire acquires a lock. A time-to-live time is set on the lock to ensure the lock is invalidated after the time is passed.

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 release a lock on the key. Returns nil of lock on the current key does not exist

func (*Lock) SetState

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

SetState sets the lock state

type LockValue

type LockValue struct {
	Session string
	Exp     time.Time
}

LockValue represents a lock value

Jump to

Keyboard shortcuts

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