Skip to content

v1.0.0-rc.1

Choose a tag to compare

@trviph trviph released this 16 Jan 18:42
· 26 commits to main since this release
53c4da7

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 - Locker interface 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 client
  • ErrLockNotHeld - Lock doesn't exist or fencing mismatch
  • ErrMaxRetryExceeded - Maximum retry attempts exhausted
  • ErrValidityExpired - 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.1

Full Changelog: v0.4.3...v1.0.0-rc.1