murlock 4.1.0 → 4.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,8 +8,11 @@ MurLock is a distributed lock solution designed for the NestJS framework. It pro
8
8
  - **Parameter-Based Locking**: Creates locks based on request parameters or bodies.
9
9
  - **Highly Customizable**: Customize many parameters, such as lock duration.
10
10
  - **Retry Mechanism**: Implements an exponential back-off strategy if the lock is not obtained.
11
- - **Logging: Provides**: logging options for debugging and monitoring.
11
+ - **Logging**: Provides logging options for debugging and monitoring.
12
12
  - **OOP and Generic Structure**: Easily integratable and expandable due to its OOP and generic design.
13
+ - **Blocking Mode**: Optional infinite retry mode for critical operations.
14
+ - **Robust Redis Connection**: Automatic reconnection with configurable strategy.
15
+ - **Fail-Fast Option**: Configurable behavior on Redis connection failures.
13
16
 
14
17
  ## Installation
15
18
 
@@ -36,6 +39,8 @@ import { MurLockModule } from 'murlock';
36
39
  maxAttempts: 3,
37
40
  logLevel: 'log',
38
41
  ignoreUnlockFail: false,
42
+ failFastOnRedisError: false,
43
+ blocking: false,
39
44
  }),
40
45
  ],
41
46
  })
@@ -104,7 +109,9 @@ import { MurLockModule } from 'murlock';
104
109
  wait: configService.get('MURLOCK_WAIT'),
105
110
  maxAttempts: configService.get('MURLOCK_MAX_ATTEMPTS'),
106
111
  logLevel: configService.get('LOG_LEVEL'),
107
- ignoreUnlockFail: configService.get('LOG_LEVEL')
112
+ ignoreUnlockFail: configService.get('IGNORE_UNLOCK_FAIL'),
113
+ failFastOnRedisError: configService.get('FAIL_FAST_ON_REDIS_ERROR'),
114
+ blocking: configService.get('BLOCKING_MODE'),
108
115
  }),
109
116
  inject: [ConfigService],
110
117
  }),
@@ -115,7 +122,89 @@ export class AppModule {}
115
122
 
116
123
  In the example above, the `ConfigModule` and `ConfigService` are used to provide the configuration for MurLock asynchronously.
117
124
 
118
- For more details on usage and configuration, please refer to the API documentation below.
125
+ ## Overriding Global Wait Per Decorator
126
+
127
+ You can override the global wait parameter per decorator, allowing fine-grained retry control:
128
+
129
+ ### Example 1: Dynamic Wait Strategy
130
+
131
+ ```typescript
132
+ @MurLock(
133
+ 5000,
134
+ (retries) => (Math.floor(Math.random() * 50) + 50) * retries,
135
+ 'user.id',
136
+ )
137
+ async someFunction(user: User): Promise<void> {
138
+ // This uses a randomized backoff strategy for retrying lock acquisition.
139
+ }
140
+ ```
141
+
142
+ ### Example 2: Fixed Wait Strategy Per Method
143
+
144
+ ```typescript
145
+ @MurLock(5000, 1500, 'user.id')
146
+ async anotherFunction(user: User): Promise<void> {
147
+ // This will retry every 1500ms instead of global wait.
148
+ }
149
+ ```
150
+
151
+ - If no wait is provided in decorator, MurLock will fallback to global wait from forRoot().
152
+ - Allows dynamic retry logic per critical section.
153
+
154
+ ## Blocking Mode
155
+
156
+ MurLock supports a blocking mode where it will continuously retry to acquire the lock until successful. This is useful for critical operations that must eventually succeed.
157
+
158
+ ```typescript
159
+ @Module({
160
+ imports: [
161
+ MurLockModule.forRoot({
162
+ redisOptions: { url: 'redis://localhost:6379' },
163
+ wait: 1000,
164
+ maxAttempts: 3,
165
+ logLevel: 'log',
166
+ blocking: true, // Enable blocking mode
167
+ }),
168
+ ],
169
+ })
170
+ export class AppModule {}
171
+ ```
172
+
173
+ When blocking mode is enabled:
174
+
175
+ - The `maxAttempts` parameter is ignored
176
+ - The service will continuously retry to acquire the lock
177
+ - Each retry will wait for the specified `wait` time
178
+ - Redis errors will be logged but won't stop the retry process
179
+
180
+ ## Redis Connection Handling
181
+
182
+ MurLock includes robust Redis connection handling:
183
+
184
+ - **Automatic Reconnection**: Implements a reconnection strategy with exponential backoff
185
+ - **Connection Events**: Logs connection status changes (ready, reconnecting, end)
186
+ - **Fail-Fast Option**: Can be configured to exit the application on Redis connection failures
187
+
188
+ ```typescript
189
+ @Module({
190
+ imports: [
191
+ MurLockModule.forRoot({
192
+ redisOptions: {
193
+ url: 'redis://localhost:6379',
194
+ socket: {
195
+ keepAlive: false,
196
+ reconnectStrategy: (retries) => {
197
+ const delay = Math.min(retries * 500, 5000);
198
+ return delay;
199
+ },
200
+ },
201
+ },
202
+ failFastOnRedisError: true, // Exit application on Redis connection failure
203
+ }),
204
+ ],
205
+ })
206
+ export class AppModule {}
207
+ ```
119
208
 
