vault

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package vault solves the handling of mutexes.

Index

Constants

View Source
const (
	LOCKED   lockState = true
	UNLOCKED lockState = false
)

Variables

View Source
var BadMannersError = errors.New(
	"Client tried to release lock that it did not own",
)
View Source
var UnecessaryAcquireError = errors.New(
	"Client tried to acquire a lock that it already had acquired",
)
View Source
var UnecessaryReleaseError = errors.New(
	"Client tried to release a lock that had not been acquired",
)

Functions

This section is empty.

Types

type QueueType

type QueueType string
const (
	Single QueueType = "single"
	Multi  QueueType = "multi"
)

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 string, client string, callback func(error) error)
	Release(lockTag string, client string, callback func(error) error)
	Cleanup(client string)
}

The Vault interface specifies high level functions to implement in order to handle the acquisition and release of mutexes.

func NewVault

func NewVault(options *VaultOptions) Vault

type VaultOptions

type VaultOptions struct {
	// 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
}

Directories

Path Synopsis
Package queue implements a way for the vault to ensure single-threaded handling of mutexes.
Package queue implements a way for the vault to ensure single-threaded handling of mutexes.

Jump to

Keyboard shortcuts

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