locker

package
v1.35.2 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLockNotAcquired = errors.New("lock not acquired")

ErrLockNotAcquired is returned when a lock cannot be acquired within the configured timeout.

Functions

func Module

func Module() fx.Option

Types

type Locker

type Locker interface {
	// AcquireLock attempts to acquire a lock for the given key.
	// Returns ErrLockNotAcquired if the lock cannot be acquired within the configured timeout.
	AcquireLock(ctx context.Context, key string) error
	// ReleaseLock releases a previously acquired lock for the given key.
	// Returns an error if the lock was not held by this instance.
	ReleaseLock(ctx context.Context, key string) error

	// Close releases any held locks.
	Close() error
}

func NewMySQLLocker

func NewMySQLLocker(db *sql.DB, prefix string, timeout time.Duration) Locker

NewMySQLLocker creates a new MySQL-based distributed locker.

Jump to

Keyboard shortcuts

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