Repository navigation
v1.0.0-rc.1
v1.0.0-rc.1
Release Candidate - This is a pre-release for v1.0.0. API is considered stable.
This release is identical to v0.5.0, promoted to release candidate status for v1.0.0.
Features
- Single Instance Lock (
Lock) - Redis-backed distributed lock with retry, fencing tokens, and atomic Lua scripts - Distributed Lock (
DistributedLock) - Redlock algorithm implementation with quorum (N/2+1) consensus - Watchdog Pattern - Built-in
Watch()helper for automatic lock extension - Unified Interface -
Lockerinterface for interchangeable use of both lock types
API
| Method | Description |
|---|---|
Acquire |
Acquires lock with retry, returns fencing token |
TryAcquire |
Single attempt, no retry |
AcquireWithFencing |
Acquires with provided fencing token |
Extend |
Extends TTL with retry if fencing matches |
TryExtend |
Single extend attempt |
AcquireOrExtend |
Extends if held, otherwise acquires |
Release |
Atomically releases lock if fencing matches |
Error Handling
ErrLockAlreadyHeld- Lock is held by another clientErrLockNotHeld- Lock doesn't exist or fencing mismatchErrMaxRetryExceeded- Maximum retry attempts exhaustedErrValidityExpired- Lock validity expired due to clock drift
Supports errors.Is() and errors.Join() for aggregated errors from DistributedLock.
Installation
go get github.com/trviph/redlock@v1.0.0-rc.1Full Changelog: v0.4.3...v1.0.0-rc.1