lock

package
v0.0.0-...-e8ca4d1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2019 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsulAPIWrapper

type ConsulAPIWrapper struct {
	DefaultConfig func() *consulapi.Config
	NewClient     func(config *consulapi.Config) (*consulapi.Client, error)
}

type ConsulCombinationLock

type ConsulCombinationLock struct {
	ConsulLock ConsulLock
	LocalLock  LocalLock
}

func (ConsulCombinationLock) Lock

func (lock ConsulCombinationLock) Lock() error

func (ConsulCombinationLock) Unlock

func (lock ConsulCombinationLock) Unlock() error

type ConsulCombinationLockClient

type ConsulCombinationLockClient struct {
	ConsulClient *ConsulLockClient
	LocalClient  *LocalLockClient
}

func NewConsulCombinationLockClient

func NewConsulCombinationLockClient(consulAddress, consulBaseFolder string, consulLockOptions *consulapi.LockOptions) (*ConsulCombinationLockClient, error)

func (ConsulCombinationLockClient) LockKey

func (c ConsulCombinationLockClient) LockKey(key string) (Lock_i, error)

type ConsulLock

type ConsulLock struct {
	Key        string
	ConsulLock *consulapi.Lock
	LockCh     <-chan struct{}
}

func (ConsulLock) Lock

func (lock ConsulLock) Lock() error

func (ConsulLock) Unlock

func (lock ConsulLock) Unlock() error

type ConsulLockClient

type ConsulLockClient struct {
	Client      *consulapi.Client
	LockOptions *consulapi.LockOptions
	BaseFolder  string
}

func NewConsulLockClient

func NewConsulLockClient(address, baseFolder string, lockOptions *consulapi.LockOptions) (ConsulLockClient, error)

func (ConsulLockClient) LockKey

func (c ConsulLockClient) LockKey(key string) (Lock_i, error)

type LocalLock

type LocalLock struct {
	Client *LocalLockClient
	Key    string
}

func (LocalLock) Lock

func (lock LocalLock) Lock() error

func (LocalLock) Unlock

func (lock LocalLock) Unlock() error

type LocalLockClient

type LocalLockClient struct {
	Keys           *c.Cache
	ExpirationTime time.Duration
}

The LocalLock is an implementation of the LockClient_i/Lock_i structure That is designed to be used in a non-distributed environment It uses a cache of Mutexes which are locked and unlocked according to a specified key

func NewLocalLockClient

func NewLocalLockClient() *LocalLockClient

func (*LocalLockClient) LockKey

func (c *LocalLockClient) LockKey(key string) (Lock_i, error)

type LockClient_i

type LockClient_i interface {
	LockKey(key string) (Lock_i, error)
}

type Lock_i

type Lock_i interface {
	Lock() error
	Unlock() error
}

Lock_i is an instance of a Lock in the set of LockClient_i locks It requires 3 methods for implementation

  • Lock: which attempts to establish a lock on its key
  • Unlock: which attempts to remove a lock on its key
  • Destroy: which deletes the Lock_i's key from its parent client

Jump to

Keyboard shortcuts

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