Documentation
¶
Overview ¶
Path: nexss/auth/security/dlock/memory_mutex.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLocked = xerr.Conflict("resource is currently locked by another instance")
ErrLocked is returned when another instance is already processing the task.
Functions ¶
Types ¶
type LeaseMutex ¶ added in v0.7.0
type LeaseMutex interface {
TryAcquire(ctx context.Context, key string, ttl time.Duration) (Lease, bool, error)
}
LeaseMutex releases only the exact acquisition returned to its caller. Implementations should prefer this contract when lock expiry can overlap work.
type MemoryMutex ¶
type MemoryMutex struct {
// contains filtered or unexported fields
}
MemoryMutex provides an in-memory implementation of Mutex for single-node / testing.
func NewMemoryMutex ¶
func NewMemoryMutex() *MemoryMutex
func (*MemoryMutex) TryAcquire ¶ added in v0.7.0
type Mutex ¶
type Mutex interface {
TryLock(ctx context.Context, key string, ttl time.Duration) (bool, error)
Unlock(ctx context.Context, key string) error
}
Mutex defines a distributed lock interface (e.g., Redis, NATS, Postgres).
type RedisMutex ¶
type RedisMutex struct {
// contains filtered or unexported fields
}
RedisMutex implements an ownership-aware distributed lock using Redis SET NX.
func NewRedisMutex ¶
func NewRedisMutex(client *redis.Client) *RedisMutex