Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GroupConfig ¶
type GroupConfig struct {
Slots int `yaml:"slots"`
}
type Groups ¶
type Groups map[string]GroupConfig
func NewDefaultGroups ¶
func NewDefaultGroups() Groups
type LockManager ¶
type LockManager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(groups Groups, storageCfg StorageConfig) (*LockManager, error)
Create a new LockManager from the given configuration
func NewManagerWithStorage ¶
func NewManagerWithStorage(groups Groups, storage StorageBackend) *LockManager
Create a new LockManager with custom StorageBackend
func (*LockManager) Close ¶
func (lm *LockManager) Close() error
func (*LockManager) Release ¶
func (lm *LockManager) Release(group, id string) error
type StorageBackend ¶
type StorageBackend interface {
// Reserve a lock for the given group.
// Returns true if the lock is successfully reserved, even if the lock is already held by the specific id
Reserve(group, id string) error
// Returns the current number of locks for the given group
GetLocks(group string) (int, error)
// Release the lock currently held by the id.
// Does not fail when no lock is held.
Release(group, id string) error
// Return all locks older than x
GetStaleLocks(ts time.Duration) ([]types.Lock, error)
// Check if a given id already has a lock for this group
HasLock(group, id string) (bool, error)
// Calls all necessary finalization if necessary
Close() error
}
It is assumed that each group itself is multi-read, single-write. There can be multiple writes to different groups happening in parallel though.
type StorageConfig ¶
type StorageConfig struct {
Type string `yaml:"type"`
SQLite sql.SQLiteConfig `yaml:"sqlite,omitempty"`
Postgres sql.PostgresConfig `yaml:"postgres,omitempty"`
MySQL sql.MySQLConfig `yaml:"mysql,omitempty"`
Valkey valkey.ValkeyConfig `yaml:"valkey,omitempty"`
Etcd etcd.EtcdConfig `yaml:"etcd,omitempty"`
Kubernetes kubernetes.KubernetesConfig `yaml:"kubernetes,omitempty"`
MongoDB mongodb.MongoDBConfig `yaml:"mongodb,omitempty"`
}
func NewDefaultStorageConfig ¶
func NewDefaultStorageConfig() StorageConfig
Create a new storage config with default values
Click to show internal directories.
Click to hide internal directories.