Documentation
¶
Overview ¶
Package vault solves the handling of mutexes.
Index ¶
- Constants
- Variables
- type Mock
- func (v *Mock) Acquire(lockTag string, client string, callback func(error) error)
- func (v *Mock) AwaitAcquire(lockTag string) error
- func (v *Mock) AwaitRelease(lockTag string) error
- func (v *Mock) Cleanup(locktag string, client string)
- func (v *Mock) EnableAwaits()
- func (v *Mock) Release(lockTag string, client string, callback func(error) error)
- type Opts
- type QueueType
- type Vault
Constants ¶
View Source
const ( Single QueueType = "single" Multi QueueType = "multi" LOCKED lockState = true UNLOCKED lockState = false )
Variables ¶
View Source
var ( ErrUnnecessaryAcquire = errors.New( "client tried to acquire a lock that it already had acquired", ) ErrUnnecessaryRelease = errors.New( "client tried to release a lock that had not been acquired", ) ErrBadManners = errors.New( "client tried to release lock that it did not own", ) )
Functions ¶
This section is empty.
Types ¶
type Mock ¶ added in v0.5.2
type Mock struct {
AcquireCount int
ReleaseCount int
CleanupCount int
// contains filtered or unexported fields
}
func (*Mock) AwaitAcquire ¶ added in v0.5.2
func (*Mock) AwaitRelease ¶ added in v0.5.2
func (*Mock) EnableAwaits ¶ added in v0.5.2
func (v *Mock) EnableAwaits()
type Opts ¶ added in v0.5.2
type Opts struct {
// Used for telemetry.
Version string
// Single queue mode should only be used for testing.
QueueType
// Only for multi-mode queues, determines the number of
// supporting Go-routines able to handle work given to the
// queueing layer.
QueueConcurrency int
// Sets the capacity of the underlying queue(s), the max amount
// of buffered work for a queue. In a multi queue setting, the
// capacity indicates the buffer size per queue.
QueueCapacity int
}
type Vault ¶
type Vault interface {
// Lock tag is a string identifying the lock to acquire, client the requesting party,
// and the callback a function which will be called to either confirm acquisition or
// including an error in case the client is misbehaving. The callback may return an
// error in case feedback handling encounters an error.
Acquire(lockTag, client string, callback func(error) error)
Release(lockTag, client string, callback func(error) error)
Cleanup(locktag, client string)
}
The Vault interface specifies high level functions to implement in order to handle the acquisition and release of mutexes.
Click to show internal directories.
Click to hide internal directories.