120
209
  ## Using Custom Lock Key
121
210
 
@@ -229,14 +318,10 @@ try {
229
318
 
230
319
  Directly using `MurLockService` gives you finer control over lock management but also increases the responsibility to ensure locks are correctly managed throughout your application's lifecycle.
231
320
 
232
- ---
233
-
234
- This refined section is suitable for developers looking for documentation on using `MurLockService` directly in their projects and adheres to the typical conventions found in README files for open-source projects.
235
-
236
321
  ## Best Practices and Considerations
237
322
 
238
323
  - **Short-lived Locks**: Ensure that locks are short-lived to prevent deadlocks and to increase the efficiency of your application.
239
- **Error Handling**: Robustly handle errors during lock acquisition:
324
+ - **Error Handling**: Robustly handle errors during lock acquisition:
240
325
  - **Graceful Failures**: If a lock cannot be obtained, handle the situation gracefully, potentially logging the incident and retrying the operation.
241
326
  - **Consider Failures in Unlocking**: Even with `ignoreUnlockFail` set to true, implement error handling strategies to log and manage unlock failures, ensuring they do not disrupt the application flow.
242
327
  - **Logging**: Adjust the `logLevel` based on your environment. Use 'debug' for development and 'error' or 'warn' for production.
@@ -246,28 +331,35 @@ This refined section is suitable for developers looking for documentation on usi
246
331
  - **Custom**: Set `lockKeyPrefix` to 'custom' and define lock keys explicitly to fine-tune lock scope and granularity.
247
332
  - **Resource Cleanup**: Even though `runWithLock` manages lock cleanup, ensure your application logic correctly handles any necessary cleanup or rollback in case of errors.
248
333
  - **Use of Finally Block**: Explicitly manage lock release in a `finally` block to ensure that locks are always released, preventing potential deadlocks and resource leaks.
334
+ - **Redis Connection**: Configure Redis connection options appropriately for your environment:
335
+ - Use `failFastOnRedisError` in production to ensure application fails fast on Redis connection issues
336
+ - Consider using blocking mode for critical operations that must eventually succeed
337
+ - Configure appropriate reconnection strategies based on your network reliability
249
338
 
250
339
  ## API Documentation
251
340
 
252
- ### MurLock(releaseTime: number, ...keyParams: string[])
341
+ ### MurLock(releaseTime: number, wait?: number | ((retries: number) => number), ...keyParams: string[])
253
342
 
254
343
  A method decorator to indicate that a particular method should be locked.
255
344
 
256
345
  - `releaseTime`: Time in milliseconds after which the lock should be automatically released.
346
+ - `wait` (optional): Time in milliseconds to wait between retry attempts, or a function that calculates wait time based on retry count.
257
347
  - `...keyParams`: Method parameters based on which the lock should be made. The format is `paramName.attribute`. If just `paramName` is provided, it will use the `toString` method of that parameter.
258
348
 
259
349
  ### Configuration Options
260
350
 
261
351
  Here are the customizable options for `MurLockModule`, allowing you to tailor its behavior to best fit your application's needs:
262
352
 
263
- - **redisOptions:** Configuration settings for the Redis client, such as the connection URL.
353
+ - **redisOptions:** Configuration settings for the Redis client, such as the connection URL and socket options.
264
354
  - **wait:** Time in milliseconds to wait before retrying to obtain a lock if the initial attempt fails.
265
- - **maxAttempts:** The maximum number of attempts to try and acquire a lock before giving up.
355
+ - **maxAttempts:** The maximum number of attempts to try and acquire a lock before giving up (ignored in blocking mode).
266
356
  - **logLevel:** Determines the level of logging used within the module. Options include 'none', 'error', 'warn', 'log', or 'debug'.
267
357
  - **ignoreUnlockFail (optional):** When set to `true`, the module will not throw an exception if releasing a lock fails. This setting helps in scenarios where failing silently is preferred over interrupting the application flow. Defaults to `false` to ensure that failures are noticed and handled appropriately.
268
358
  - **lockKeyPrefix (optional)**: Specifies how lock keys are prefixed, allowing for greater flexibility:
269
359
  - **Default**: Uses class and method names as prefixes, e.g., `Userservice:createUser:{userId}`.
270
360
  - **Custom**: Set this to 'custom' to define lock keys manually in your service methods, allowing for specific lock key constructions beyond the standard naming.
361
+ - **failFastOnRedisError (optional)**: When set to `true`, the application will exit with code 1 if a Redis connection error occurs. Defaults to `false`.
362
+ - **blocking (optional)**: When set to `true`, the lock acquisition will retry indefinitely until successful. Defaults to `false`.
271
363
 
272
364
  ### MurLockService
273
365
 
@@ -2,7 +2,7 @@
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
  export declare class AsyncStorageManager<T> implements Map<string, T> {
4
4
  private readonly asyncLocalStorage;
5
- constructor(asyncLocalStorage: AsyncLocalStorage<Map<string, T>>);
5
+ constructor(asyncLocalStorage?: AsyncLocalStorage<Map<string, T>>);
6
6
  private getStore;
7
7
  register(): void;
8
8
  runWithNewContext<R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs): R;
@@ -1,10 +1,21 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
2
11
  var _a;
3
12
  Object.defineProperty(exports, "__esModule", { value: true });
4
13
  exports.AsyncStorageManager = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const async_hooks_1 = require("async_hooks");
5
16
  const exceptions_1 = require("../exceptions");
6
- class AsyncStorageManager {
7
- constructor(asyncLocalStorage) {
17
+ let AsyncStorageManager = class AsyncStorageManager {
18
+ constructor(asyncLocalStorage = new async_hooks_1.AsyncLocalStorage()) {
8
19
  this.asyncLocalStorage = asyncLocalStorage;
9
20
  this[_a] = '[object AsyncContext]';
10
21
  }
@@ -55,7 +66,11 @@ class AsyncStorageManager {
55
66
  [Symbol.iterator]() {
56
67
  return this.getStore()[Symbol.iterator]();
57
68
  }
58
- }
69
+ };
59
70
  exports.AsyncStorageManager = AsyncStorageManager;
60
71
  _a = Symbol.toStringTag;
72
+ exports.AsyncStorageManager = AsyncStorageManager = __decorate([
73
+ (0, common_1.Injectable)(),
74
+ __metadata("design:paramtypes", [Object])
75
+ ], AsyncStorageManager);
61
76
  //# sourceMappingURL=als-manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"als-manager.js","sourceRoot":"","sources":["../../lib/als/als-manager.ts"],"names":[],"mappings":";;;;AACA,8CAA6D;AAE7D,MAAa,mBAAmB;IAC9B,YAA6B,iBAAoD;QAApD,sBAAiB,GAAjB,iBAAiB,CAAmC;QAgEjF,QAAoB,GAAW,uBAAuB,CAAC;IAhE8B,CAAC;IAE9E,QAAQ;QACd,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;QAEhD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,yCAA4B,CAAC,uBAAuB,CAAC,CAAC;SACjE;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,iBAAiB,CAAyB,EAAyB,EAAE,GAAG,IAAW;QACjF,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAW,IAAI,GAAG,EAAa,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACjF,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,G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;IACnC,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC5C,CAAC;CAGF,CAAA;AAjEY,kDAAmB;KAgE7B,MAAM,CAAC,WAAW;8BAhER,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;;GACA,mBAAmB,CAiE/B"}
@@ -1,4 +1,2 @@
1
- import { DynamicModule } from '@nestjs/common';
2
1
  export declare class AsyncStorageManagerModule {
3
- static forRoot(): DynamicModule;
4
2
  }
@@ -5,24 +5,28 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var AsyncStorageManagerModule_1;
9
8
  Object.defineProperty(exports, "__esModule", { value: true });
10
9
  exports.AsyncStorageManagerModule = void 0;
11
10
  const common_1 = require("@nestjs/common");
12
11
  const als_manager_1 = require("./als-manager");
13
12
  const als_service_1 = require("./als.service");
14
- let AsyncStorageManagerModule = AsyncStorageManagerModule_1 = class AsyncStorageManagerModule {
15
- static forRoot() {
16
- return {
17
- module: AsyncStorageManagerModule_1,
18
- providers: [als_service_1.AsyncStorageService, als_manager_1.AsyncStorageManager],
19
- exports: [als_service_1.AsyncStorageService]
20
- };
21
- }
13
+ const async_hooks_1 = require("async_hooks");
14
+ let AsyncStorageManagerModule = class AsyncStorageManagerModule {
22
15
  };
23
16
  exports.AsyncStorageManagerModule = AsyncStorageManagerModule;
24
- exports.AsyncStorageManagerModule = AsyncStorageManagerModule = AsyncStorageManagerModule_1 = __decorate([
17
+ exports.AsyncStorageManagerModule = AsyncStorageManagerModule = __decorate([
25
18
  (0, common_1.Global)(),
26
- (0, common_1.Module)({})
19
+ (0, common_1.Module)({
20
+ providers: [
21
+ {
22
+ provide: als_manager_1.AsyncStorageManager,
23
+ useFactory: () => {
24
+ return new als_manager_1.AsyncStorageManager(new async_hooks_1.AsyncLocalStorage());
25
+ },
26
+ },
27
+ als_service_1.AsyncStorageService,
28
+ ],
29
+ exports: [als_service_1.AsyncStorageService],
30
+ })
27
31
  ], AsyncStorageManagerModule);
28
32
  //# sourceMappingURL=als.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"als.module.js","sourceRoot":"","sources":["../../lib/als/als.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA8D;AAC9D,+CAAoD;AACpD,+CAAoD;AAI7C,IAAM,yBAAyB,iCAA/B,MAAM,yBAAyB;IACpC,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,2BAAyB;YACjC,SAAS,EAAE,CAAC,iCAAmB,EAAE,iCAAmB,CAAC;YACrD,OAAO,EAAE,CAAC,iCAAmB,CAAC;SAC/B,CAAA;IACH,CAAC;CACF,CAAA;AARY,8DAAyB;oCAAzB,yBAAyB;IAFrC,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,yBAAyB,CAQrC"}
1
+ {"version":3,"file":"als.module.js","sourceRoot":"","sources":["../../lib/als/als.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,+CAAoD;AACpD,+CAAoD;AACpD,6CAAgD;AAezC,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;CAAG,CAAA;AAA5B,8DAAyB;oCAAzB,yBAAyB;IAbrC,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,iCAAmB;gBAC5B,UAAU,EAAE,GAAG,EAAE;oBACf,OAAO,IAAI,iCAAmB,CAAS,IAAI,+BAAiB,EAAuB,CAAC,CAAC;gBACvF,CAAC;aACF;YACD,iCAAmB;SACpB;QACD,OAAO,EAAE,CAAC,iCAAmB,CAAC;KAC/B,CAAC;GACW,yBAAyB,CAAG"}
@@ -1,10 +1,8 @@
1
- import { OnModuleInit } from "@nestjs/common";
2
- import { AsyncStorageManager } from "./als-manager";
3
- export declare class AsyncStorageService implements OnModuleInit {
4
- private asyncStorageManager;
1
+ import { AsyncStorageManager } from './als-manager';
2
+ export declare class AsyncStorageService {
3
+ private readonly asyncStorageManager;
5
4
  constructor(asyncStorageManager: AsyncStorageManager<string>);
6
- onModuleInit(): void;
7
- runWithNewContext<R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs): Promise<R>;
5
+ runWithNewContext<R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs): R;
8
6
  registerContext(): void;
9
7
  get(key: string): string;
10
8
  setClientID(key: string, value: string): void;
@@ -8,31 +8,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
- return new (P || (P = Promise))(function (resolve, reject) {
14
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
- step((generator = generator.apply(thisArg, _arguments || [])).next());
18
- });
19
- };
20
11
  Object.defineProperty(exports, "__esModule", { value: true });
21
12
  exports.AsyncStorageService = void 0;
22
13
  const common_1 = require("@nestjs/common");
23
14
  const als_manager_1 = require("./als-manager");
24
- const async_hooks_1 = require("async_hooks");
25
15
  let AsyncStorageService = class AsyncStorageService {
26
16
  constructor(asyncStorageManager) {
27
17
  this.asyncStorageManager = asyncStorageManager;
28
18
  }
29
- onModuleInit() {
30
- this.asyncStorageManager = new als_manager_1.AsyncStorageManager(new async_hooks_1.AsyncLocalStorage());
31
- }
32
19
  runWithNewContext(fn, ...args) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- return this.asyncStorageManager.runWithNewContext(fn, ...args);
35
- });
20
+ return this.asyncStorageManager.runWithNewContext(fn, ...args);
36
21
  }
37
22
  registerContext() {
38
23
  this.asyncStorageManager.register();
@@ -1 +1 @@
1
- {"version":3,"file":"als.service.js","sourceRoot":"","sources":["../../lib/als/als.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0D;AAC1D,+CAAoD;AACpD,6CAAgD;AAGzC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,YAAoB,mBAAgD;QAAhD,wBAAmB,GAAnB,mBAAmB,CAA6B;IAAI,CAAC;IAEzE,YAAY;QACV,IAAI,CAAC,mBAAmB,GAAG,IAAI,iCAAmB,CAAC,IAAI,+BAAiB,EAAO,CAAC,CAAC;IACnF,CAAC;IAEK,iBAAiB,CAAyB,EAAyB,EAAE,GAAG,IAAW;;YACvF,OAAO,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACjE,CAAC;KAAA;IAED,eAAe;QACb,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAED,WAAW,CAAC,GAAW,EAAE,KAAa;QACpC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF,CAAA;AAtBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAE8B,iCAAmB;GADjD,mBAAmB,CAsB/B"}
1
+ {"version":3,"file":"als.service.js","sourceRoot":"","sources":["../../lib/als/als.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAAoD;AAG7C,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,YAA6B,mBAAgD;QAAhD,wBAAmB,GAAnB,mBAAmB,CAA6B;IAAG,CAAC;IAEjF,iBAAiB,CAAyB,EAAyB,EAAE,GAAG,IAAW;QACjF,OAAO,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACjE,CAAC;IAED,eAAe;QACb,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAED,WAAW,CAAC,GAAW,EAAE,KAAa;QACpC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF,CAAA;AAlBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAEuC,iCAAmB;GAD1D,mBAAmB,CAkB/B"}
@@ -6,6 +6,8 @@ export interface MurLockModuleOptions {
6
6
  logLevel: 'none' | 'error' | 'warn' | 'log' | 'debug';
7
7
  ignoreUnlockFail?: boolean;
8
8
  lockKeyPrefix?: 'default' | 'custom';
9
+ failFastOnRedisError?: boolean;
10
+ blocking?: boolean;
9
11
  }
10
12
  export interface MurLockModuleAsyncOptions {
11
13
  imports?: any[];
@@ -15,7 +15,7 @@ let MurLockModule = MurLockModule_1 = class MurLockModule {
15
15
  static forRoot(options) {
16
16
  return {
17
17
  module: MurLockModule_1,
18
- imports: [als_module_1.AsyncStorageManagerModule.forRoot()],
18
+ imports: [als_module_1.AsyncStorageManagerModule],
19
19
  providers: [
20
20
  {
21
21
  provide: 'MURLOCK_OPTIONS',
@@ -29,8 +29,14 @@ let MurLockModule = MurLockModule_1 = class MurLockModule {
29
29
  static forRootAsync(options) {
30
30
  return {
31
31
  module: MurLockModule_1,
32
- imports: [als_module_1.AsyncStorageManagerModule.forRoot(), ...options.imports],
33
- providers: [this.createAsyncOptionsProvider(options), murlock_service_1.MurLockService],
32
+ imports: [
33
+ als_module_1.AsyncStorageManagerModule,
34
+ ...(options.imports || [])
35
+ ],
36
+ providers: [
37
+ this.createAsyncOptionsProvider(options),
38
+ murlock_service_1.MurLockService,
39
+ ],
34
40
  exports: [murlock_service_1.MurLockService],
35
41
  };
36
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"murlock.module.js","sourceRoot":"","sources":["../lib/murlock.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAyE;AACzE,iDAA6D;AAE7D,uDAAmD;AAI5C,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACxB,MAAM,CAAC,OAAO,CAAC,OAA6B;QAC1C,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,OAAO,EAAE,CAAC,sCAAyB,CAAC,OAAO,EAAE,CAAC;YAC9C,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,iBAAiB;oBAC1B,QAAQ,EAAE,OAAO;iBAClB;gBACD,gCAAc;aACf;YACD,OAAO,EAAE,CAAC,gCAAc,CAAC;SAC1B,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,OAAkC;QACpD,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,OAAO,EAAE,CAAC,sCAAyB,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;YAClE,SAAS,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,gCAAc,CAAC;YACrE,OAAO,EA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AAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;SAC7B,CAAC;IACJ,CAAC;CACF,CAAA;AAxCY,sCAAa;wBAAb,aAAa;IAFzB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,aAAa,CAwCzB"}
@@ -6,8 +6,8 @@ export declare class MurLockService implements OnModuleInit, OnApplicationShutdo
6
6
  private readonly asyncStorageService;
7
7
  private readonly logger;
8
8
  private redisClient;
9
- private readonly lockScript;
10
- private readonly unlockScript;
9
+ private lockScript;
10
+ private unlockScript;
11
11
  constructor(options: MurLockModuleOptions, asyncStorageService: AsyncStorageService);
12
12
  onModuleInit(): Promise<void>;
13
13
  onApplicationShutdown(signal?: string): Promise<void>;
@@ -19,4 +19,6 @@ export declare class MurLockService implements OnModuleInit, OnApplicationShutdo
19
19
  private releaseLock;
20
20
  runWithLock<R>(lockKey: string, releaseTime: number, fn: () => Promise<R>): any;
21
21
  runWithLock<R>(lockKey: string, releaseTime: number, wait: number | ((retries: number) => number), fn: () => Promise<R>): any;
22
+ private registerRedisErrorHandlers;
23
+ private blockingLock;
22
24
  }
@@ -24,7 +24,7 @@ var MurLockService_1;
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.MurLockService = void 0;
26
26
  const common_1 = require("@nestjs/common");
27
- const fs_1 = require("fs");
27
+ const promises_1 = require("fs/promises");
28
28
  const path_1 = require("path");
29
29
  const redis_1 = require("redis");
30
30
  const als_service_1 = require("./als/als.service");
@@ -35,17 +35,34 @@ let MurLockService = MurLockService_1 = class MurLockService {
35
35
  this.options = options;
36
36
  this.asyncStorageService = asyncStorageService;
37
37
  this.logger = new common_1.Logger(MurLockService_1.name);
38
- this.lockScript = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, './lua/lock.lua')).toString();
39
- this.unlockScript = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, './lua/unlock.lua')).toString();
40
38
  }
41
39
  onModuleInit() {
42
40
  return __awaiter(this, void 0, void 0, function* () {
43
- this.redisClient = (0, redis_1.createClient)(this.options.redisOptions);
44
- this.redisClient.on('error', (err) => {
45
- this.log('error', 'MurLock Redis Client Error', err);
46
- throw new exceptions_1.MurLockRedisException(`MurLock Redis Client Error: ${err.message}`);
47
- });
48
- yield this.redisClient.connect();
41
+ try {
42
+ this.lockScript = yield (0, promises_1.readFile)((0, path_1.join)(__dirname, './lua/lock.lua'), 'utf8');
43
+ this.unlockScript = yield (0, promises_1.readFile)((0, path_1.join)(__dirname, './lua/unlock.lua'), 'utf8');
44
+ }
45
+ catch (error) {
46
+ throw new exceptions_1.MurLockException(`Failed to load Lua scripts: ${error.message}`);
47
+ }
48
+ this.redisClient = (0, redis_1.createClient)(Object.assign(Object.assign({}, this.options.redisOptions), { socket: {
49
+ keepAlive: false,
50
+ reconnectStrategy: (retries) => {
51
+ const delay = Math.min(retries * 500, 5000);
52
+ this.log('warn', `MurLock Redis reconnect attempt ${retries}, waiting ${delay} ms...`);
53
+ return delay;
54
+ },
55
+ } }));
56
+ this.registerRedisErrorHandlers();
57
+ try {
58
+ yield this.redisClient.connect();
59
+ }
60
+ catch (error) {
61
+ this.log('error', `Failed to connect to Redis: ${error.message}`);
62
+ if (this.options.failFastOnRedisError) {
63
+ throw new exceptions_1.MurLockException(`Redis connection failed: ${error.message}`);
64
+ }
65
+ }
49
66
  });
50
67
  }
51
68
  onApplicationShutdown(signal) {
@@ -73,6 +90,9 @@ let MurLockService = MurLockService_1 = class MurLockService {
73
90
  lock(lockKey, releaseTime, clientId, wait) {
74
91
  return __awaiter(this, void 0, void 0, function* () {
75
92
  this.log('debug', `MurLock Client ID is ${clientId}`);
93
+ if (this.options.blocking) {
94
+ return this.blockingLock(lockKey, releaseTime, clientId);
95
+ }
76
96
  const attemptLock = (attemptsRemaining) => __awaiter(this, void 0, void 0, function* () {
77
97
  if (attemptsRemaining === 0) {
78
98
  throw new exceptions_1.MurLockException(`Failed to obtain lock for key ${lockKey} after ${this.options.maxAttempts} attempts.`);
@@ -175,6 +195,52 @@ let MurLockService = MurLockService_1 = class MurLockService {
175
195
  }
176
196
  });
177
197
  }
198
+ registerRedisErrorHandlers() {
199
+ this.redisClient.on('error', (err) => {
200
+ this.log('error', `MurLock Redis Client Error: ${err.message}`);
201
+ if (this.options.failFastOnRedisError) {
202
+ this.log('error', 'MurLock Redis entering fail-fast shutdown due to Redis error.');
203
+ process.exit(1);
204
+ }
205
+ });
206
+ this.redisClient.on('reconnecting', () => {
207
+ this.log('warn', 'MurLock Redis Client attempting reconnect...');
208
+ });
209
+ this.redisClient.on('ready', () => {
210
+ this.log('log', 'MurLock Redis Client connected and ready.');
211
+ });
212
+ this.redisClient.on('end', () => {
213
+ this.log('warn', 'MurLock Redis Client connection closed.');
214
+ });
215
+ }
216
+ blockingLock(lockKey, releaseTime, clientId) {
217
+ return __awaiter(this, void 0, void 0, function* () {
218
+ while (true) {
219
+ try {
220
+ const isLockSuccessful = yield this.redisClient.sendCommand([
221
+ 'EVAL',
222
+ this.lockScript,
223
+ '1',
224
+ lockKey,
225
+ clientId,
226
+ releaseTime.toString(),
227
+ ]);
228
+ if (isLockSuccessful === 1) {
229
+ this.log('log', `Successfully obtained lock for key ${lockKey} in blocking mode`);
230
+ return true;
231
+ }
232
+ else {
233
+ this.log('warn', `Lock busy for key ${lockKey}, waiting ${this.options.wait} ms before next attempt (blocking mode)...`);
234
+ yield this.sleep(this.options.wait);
235
+ }
236
+ }
237
+ catch (error) {
238
+ this.log('error', `Unexpected error in blocking lock for key ${lockKey}: ${error.message}`);
239
+ yield this.sleep(this.options.wait);
240
+ }
241
+ }
242
+ });
243
+ }
178
244
  };
179
245
  exports.MurLockService = MurLockService;
180
246
  exports.MurLockService = MurLockService = MurLockService_1 = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"murlock.service.js","sourceRoot":"","sources":["../lib/murlock.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAMwB;AACxB,2BAAkC;AAClC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