Repository navigation
feat(nestjs-tools-lock)!: replace redlock with redlock-universal - #215
Open
legreffier[bot] wants to merge 2 commits into
Open
legreffier[bot] wants to merge 2 commits into
legreffier[bot] wants to merge 2 commits into
Conversation
redlock 5 never left beta and is superseded by redlock-universal.
LockService now uses a per-key lock over an ioredis adapter and returns
an AcquiredLock { key, value, ttl, release(), extend() }.
BREAKING CHANGE: lock() and get() return an AcquiredLock instead of
redlock's Lock; release(), extend() and unlock() resolve to booleans;
acquisition failures throw LockAcquisitionError instead of redlock's
ExecutionError; lock options are limited to retryCount and retryDelay
(retryCount -1 is no longer supported); the public redlock property and
errorHandler() were removed. See the package README for migration.
MoltNet-Diary: e2dd9f2a-2432-494d-ba64-c75c29b45982
Task-Group: lock-redlock-universal
Task-Completes: true
|
View your CI Pipeline Execution ↗ for commit d96edc6
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
…universal's LockError (with key and cause) and its subclasses LockAcquisitionError, LockReleaseError and LockExtensionError replace the re-exported redlock-universal errors, so no public type depends on the lock library. MoltNet-Diary: 4cdcfbbd-a0e6-4fc9-a5eb-f6f05c806ea3 Task-Group: lock-redlock-universal
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces
redlock, whose 5.0 release never left beta and is superseded per the@sesamecare-oss/redlockREADME, withredlock-universal0.8.Breaking: releases as
@getlarge/nestjs-tools-lock@2.0.0(nx release --dry-runresolvesmajor).Why a major
The 1.x public API exposes redlock types directly. redlock-universal uses a different model (per-key locks, a plain
LockHandle, boolean release and extend), so identical types are not possible.To keep migration small, the members people use keep their names:
lock()/get()→ redlockLockAcquiredLock { key, value, ttl, release(), extend(ttl) }lock.release()→ExecutionResultboolean(falseif expired or taken)lock.extend(ttl)→Lockbooleanunlock(key, id)→ExecutionResultbooleanExecutionErrorLockAcquisitionError(re-exported)optimistic(cb(RedlockAbortSignal))optimistic(cb(LockAbortSignal)), same shapeLockOptions = Partial<redlock Settings>{ retryCount?, retryDelay? }, same semanticsredlockproperty,errorHandler()Dropped options:
driftFactor: multi-node only. We connect to one Redis, so this usescreateLock(single-node) rather thanRedLock.retryJitterautomaticExtensionThreshold:optimistic()auto-extends.retryCount: -1Other changes
LockServiceOptions,LockOptions,AcquiredLock,LockAbortSignal) are now exported from the package index. Before, public signatures referenced them without exporting them.{ unlock }and anoptimist()method that did not exist. It now includes a migration section.redlocktsconfigpathsworkaround and theioredis-mockdevDependency. The mock cannot run redlock-universal's Lua scripts, so tests use the real Redis that CI already provides.REDIS_URL/REDIS_PORTfor local runs.Verification
nx format:checkandnx sync:checkpass.extend,optimisticand retry-until-released.nx release --dry-run --projects=nestjs-tools-lock→ 2.0.0.