Skip to content

Commit

Permalink
Fix redlock release key method (#204)
Browse files Browse the repository at this point in the history
* Fix release method on redlock service

* Upgrade packages
  • Loading branch information
danielailie authored Jan 30, 2024
1 parent 47edf11 commit 3045ac7
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 29 deletions.
4 changes: 2 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "3.1.3",
"version": "3.1.4",
"packages": [
"packages/*"
],
"npmClient": "npm"
}
}
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-auth",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs auth package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -46,4 +46,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-cache",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs cache package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -49,4 +49,4 @@
"publishConfig": {
"access": "public"
}
}
}
9 changes: 5 additions & 4 deletions packages/cache/src/redlock/redlock.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export class RedlockService {
private readonly metricsService: MetricsService,
) { }

async release(key: string): Promise<void> {
const promise = async (redis: Redis) => await redis.del(key);
async release(type: string, key: string): Promise<void> {
const lockKey = `${type}:${key}`;
const promise = async (redis: Redis) => await redis.del(lockKey);
await Promise.allSettled(this.redisArray.map(promise));
}

Expand Down Expand Up @@ -76,7 +77,7 @@ export class RedlockService {
return lockResult;
}

const releasePromise = async (redis: Redis) => await redis.del(key);
const releasePromise = async (redis: Redis) => await redis.del(lockKey);
await Promise.allSettled(successInstances.map(releasePromise));

await this.sleep(config.retryInterval);
Expand Down Expand Up @@ -127,7 +128,7 @@ export class RedlockService {
clearTimeout(extensionId);
}

this.release(lockKey).catch(error => {
this.release(type, key).catch(error => {
this.logError(`Failed to release lock for resource '${lockKey}': ${error.message}`);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-common",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs common package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/elastic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-elastic",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs elastic package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -37,4 +37,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-http",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs http package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -46,4 +46,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/monitoring/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-monitoring",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs monitoring package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -41,4 +41,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/rabbitmq/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-rabbitmq",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs rabbitmq client package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -43,4 +43,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions packages/redis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-nestjs-redis",
"version": "3.1.3",
"version": "3.1.4",
"description": "Multiversx SDK Nestjs redis client package",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -40,4 +40,4 @@
"publishConfig": {
"access": "public"
}
}
}

0 comments on commit 3045ac7

Please sign in to comment.