Skip to content

feat(utils): distributed reentrant mutex#2664

Open
inkedsquid wants to merge 9 commits into
2-devfrom
feat/distributed-reentrant-mutex
Open

feat(utils): distributed reentrant mutex#2664
inkedsquid wants to merge 9 commits into
2-devfrom
feat/distributed-reentrant-mutex

Conversation

@inkedsquid

@inkedsquid inkedsquid commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

This PR introduces a distributed reentrant mutex utilizing redlock-universal.

Specifically, it:

  • Adds the redlock-universal dependency to handle distributed locking via Redis.
  • Implements withLock in lib/util/mutex2.ts, utilizing Node's AsyncLocalStorage to keep track of acquired locks within the current execution context, achieving lock reentrancy.
  • Migrates lib/core/cache/cacheEngine and lib/service/cache/redis from JavaScript to TypeScript for better type safety.

How should this be manually tested?

  • Step 1 : Write an endpoint that call a mutex with withLock for the first time
  • Step 2 : Call it again in its context
  • Step 3 : It should not block until the first one timeout

Boyscout

  • Converted cacheEngine and redis service files to TypeScript (.ts) to improve the codebase's maintainability and developer experience.
  • Updated transpile target to es2021 for String#ReplaceAll (Sonar Issue)

KZLPRD-1241

@inkedsquid inkedsquid self-assigned this Jun 25, 2026
@inkedsquid inkedsquid changed the title Feat/distributed reentrant mutex feat(utils): distributed reentrant mutex Jun 25, 2026
@inkedsquid inkedsquid marked this pull request as draft June 25, 2026 08:31
@sonarqubecloud

Copy link
Copy Markdown

@inkedsquid inkedsquid marked this pull request as ready for review June 26, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant