@daiso-tech/core 0.32.0 → 0.33.0

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.
Files changed (126) hide show
  1. package/dist/async/async.errors.d.ts +14 -0
  2. package/dist/async/async.errors.js +14 -0
  3. package/dist/async/async.errors.js.map +1 -1
  4. package/dist/async/async.events.d.ts +23 -0
  5. package/dist/async/async.events.js +23 -0
  6. package/dist/async/async.events.js.map +1 -1
  7. package/dist/async/backof-policies/_shared.d.ts +1 -1
  8. package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.d.ts +2 -2
  9. package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +1 -1
  10. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts +2 -2
  11. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +1 -1
  12. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.d.ts +2 -2
  13. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +1 -1
  14. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +2 -2
  15. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +1 -1
  16. package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +7 -41
  17. package/dist/async/utilities/lazy-promise/lazy-promise.js +7 -8
  18. package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
  19. package/dist/cache/contracts/cache-factory.contract.d.ts +3 -3
  20. package/dist/cache/contracts/cache.contract.d.ts +0 -22
  21. package/dist/cache/contracts/cache.errors.d.ts +14 -1
  22. package/dist/cache/contracts/cache.errors.js +14 -1
  23. package/dist/cache/contracts/cache.errors.js.map +1 -1
  24. package/dist/cache/contracts/cache.events.d.ts +28 -14
  25. package/dist/cache/contracts/cache.events.js +28 -3
  26. package/dist/cache/contracts/cache.events.js.map +1 -1
  27. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js +3 -3
  28. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js.map +1 -1
  29. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +0 -1
  30. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
  31. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js +3 -3
  32. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js.map +1 -1
  33. package/dist/cache/implementations/derivables/cache/cache.d.ts +9 -139
  34. package/dist/cache/implementations/derivables/cache/cache.js +38 -229
  35. package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
  36. package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +6 -6
  37. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
  38. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +2 -2
  39. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +1 -1
  40. package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +4 -4
  41. package/dist/cache/implementations/test-utilities/cache.test-suite.js +239 -433
  42. package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
  43. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +2 -2
  44. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +1 -1
  45. package/dist/collection/contracts/collection.errors.d.ts +17 -0
  46. package/dist/collection/contracts/collection.errors.js +17 -0
  47. package/dist/collection/contracts/collection.errors.js.map +1 -1
  48. package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +3 -3
  49. package/dist/event-bus/contracts/event-bus.contract.d.ts +2 -44
  50. package/dist/event-bus/contracts/event-bus.contract.js.map +1 -1
  51. package/dist/event-bus/contracts/event-bus.errors.d.ts +16 -1
  52. package/dist/event-bus/contracts/event-bus.errors.js +16 -1
  53. package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
  54. package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +6 -77
  55. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +11 -131
  56. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  57. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +4 -4
  58. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
  59. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +2 -2
  60. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +1 -1
  61. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +4 -4
  62. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +691 -1432
  63. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
  64. package/dist/lock/contracts/lock-provider-factory.contract.d.ts +3 -3
  65. package/dist/lock/contracts/lock-provider.contract.d.ts +10 -20
  66. package/dist/lock/contracts/lock.contract.d.ts +1 -10
  67. package/dist/lock/contracts/lock.errors.d.ts +18 -0
  68. package/dist/lock/contracts/lock.errors.js +18 -0
  69. package/dist/lock/contracts/lock.errors.js.map +1 -1
  70. package/dist/lock/contracts/lock.events.d.ts +22 -0
  71. package/dist/lock/contracts/lock.events.js +22 -0
  72. package/dist/lock/contracts/lock.events.js.map +1 -1
  73. package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +12 -155
  74. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +31 -228
  75. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
  76. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +5 -5
  77. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +7 -30
  78. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
  79. package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +8 -58
  80. package/dist/lock/implementations/derivables/lock-provider/lock.js +33 -105
  81. package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
  82. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +9 -8
  83. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
  84. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +2 -2
  85. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +178 -659
  86. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
  87. package/dist/serde/contracts/deserializer.contract.d.ts +1 -1
  88. package/dist/serde/contracts/deserializer.contract.js +1 -1
  89. package/dist/serde/contracts/deserializer.contract.js.map +1 -1
  90. package/dist/serde/contracts/serde.errors.d.ts +14 -2
  91. package/dist/serde/contracts/serde.errors.js +16 -4
  92. package/dist/serde/contracts/serde.errors.js.map +1 -1
  93. package/dist/serde/contracts/serializer.contract.d.ts +1 -1
  94. package/dist/serde/contracts/serializer.contract.js +1 -1
  95. package/dist/serde/contracts/serializer.contract.js.map +1 -1
  96. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +3 -3
  97. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +1 -1
  98. package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +3 -3
  99. package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +1 -1
  100. package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +3 -3
  101. package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +1 -1
  102. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +3 -3
  103. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
  104. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +2 -2
  105. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +1 -1
  106. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +2 -2
  107. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +1 -1
  108. package/dist/utilities/classes/key-prefixer/_module.d.ts +0 -1
  109. package/dist/utilities/classes/key-prefixer/_module.js +0 -1
  110. package/dist/utilities/classes/key-prefixer/_module.js.map +1 -1
  111. package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +2 -11
  112. package/dist/utilities/classes/key-prefixer/key-prefixer.js +4 -46
  113. package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
  114. package/dist/utilities/errors.d.ts +2 -0
  115. package/dist/utilities/errors.js +2 -0
  116. package/dist/utilities/errors.js.map +1 -1
  117. package/package.json +3 -4
  118. package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.d.ts +0 -15
  119. package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.js +0 -50
  120. package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.js.map +0 -1
  121. package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.d.ts +0 -23
  122. package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.js +0 -44
  123. package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.js.map +0 -1
  124. package/dist/utilities/classes/key-prefixer/key-prefixer.contract.d.ts +0 -28
  125. package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js +0 -5
  126. package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js.map +0 -1
@@ -54,12 +54,9 @@ import { Serde } from "../../../serde/implementations/derivables/_module-exports
54
54
  */
55
55
  export function lockProviderTestSuite(settings) {
56
56
  const { expect, test, createLockProvider, describe, beforeEach, serde = new Serde(new NoOpSerdeAdapter()), } = settings;
57
- let lockProviderA;
58
- let lockProviderB;
57
+ let lockProvider;
59
58
  beforeEach(async () => {
60
- const lockProvider = await createLockProvider();
61
- lockProviderA = lockProvider;
62
- lockProviderB = lockProvider.withGroup("b");
59
+ lockProvider = await createLockProvider();
63
60
  });
64
61
  const TTL = TimeSpan.fromMilliseconds(50);
65
62
  const DELAY_TIME = TimeSpan.fromMilliseconds(50);
@@ -68,7 +65,7 @@ export function lockProviderTestSuite(settings) {
68
65
  test("Should return string when lock is available", async () => {
69
66
  const key = "a";
70
67
  const ttl = null;
71
- const lock = lockProviderA.create(key, {
68
+ const lock = lockProvider.create(key, {
72
69
  ttl,
73
70
  });
74
71
  const [result, error] = await lock.run(async () => {
@@ -81,7 +78,7 @@ export function lockProviderTestSuite(settings) {
81
78
  test("Should return null when lock is already acquired", async () => {
82
79
  const key = "a";
83
80
  const ttl = null;
84
- const lock = lockProviderA.create(key, {
81
+ const lock = lockProvider.create(key, {
85
82
  ttl,
86
83
  });
87
84
  await lock.acquire();
@@ -95,7 +92,7 @@ export function lockProviderTestSuite(settings) {
95
92
  test("Should work with LazyPromise", async () => {
96
93
  const key = "a";
97
94
  const ttl = null;
98
- const lock = lockProviderA.create(key, {
95
+ const lock = lockProvider.create(key, {
99
96
  ttl,
100
97
  });
101
98
  const [result, error] = await lock.run(new LazyPromise(async () => {
@@ -110,7 +107,7 @@ export function lockProviderTestSuite(settings) {
110
107
  test("Should return string when lock is available", async () => {
111
108
  const key = "a";
112
109
  const ttl = null;
113
- const lock = lockProviderA.create(key, {
110
+ const lock = lockProvider.create(key, {
114
111
  ttl,
115
112
  });
116
113
  const result = await lock.runOrFail(async () => {
@@ -122,7 +119,7 @@ export function lockProviderTestSuite(settings) {
122
119
  test("Should throw KeyAlreadyAcquiredLockError when lock is already acquired", async () => {
123
120
  const key = "a";
124
121
  const ttl = null;
125
- const lock = lockProviderA.create(key, {
122
+ const lock = lockProvider.create(key, {
126
123
  ttl,
127
124
  });
128
125
  await lock.acquire();
@@ -135,7 +132,7 @@ export function lockProviderTestSuite(settings) {
135
132
  test("Should work with LazyPromise", async () => {
136
133
  const key = "a";
137
134
  const ttl = null;
138
- const lock = lockProviderA.create(key, {
135
+ const lock = lockProvider.create(key, {
139
136
  ttl,
140
137
  });
141
138
  const result = await lock.runOrFail(new LazyPromise(async () => {
@@ -149,7 +146,7 @@ export function lockProviderTestSuite(settings) {
149
146
  test("Should return string when lock is available", async () => {
150
147
  const key = "a";
151
148
  const ttl = null;
152
- const lock = lockProviderA.create(key, {
149
+ const lock = lockProvider.create(key, {
153
150
  ttl,
154
151
  });
155
152
  const [result, error] = await lock.runBlocking(async () => {
@@ -165,7 +162,7 @@ export function lockProviderTestSuite(settings) {
165
162
  test("Should return null when lock is already acquired", async () => {
166
163
  const key = "a";
167
164
  const ttl = null;
168
- const lock = lockProviderA.create(key, {
165
+ const lock = lockProvider.create(key, {
169
166
  ttl,
170
167
  });
171
168
  await lock.acquire();
@@ -182,7 +179,7 @@ export function lockProviderTestSuite(settings) {
182
179
  test("Should work with LazyPromise", async () => {
183
180
  const key = "a";
184
181
  const ttl = null;
185
- const lock = lockProviderA.create(key, {
182
+ const lock = lockProvider.create(key, {
186
183
  ttl,
187
184
  });
188
185
  const [result, error] = await lock.runBlocking(new LazyPromise(async () => {
@@ -198,12 +195,12 @@ export function lockProviderTestSuite(settings) {
198
195
  test("Should retry acquire the lock", async () => {
199
196
  const key = "a";
200
197
  const ttl = TimeSpan.fromMilliseconds(50);
201
- const lock = lockProviderA.create(key, {
198
+ const lock = lockProvider.create(key, {
202
199
  ttl,
203
200
  });
204
201
  await lock.acquire();
205
202
  let index = 0;
206
- await lock.addListener(KeyAlreadyAcquiredLockEvent, (_event) => {
203
+ await lockProvider.addListener(KeyAlreadyAcquiredLockEvent, (_event) => {
207
204
  index++;
208
205
  });
209
206
  await lock.runBlocking(async () => {
@@ -219,7 +216,7 @@ export function lockProviderTestSuite(settings) {
219
216
  test("Should return string when lock is available", async () => {
220
217
  const key = "a";
221
218
  const ttl = null;
222
- const lock = lockProviderA.create(key, {
219
+ const lock = lockProvider.create(key, {
223
220
  ttl,
224
221
  });
225
222
  const result = await lock.runBlockingOrFail(async () => {
@@ -234,7 +231,7 @@ export function lockProviderTestSuite(settings) {
234
231
  test("Should throw KeyAlreadyAcquiredLockError when lock is already acquired", async () => {
235
232
  const key = "a";
236
233
  const ttl = null;
237
- const lock = lockProviderA.create(key, {
234
+ const lock = lockProvider.create(key, {
238
235
  ttl,
239
236
  });
240
237
  await lock.acquire();
@@ -250,7 +247,7 @@ export function lockProviderTestSuite(settings) {
250
247
  test("Should work with LazyPromise", async () => {
251
248
  const key = "a";
252
249
  const ttl = null;
253
- const lock = lockProviderA.create(key, {
250
+ const lock = lockProvider.create(key, {
254
251
  ttl,
255
252
  });
256
253
  const result = await lock.runBlockingOrFail(new LazyPromise(async () => {
@@ -265,12 +262,12 @@ export function lockProviderTestSuite(settings) {
265
262
  test("Should retry acquire the lock", async () => {
266
263
  const key = "a";
267
264
  const ttl = TimeSpan.fromMilliseconds(50);
268
- const lock = lockProviderA.create(key, {
265
+ const lock = lockProvider.create(key, {
269
266
  ttl,
270
267
  });
271
268
  await lock.acquire();
272
269
  let index = 0;
273
- await lock.addListener(KeyAlreadyAcquiredLockEvent, (_event) => {
270
+ await lockProvider.addListener(KeyAlreadyAcquiredLockEvent, (_event) => {
274
271
  index++;
275
272
  });
276
273
  try {
@@ -291,7 +288,7 @@ export function lockProviderTestSuite(settings) {
291
288
  test("Should return true when lock is available", async () => {
292
289
  const key = "a";
293
290
  const ttl = null;
294
- const lock = lockProviderA.create(key, {
291
+ const lock = lockProvider.create(key, {
295
292
  ttl,
296
293
  });
297
294
  const result = await lock.acquire();
@@ -300,7 +297,7 @@ export function lockProviderTestSuite(settings) {
300
297
  test("Should return false when lock is already acquired", async () => {
301
298
  const key = "a";
302
299
  const ttl = null;
303
- const lock = lockProviderA.create(key, {
300
+ const lock = lockProvider.create(key, {
304
301
  ttl,
305
302
  });
306
303
  await lock.acquire();
@@ -311,7 +308,7 @@ export function lockProviderTestSuite(settings) {
311
308
  const key = "a";
312
309
  const ttl = null;
313
310
  const owner = "b";
314
- const lock = lockProviderA.create(key, {
311
+ const lock = lockProvider.create(key, {
315
312
  ttl,
316
313
  owner,
317
314
  });
@@ -323,7 +320,7 @@ export function lockProviderTestSuite(settings) {
323
320
  const key = "a";
324
321
  const ttl = null;
325
322
  const owner = "b";
326
- const lock = lockProviderA.create(key, {
323
+ const lock = lockProvider.create(key, {
327
324
  ttl,
328
325
  owner,
329
326
  });
@@ -336,7 +333,7 @@ export function lockProviderTestSuite(settings) {
336
333
  test("Should not throw KeyAlreadyAcquiredLockError when lock is available", async () => {
337
334
  const key = "a";
338
335
  const ttl = null;
339
- const lock = lockProviderA.create(key, {
336
+ const lock = lockProvider.create(key, {
340
337
  ttl,
341
338
  });
342
339
  const result = lock.acquireOrFail();
@@ -345,7 +342,7 @@ export function lockProviderTestSuite(settings) {
345
342
  test("Should throw KeyAlreadyAcquiredLockError when lock is already acquired", async () => {
346
343
  const key = "a";
347
344
  const ttl = null;
348
- const lock = lockProviderA.create(key, {
345
+ const lock = lockProvider.create(key, {
349
346
  ttl,
350
347
  });
351
348
  await lock.acquireOrFail();
@@ -357,7 +354,7 @@ export function lockProviderTestSuite(settings) {
357
354
  test("Should return true when lock is available", async () => {
358
355
  const key = "a";
359
356
  const ttl = null;
360
- const lock = lockProviderA.create(key, {
357
+ const lock = lockProvider.create(key, {
361
358
  ttl,
362
359
  });
363
360
  const result = await lock.acquireBlocking({
@@ -369,7 +366,7 @@ export function lockProviderTestSuite(settings) {
369
366
  test("Should return false when lock is already acquired", async () => {
370
367
  const key = "a";
371
368
  const ttl = null;
372
- const lock = lockProviderA.create(key, {
369
+ const lock = lockProvider.create(key, {
373
370
  ttl,
374
371
  });
375
372
  await lock.acquireBlocking({
@@ -386,7 +383,7 @@ export function lockProviderTestSuite(settings) {
386
383
  const key = "a";
387
384
  const ttl = null;
388
385
  const owner = "b";
389
- const lock = lockProviderA.create(key, {
386
+ const lock = lockProvider.create(key, {
390
387
  ttl,
391
388
  owner,
392
389
  });
@@ -401,7 +398,7 @@ export function lockProviderTestSuite(settings) {
401
398
  const key = "a";
402
399
  const ttl = null;
403
400
  const owner = "b";
404
- const lock = lockProviderA.create(key, {
401
+ const lock = lockProvider.create(key, {
405
402
  ttl,
406
403
  owner,
407
404
  });
@@ -415,12 +412,12 @@ export function lockProviderTestSuite(settings) {
415
412
  test("Should retry acquire the lock", async () => {
416
413
  const key = "a";
417
414
  const ttl = TimeSpan.fromMilliseconds(50);
418
- const lock = lockProviderA.create(key, {
415
+ const lock = lockProvider.create(key, {
419
416
  ttl,
420
417
  });
421
418
  await lock.acquire();
422
419
  let index = 0;
423
- await lock.addListener(KeyAlreadyAcquiredLockEvent, (_event) => {
420
+ await lockProvider.addListener(KeyAlreadyAcquiredLockEvent, (_event) => {
424
421
  index++;
425
422
  });
426
423
  await lock.acquireBlocking({
@@ -434,7 +431,7 @@ export function lockProviderTestSuite(settings) {
434
431
  test("Should not throw KeyAlreadyAcquiredLockError when lock is available", async () => {
435
432
  const key = "a";
436
433
  const ttl = null;
437
- const lock = lockProviderA.create(key, {
434
+ const lock = lockProvider.create(key, {
438
435
  ttl,
439
436
  });
440
437
  const promise = lock.acquireBlockingOrFail({
@@ -446,7 +443,7 @@ export function lockProviderTestSuite(settings) {
446
443
  test("Should throw KeyAlreadyAcquiredLockError when lock is already acquired", async () => {
447
444
  const key = "a";
448
445
  const ttl = null;
449
- const lock = lockProviderA.create(key, {
446
+ const lock = lockProvider.create(key, {
450
447
  ttl,
451
448
  });
452
449
  await lock.acquireBlockingOrFail({
@@ -463,7 +460,7 @@ export function lockProviderTestSuite(settings) {
463
460
  const key = "a";
464
461
  const ttl = null;
465
462
  const owner = "b";
466
- const lock = lockProviderA.create(key, {
463
+ const lock = lockProvider.create(key, {
467
464
  ttl,
468
465
  owner,
469
466
  });
@@ -478,7 +475,7 @@ export function lockProviderTestSuite(settings) {
478
475
  const key = "a";
479
476
  const ttl = null;
480
477
  const owner = "b";
481
- const lock = lockProviderA.create(key, {
478
+ const lock = lockProvider.create(key, {
482
479
  ttl,
483
480
  owner,
484
481
  });
@@ -492,12 +489,12 @@ export function lockProviderTestSuite(settings) {
492
489
  test("Should retry acquire the lock", async () => {
493
490
  const key = "a";
494
491
  const ttl = TimeSpan.fromMilliseconds(50);
495
- const lock = lockProviderA.create(key, {
492
+ const lock = lockProvider.create(key, {
496
493
  ttl,
497
494
  });
498
495
  await lock.acquire();
499
496
  let index = 0;
500
- await lock.addListener(KeyAlreadyAcquiredLockEvent, (_event) => {
497
+ await lockProvider.addListener(KeyAlreadyAcquiredLockEvent, (_event) => {
501
498
  index++;
502
499
  });
503
500
  try {
@@ -517,7 +514,7 @@ export function lockProviderTestSuite(settings) {
517
514
  const key = "a";
518
515
  const ttl = null;
519
516
  const owner = "b";
520
- const lock = lockProviderA.create(key, {
517
+ const lock = lockProvider.create(key, {
521
518
  ttl,
522
519
  owner,
523
520
  });
@@ -529,13 +526,13 @@ export function lockProviderTestSuite(settings) {
529
526
  const key = "a";
530
527
  const ttl = null;
531
528
  const owner1 = "b";
532
- const lock1 = lockProviderA.create(key, {
529
+ const lock1 = lockProvider.create(key, {
533
530
  ttl,
534
531
  owner: owner1,
535
532
  });
536
533
  await lock1.acquire();
537
534
  const owner2 = "c";
538
- const lock2 = lockProviderA.create(key, {
535
+ const lock2 = lockProvider.create(key, {
539
536
  ttl,
540
537
  owner: owner2,
541
538
  });
@@ -546,7 +543,7 @@ export function lockProviderTestSuite(settings) {
546
543
  const key = "a";
547
544
  const ttl = null;
548
545
  const owner = "b";
549
- const lock = lockProviderA.create(key, {
546
+ const lock = lockProvider.create(key, {
550
547
  ttl,
551
548
  owner,
552
549
  });
@@ -559,7 +556,7 @@ export function lockProviderTestSuite(settings) {
559
556
  const key = "a";
560
557
  const ttl = null;
561
558
  const owner = "b";
562
- const lock = lockProviderA.create(key, {
559
+ const lock = lockProvider.create(key, {
563
560
  ttl,
564
561
  owner,
565
562
  });
@@ -574,7 +571,7 @@ export function lockProviderTestSuite(settings) {
574
571
  const key = "a";
575
572
  const ttl = null;
576
573
  const owner = "b";
577
- const lock = lockProviderA.create(key, {
574
+ const lock = lockProvider.create(key, {
578
575
  ttl,
579
576
  owner,
580
577
  });
@@ -586,13 +583,13 @@ export function lockProviderTestSuite(settings) {
586
583
  const key = "a";
587
584
  const ttl = null;
588
585
  const owner1 = "b";
589
- const lock1 = lockProviderA.create(key, {
586
+ const lock1 = lockProvider.create(key, {
590
587
  ttl,
591
588
  owner: owner1,
592
589
  });
593
590
  await lock1.acquire();
594
591
  const owner2 = "c";
595
- const lock2 = lockProviderA.create(key, {
592
+ const lock2 = lockProvider.create(key, {
596
593
  ttl,
597
594
  owner: owner2,
598
595
  });
@@ -603,7 +600,7 @@ export function lockProviderTestSuite(settings) {
603
600
  const key = "a";
604
601
  const ttl = null;
605
602
  const owner = "b";
606
- const lock = lockProviderA.create(key, {
603
+ const lock = lockProvider.create(key, {
607
604
  ttl,
608
605
  owner,
609
606
  });
@@ -616,7 +613,7 @@ export function lockProviderTestSuite(settings) {
616
613
  const key = "a";
617
614
  const ttl = null;
618
615
  const owner = "b";
619
- const lock = lockProviderA.create(key, {
616
+ const lock = lockProvider.create(key, {
620
617
  ttl,
621
618
  owner,
622
619
  });
@@ -631,13 +628,13 @@ export function lockProviderTestSuite(settings) {
631
628
  const key = "a";
632
629
  const ttl = null;
633
630
  const owner1 = "b";
634
- const lock1 = lockProviderA.create(key, {
631
+ const lock1 = lockProvider.create(key, {
635
632
  ttl,
636
633
  owner: owner1,
637
634
  });
638
635
  await lock1.acquire();
639
636
  const owner2 = "c";
640
- const lock2 = lockProviderA.create(key, {
637
+ const lock2 = lockProvider.create(key, {
641
638
  ttl,
642
639
  owner: owner2,
643
640
  });
@@ -649,7 +646,7 @@ export function lockProviderTestSuite(settings) {
649
646
  const key = "a";
650
647
  const ttl = null;
651
648
  const owner = "b";
652
- const lock = lockProviderA.create(key, {
649
+ const lock = lockProvider.create(key, {
653
650
  ttl,
654
651
  owner,
655
652
  });
@@ -662,7 +659,7 @@ export function lockProviderTestSuite(settings) {
662
659
  const key = "a";
663
660
  const ttl = null;
664
661
  const owner = "b";
665
- const lock = lockProviderA.create(key, {
662
+ const lock = lockProvider.create(key, {
666
663
  ttl,
667
664
  owner,
668
665
  });
@@ -677,7 +674,7 @@ export function lockProviderTestSuite(settings) {
677
674
  const key = "a";
678
675
  const ttl = null;
679
676
  const owner = "b";
680
- const lock = lockProviderA.create(key, {
677
+ const lock = lockProvider.create(key, {
681
678
  ttl,
682
679
  owner,
683
680
  });
@@ -689,7 +686,7 @@ export function lockProviderTestSuite(settings) {
689
686
  const key = "a";
690
687
  const owner = "b";
691
688
  const ttl = TTL;
692
- const lock = lockProviderA.create(key, {
689
+ const lock = lockProvider.create(key, {
693
690
  ttl,
694
691
  owner,
695
692
  });
@@ -701,7 +698,7 @@ export function lockProviderTestSuite(settings) {
701
698
  const key = "a";
702
699
  const owner = "b";
703
700
  const ttl = TTL;
704
- const lock = lockProviderA.create(key, {
701
+ const lock = lockProvider.create(key, {
705
702
  ttl,
706
703
  owner,
707
704
  });
@@ -716,7 +713,7 @@ export function lockProviderTestSuite(settings) {
716
713
  const key = "a";
717
714
  const ttl = null;
718
715
  const owner = "b";
719
- const lock = lockProviderA.create(key, {
716
+ const lock = lockProvider.create(key, {
720
717
  ttl,
721
718
  owner,
722
719
  });
@@ -728,7 +725,7 @@ export function lockProviderTestSuite(settings) {
728
725
  const key = "a";
729
726
  const owner = "b";
730
727
  const ttl = TTL;
731
- const lock = lockProviderA.create(key, {
728
+ const lock = lockProvider.create(key, {
732
729
  ttl,
733
730
  owner,
734
731
  });
@@ -740,7 +737,7 @@ export function lockProviderTestSuite(settings) {
740
737
  const key = "a";
741
738
  const owner = "b";
742
739
  const ttl = TTL;
743
- const lock = lockProviderA.create(key, {
740
+ const lock = lockProvider.create(key, {
744
741
  ttl,
745
742
  owner,
746
743
  });
@@ -755,7 +752,7 @@ export function lockProviderTestSuite(settings) {
755
752
  const key = "a";
756
753
  const ttl = TTL;
757
754
  const owner = "b";
758
- const lock = lockProviderA.create(key, {
755
+ const lock = lockProvider.create(key, {
759
756
  ttl,
760
757
  owner,
761
758
  });
@@ -768,13 +765,13 @@ export function lockProviderTestSuite(settings) {
768
765
  const key = "a";
769
766
  const ttl = TTL;
770
767
  const owner1 = "b";
771
- const lock1 = lockProviderA.create(key, {
768
+ const lock1 = lockProvider.create(key, {
772
769
  ttl,
773
770
  owner: owner1,
774
771
  });
775
772
  await lock1.acquire();
776
773
  const owner2 = "c";
777
- const lock2 = lockProviderA.create(key, {
774
+ const lock2 = lockProvider.create(key, {
778
775
  ttl,
779
776
  owner: owner2,
780
777
  });
@@ -785,7 +782,7 @@ export function lockProviderTestSuite(settings) {
785
782
  const key = "a";
786
783
  const ttl = TTL;
787
784
  const owner = "b";
788
- const lock = lockProviderA.create(key, {
785
+ const lock = lockProvider.create(key, {
789
786
  ttl,
790
787
  owner,
791
788
  });
@@ -801,7 +798,7 @@ export function lockProviderTestSuite(settings) {
801
798
  const key = "a";
802
799
  const ttl = TTL;
803
800
  const owner = "b";
804
- const lock = lockProviderA.create(key, {
801
+ const lock = lockProvider.create(key, {
805
802
  ttl,
806
803
  owner,
807
804
  });
@@ -814,13 +811,13 @@ export function lockProviderTestSuite(settings) {
814
811
  const key = "a";
815
812
  const ttl = TTL;
816
813
  const owner1 = "b";
817
- const lock1 = lockProviderA.create(key, {
814
+ const lock1 = lockProvider.create(key, {
818
815
  ttl,
819
816
  owner: owner1,
820
817
  });
821
818
  await lock1.acquire();
822
819
  const owner2 = "c";
823
- const lock2 = lockProviderA.create(key, {
820
+ const lock2 = lockProvider.create(key, {
824
821
  ttl,
825
822
  owner: owner2,
826
823
  });
@@ -831,7 +828,7 @@ export function lockProviderTestSuite(settings) {
831
828
  const key = "a";
832
829
  const ttl = TTL;
833
830
  const owner = "b";
834
- const lock = lockProviderA.create(key, {
831
+ const lock = lockProvider.create(key, {
835
832
  ttl,
836
833
  owner,
837
834
  });
@@ -847,7 +844,7 @@ export function lockProviderTestSuite(settings) {
847
844
  const key = "a";
848
845
  const ttl = null;
849
846
  const owner = "b";
850
- const lock = lockProviderA.create(key, {
847
+ const lock = lockProvider.create(key, {
851
848
  ttl,
852
849
  owner,
853
850
  });
@@ -858,7 +855,7 @@ export function lockProviderTestSuite(settings) {
858
855
  const key = "a";
859
856
  const ttl = null;
860
857
  const owner = "b";
861
- const lock = lockProviderA.create(key, {
858
+ const lock = lockProvider.create(key, {
862
859
  ttl,
863
860
  owner,
864
861
  });
@@ -870,7 +867,7 @@ export function lockProviderTestSuite(settings) {
870
867
  const key = "a";
871
868
  const ttl = TTL;
872
869
  const owner = "b";
873
- const lock = lockProviderA.create(key, {
870
+ const lock = lockProvider.create(key, {
874
871
  ttl,
875
872
  owner,
876
873
  });
@@ -883,7 +880,7 @@ export function lockProviderTestSuite(settings) {
883
880
  test("Should return the owner", async () => {
884
881
  const key = "a";
885
882
  const owner = "b";
886
- const lock = lockProviderA.create(key, {
883
+ const lock = lockProvider.create(key, {
887
884
  owner,
888
885
  });
889
886
  const result = await lock.getOwner();
@@ -891,7 +888,7 @@ export function lockProviderTestSuite(settings) {
891
888
  });
892
889
  test("Should return the auto generated owner", async () => {
893
890
  const key = "a";
894
- const lock = lockProviderA.create(key);
891
+ const lock = lockProvider.create(key);
895
892
  const result = await lock.getOwner();
896
893
  expect(result).toBeDefined();
897
894
  expect(typeof result).toBe("string");
@@ -904,12 +901,12 @@ export function lockProviderTestSuite(settings) {
904
901
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
905
902
  const key = "a";
906
903
  const owner = "b";
907
- const lock = lockProviderA.create(key, {
904
+ const lock = lockProvider.create(key, {
908
905
  owner,
909
906
  ttl: TTL,
910
907
  });
911
908
  let event_ = null;
912
- const unsubscribe = await lock.subscribe(KeyAcquiredLockEvent, (event) => {
909
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
913
910
  event_ = event;
914
911
  });
915
912
  await lock.run(async () => {
@@ -924,12 +921,12 @@ export function lockProviderTestSuite(settings) {
924
921
  test("Should dispatch KeyReleasedLockEvent when lock is not acquired", async () => {
925
922
  const key = "a";
926
923
  const owner = "b";
927
- const lock = lockProviderA.create(key, {
924
+ const lock = lockProvider.create(key, {
928
925
  owner,
929
926
  ttl: TTL,
930
927
  });
931
928
  let event_ = null;
932
- const unsubscribe = await lock.subscribe(KeyReleasedLockEvent, (event) => {
929
+ const unsubscribe = await lockProvider.subscribe(KeyReleasedLockEvent, (event) => {
933
930
  event_ = event;
934
931
  });
935
932
  await lock.run(async () => {
@@ -943,12 +940,12 @@ export function lockProviderTestSuite(settings) {
943
940
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
944
941
  const key = "a";
945
942
  const owner = "b";
946
- const lock = lockProviderA.create(key, {
943
+ const lock = lockProvider.create(key, {
947
944
  owner,
948
945
  });
949
946
  let event_ = null;
950
947
  await lock.acquire();
951
- const unsubscribe = await lock.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
948
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
952
949
  event_ = event;
953
950
  });
954
951
  await lock.run(async () => {
@@ -964,12 +961,12 @@ export function lockProviderTestSuite(settings) {
964
961
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
965
962
  const key = "a";
966
963
  const owner = "b";
967
- const lock = lockProviderA.create(key, {
964
+ const lock = lockProvider.create(key, {
968
965
  owner,
969
966
  ttl: TTL,
970
967
  });
971
968
  let event_ = null;
972
- const unsubscribe = await lock.subscribe(KeyAcquiredLockEvent, (event) => {
969
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
973
970
  event_ = event;
974
971
  });
975
972
  await lock.runBlocking(async () => {
@@ -987,12 +984,12 @@ export function lockProviderTestSuite(settings) {
987
984
  test("Should dispatch KeyReleasedLockEvent when lock is not acquired", async () => {
988
985
  const key = "a";
989
986
  const owner = "b";
990
- const lock = lockProviderA.create(key, {
987
+ const lock = lockProvider.create(key, {
991
988
  owner,
992
989
  ttl: TTL,
993
990
  });
994
991
  let event_ = null;
995
- const unsubscribe = await lock.subscribe(KeyReleasedLockEvent, (event) => {
992
+ const unsubscribe = await lockProvider.subscribe(KeyReleasedLockEvent, (event) => {
996
993
  event_ = event;
997
994
  });
998
995
  await lock.runBlocking(async () => {
@@ -1009,12 +1006,12 @@ export function lockProviderTestSuite(settings) {
1009
1006
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1010
1007
  const key = "a";
1011
1008
  const owner = "b";
1012
- const lock = lockProviderA.create(key, {
1009
+ const lock = lockProvider.create(key, {
1013
1010
  owner,
1014
1011
  });
1015
1012
  let event_ = null;
1016
1013
  await lock.acquire();
1017
- const unsubscribe = await lock.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1014
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1018
1015
  event_ = event;
1019
1016
  });
1020
1017
  await lock.runBlocking(async () => {
@@ -1033,12 +1030,12 @@ export function lockProviderTestSuite(settings) {
1033
1030
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
1034
1031
  const key = "a";
1035
1032
  const owner = "b";
1036
- const lock = lockProviderA.create(key, {
1033
+ const lock = lockProvider.create(key, {
1037
1034
  owner,
1038
1035
  ttl: TTL,
1039
1036
  });
1040
1037
  let event_ = null;
1041
- const unsubscribe = await lock.subscribe(KeyAcquiredLockEvent, (event) => {
1038
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
1042
1039
  event_ = event;
1043
1040
  });
1044
1041
  await lock.runOrFail(async () => {
@@ -1053,12 +1050,12 @@ export function lockProviderTestSuite(settings) {
1053
1050
  test("Should dispatch KeyReleasedLockEvent when lock is not acquired", async () => {
1054
1051
  const key = "a";
1055
1052
  const owner = "b";
1056
- const lock = lockProviderA.create(key, {
1053
+ const lock = lockProvider.create(key, {
1057
1054
  owner,
1058
1055
  ttl: TTL,
1059
1056
  });
1060
1057
  let event_ = null;
1061
- const unsubscribe = await lock.subscribe(KeyReleasedLockEvent, (event) => {
1058
+ const unsubscribe = await lockProvider.subscribe(KeyReleasedLockEvent, (event) => {
1062
1059
  event_ = event;
1063
1060
  });
1064
1061
  await lock.runOrFail(async () => {
@@ -1072,12 +1069,12 @@ export function lockProviderTestSuite(settings) {
1072
1069
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1073
1070
  const key = "a";
1074
1071
  const owner = "b";
1075
- const lock = lockProviderA.create(key, {
1072
+ const lock = lockProvider.create(key, {
1076
1073
  owner,
1077
1074
  });
1078
1075
  let event_ = null;
1079
1076
  await lock.acquire();
1080
- const unsubscribe = await lock.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1077
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1081
1078
  event_ = event;
1082
1079
  });
1083
1080
  try {
@@ -1098,12 +1095,12 @@ export function lockProviderTestSuite(settings) {
1098
1095
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
1099
1096
  const key = "a";
1100
1097
  const owner = "b";
1101
- const lock = lockProviderA.create(key, {
1098
+ const lock = lockProvider.create(key, {
1102
1099
  owner,
1103
1100
  ttl: TTL,
1104
1101
  });
1105
1102
  let event_ = null;
1106
- const unsubscribe = await lock.subscribe(KeyAcquiredLockEvent, (event) => {
1103
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
1107
1104
  event_ = event;
1108
1105
  });
1109
1106
  await lock.acquire();
@@ -1116,12 +1113,12 @@ export function lockProviderTestSuite(settings) {
1116
1113
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1117
1114
  const key = "a";
1118
1115
  const owner = "b";
1119
- const lock = lockProviderA.create(key, {
1116
+ const lock = lockProvider.create(key, {
1120
1117
  owner,
1121
1118
  });
1122
1119
  let event_ = null;
1123
1120
  await lock.acquire();
1124
- const unsubscribe = await lock.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1121
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1125
1122
  event_ = event;
1126
1123
  });
1127
1124
  await lock.acquire();
@@ -1135,12 +1132,12 @@ export function lockProviderTestSuite(settings) {
1135
1132
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
1136
1133
  const key = "a";
1137
1134
  const owner = "b";
1138
- const lock = lockProviderA.create(key, {
1135
+ const lock = lockProvider.create(key, {
1139
1136
  owner,
1140
1137
  ttl: TTL,
1141
1138
  });
1142
1139
  let event_ = null;
1143
- const unsubscribe = await lock.subscribe(KeyAcquiredLockEvent, (event) => {
1140
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
1144
1141
  event_ = event;
1145
1142
  });
1146
1143
  await lock.acquireBlocking({
@@ -1156,7 +1153,7 @@ export function lockProviderTestSuite(settings) {
1156
1153
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1157
1154
  const key = "a";
1158
1155
  const owner = "b";
1159
- const lock = lockProviderA.create(key, {
1156
+ const lock = lockProvider.create(key, {
1160
1157
  owner,
1161
1158
  });
1162
1159
  let event_ = null;
@@ -1164,7 +1161,7 @@ export function lockProviderTestSuite(settings) {
1164
1161
  time: TimeSpan.fromMilliseconds(5),
1165
1162
  interval: TimeSpan.fromMilliseconds(5),
1166
1163
  });
1167
- const unsubscribe = await lock.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1164
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1168
1165
  event_ = event;
1169
1166
  });
1170
1167
  await lock.acquireBlocking({
@@ -1181,12 +1178,12 @@ export function lockProviderTestSuite(settings) {
1181
1178
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
1182
1179
  const key = "a";
1183
1180
  const owner = "b";
1184
- const lock = lockProviderA.create(key, {
1181
+ const lock = lockProvider.create(key, {
1185
1182
  owner,
1186
1183
  ttl: TTL,
1187
1184
  });
1188
1185
  let event_ = null;
1189
- const unsubscribe = await lock.subscribe(KeyAcquiredLockEvent, (event) => {
1186
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
1190
1187
  event_ = event;
1191
1188
  });
1192
1189
  await lock.acquireOrFail();
@@ -1199,12 +1196,12 @@ export function lockProviderTestSuite(settings) {
1199
1196
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1200
1197
  const key = "a";
1201
1198
  const owner = "b";
1202
- const lock = lockProviderA.create(key, {
1199
+ const lock = lockProvider.create(key, {
1203
1200
  owner,
1204
1201
  });
1205
1202
  let event_ = null;
1206
1203
  await lock.acquireOrFail();
1207
- const unsubscribe = await lock.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1204
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1208
1205
  event_ = event;
1209
1206
  });
1210
1207
  try {
@@ -1223,12 +1220,12 @@ export function lockProviderTestSuite(settings) {
1223
1220
  test("Should dispatch KeyReleasedLockEvent when released by same owner", async () => {
1224
1221
  const key = "a";
1225
1222
  const owner = "b";
1226
- const lock = lockProviderA.create(key, {
1223
+ const lock = lockProvider.create(key, {
1227
1224
  owner,
1228
1225
  });
1229
1226
  await lock.acquire();
1230
1227
  let event_ = null;
1231
- const unsubscribe = await lock.subscribe(KeyReleasedLockEvent, (event) => {
1228
+ const unsubscribe = await lockProvider.subscribe(KeyReleasedLockEvent, (event) => {
1232
1229
  event_ = event;
1233
1230
  });
1234
1231
  await lock.release();
@@ -1240,16 +1237,16 @@ export function lockProviderTestSuite(settings) {
1240
1237
  test("Should dispatch UnownedReleaseLockEvent when released by same owner", async () => {
1241
1238
  const key = "a";
1242
1239
  const owner1 = "b";
1243
- const lock1 = lockProviderA.create(key, {
1240
+ const lock1 = lockProvider.create(key, {
1244
1241
  owner: owner1,
1245
1242
  });
1246
1243
  await lock1.acquire();
1247
1244
  const owner2 = "c";
1248
- const lock2 = lockProviderA.create(key, {
1245
+ const lock2 = lockProvider.create(key, {
1249
1246
  owner: owner2,
1250
1247
  });
1251
1248
  let event_ = null;
1252
- const unsubscribe = await lock1.subscribe(UnownedReleaseLockEvent, (event) => {
1249
+ const unsubscribe = await lockProvider.subscribe(UnownedReleaseLockEvent, (event) => {
1253
1250
  event_ = event;
1254
1251
  });
1255
1252
  await lock2.release();
@@ -1263,12 +1260,12 @@ export function lockProviderTestSuite(settings) {
1263
1260
  test("Should dispatch KeyReleasedLockEvent when released by same owner", async () => {
1264
1261
  const key = "a";
1265
1262
  const owner = "b";
1266
- const lock = lockProviderA.create(key, {
1263
+ const lock = lockProvider.create(key, {
1267
1264
  owner,
1268
1265
  });
1269
1266
  await lock.acquire();
1270
1267
  let event_ = null;
1271
- const unsubscribe = await lock.subscribe(KeyReleasedLockEvent, (event) => {
1268
+ const unsubscribe = await lockProvider.subscribe(KeyReleasedLockEvent, (event) => {
1272
1269
  event_ = event;
1273
1270
  });
1274
1271
  await lock.releaseOrFail();
@@ -1280,16 +1277,16 @@ export function lockProviderTestSuite(settings) {
1280
1277
  test("Should dispatch UnownedReleaseLockEvent when released by same owner", async () => {
1281
1278
  const key = "a";
1282
1279
  const owner1 = "b";
1283
- const lock1 = lockProviderA.create(key, {
1280
+ const lock1 = lockProvider.create(key, {
1284
1281
  owner: owner1,
1285
1282
  });
1286
1283
  await lock1.acquire();
1287
1284
  const owner2 = "c";
1288
- const lock2 = lockProviderA.create(key, {
1285
+ const lock2 = lockProvider.create(key, {
1289
1286
  owner: owner2,
1290
1287
  });
1291
1288
  let event_ = null;
1292
- const unsubscribe = await lock1.subscribe(UnownedReleaseLockEvent, (event) => {
1289
+ const unsubscribe = await lockProvider.subscribe(UnownedReleaseLockEvent, (event) => {
1293
1290
  event_ = event;
1294
1291
  });
1295
1292
  try {
@@ -1308,16 +1305,16 @@ export function lockProviderTestSuite(settings) {
1308
1305
  test("Should dispatch KeyForceReleasedLockEvent when lock forcefully released", async () => {
1309
1306
  const key = "a";
1310
1307
  const owner1 = "b";
1311
- const lock1 = lockProviderA.create(key, {
1308
+ const lock1 = lockProvider.create(key, {
1312
1309
  owner: owner1,
1313
1310
  });
1314
1311
  await lock1.acquire();
1315
1312
  const owner2 = "c";
1316
- const lock2 = lockProviderA.create(key, {
1313
+ const lock2 = lockProvider.create(key, {
1317
1314
  owner: owner2,
1318
1315
  });
1319
1316
  let event_ = null;
1320
- const unsubscribe = await lock1.subscribe(KeyForceReleasedLockEvent, (event) => {
1317
+ const unsubscribe = await lockProvider.subscribe(KeyForceReleasedLockEvent, (event) => {
1321
1318
  event_ = event;
1322
1319
  });
1323
1320
  await lock2.forceRelease();
@@ -1330,13 +1327,13 @@ export function lockProviderTestSuite(settings) {
1330
1327
  test("Should dispatch KeyRefreshedLockEvent when refreshed by same owner", async () => {
1331
1328
  const key = "a";
1332
1329
  const owner = "b";
1333
- const lock = lockProviderA.create(key, {
1330
+ const lock = lockProvider.create(key, {
1334
1331
  owner,
1335
1332
  ttl: TTL,
1336
1333
  });
1337
1334
  await lock.acquire();
1338
1335
  let event_ = null;
1339
- const unsubscribe = await lock.subscribe(KeyRefreshedLockEvent, (event) => {
1336
+ const unsubscribe = await lockProvider.subscribe(KeyRefreshedLockEvent, (event) => {
1340
1337
  event_ = event;
1341
1338
  });
1342
1339
  await LazyPromise.delay(TTL.divide(2));
@@ -1351,17 +1348,17 @@ export function lockProviderTestSuite(settings) {
1351
1348
  test("Should dispatch UnownedRefreshLockEvent when refreshed by different owner", async () => {
1352
1349
  const key = "a";
1353
1350
  const owner1 = "b";
1354
- const lock1 = lockProviderA.create(key, {
1351
+ const lock1 = lockProvider.create(key, {
1355
1352
  owner: owner1,
1356
1353
  ttl: TTL,
1357
1354
  });
1358
1355
  await lock1.acquire();
1359
1356
  const owner2 = "c";
1360
- const lock2 = lockProviderA.create(key, {
1357
+ const lock2 = lockProvider.create(key, {
1361
1358
  owner: owner2,
1362
1359
  });
1363
1360
  let event_ = null;
1364
- const unsubscribe = await lock1.subscribe(UnownedRefreshLockEvent, (event) => {
1361
+ const unsubscribe = await lockProvider.subscribe(UnownedRefreshLockEvent, (event) => {
1365
1362
  event_ = event;
1366
1363
  });
1367
1364
  await LazyPromise.delay(TTL.divide(2));
@@ -1377,13 +1374,13 @@ export function lockProviderTestSuite(settings) {
1377
1374
  test("Should dispatch KeyRefreshedLockEvent when refreshed by same owner", async () => {
1378
1375
  const key = "a";
1379
1376
  const owner = "b";
1380
- const lock = lockProviderA.create(key, {
1377
+ const lock = lockProvider.create(key, {
1381
1378
  owner,
1382
1379
  ttl: TTL,
1383
1380
  });
1384
1381
  await lock.acquire();
1385
1382
  let event_ = null;
1386
- const unsubscribe = await lock.subscribe(KeyRefreshedLockEvent, (event) => {
1383
+ const unsubscribe = await lockProvider.subscribe(KeyRefreshedLockEvent, (event) => {
1387
1384
  event_ = event;
1388
1385
  });
1389
1386
  await LazyPromise.delay(TTL.divide(2));
@@ -1398,17 +1395,17 @@ export function lockProviderTestSuite(settings) {
1398
1395
  test("Should dispatch UnownedRefreshLockEvent when refreshed by different owner", async () => {
1399
1396
  const key = "a";
1400
1397
  const owner1 = "b";
1401
- const lock1 = lockProviderA.create(key, {
1398
+ const lock1 = lockProvider.create(key, {
1402
1399
  owner: owner1,
1403
1400
  ttl: TTL,
1404
1401
  });
1405
1402
  await lock1.acquire();
1406
1403
  const owner2 = "c";
1407
- const lock2 = lockProviderA.create(key, {
1404
+ const lock2 = lockProvider.create(key, {
1408
1405
  owner: owner2,
1409
1406
  });
1410
1407
  let event_ = null;
1411
- const unsubscribe = await lock1.subscribe(UnownedRefreshLockEvent, (event) => {
1408
+ const unsubscribe = await lockProvider.subscribe(UnownedRefreshLockEvent, (event) => {
1412
1409
  event_ = event;
1413
1410
  });
1414
1411
  await LazyPromise.delay(TTL.divide(2));
@@ -1431,12 +1428,12 @@ export function lockProviderTestSuite(settings) {
1431
1428
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
1432
1429
  const key = "a";
1433
1430
  const owner = "b";
1434
- const lock = lockProviderA.create(key, {
1431
+ const lock = lockProvider.create(key, {
1435
1432
  owner,
1436
1433
  ttl: TTL,
1437
1434
  });
1438
1435
  let event_ = null;
1439
- const unsubscribe = await lockProviderA.subscribe(KeyAcquiredLockEvent, (event) => {
1436
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
1440
1437
  event_ = event;
1441
1438
  });
1442
1439
  await lock.run(async () => {
@@ -1451,12 +1448,12 @@ export function lockProviderTestSuite(settings) {
1451
1448
  test("Should dispatch KeyReleasedLockEvent when lock is not acquired", async () => {
1452
1449
  const key = "a";
1453
1450
  const owner = "b";
1454
- const lock = lockProviderA.create(key, {
1451
+ const lock = lockProvider.create(key, {
1455
1452
  owner,
1456
1453
  ttl: TTL,
1457
1454
  });
1458
1455
  let event_ = null;
1459
- const unsubscribe = await lockProviderA.subscribe(KeyReleasedLockEvent, (event) => {
1456
+ const unsubscribe = await lockProvider.subscribe(KeyReleasedLockEvent, (event) => {
1460
1457
  event_ = event;
1461
1458
  });
1462
1459
  await lock.run(async () => {
@@ -1470,12 +1467,12 @@ export function lockProviderTestSuite(settings) {
1470
1467
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1471
1468
  const key = "a";
1472
1469
  const owner = "b";
1473
- const lock = lockProviderA.create(key, {
1470
+ const lock = lockProvider.create(key, {
1474
1471
  owner,
1475
1472
  });
1476
1473
  let event_ = null;
1477
1474
  await lock.acquire();
1478
- const unsubscribe = await lockProviderA.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1475
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1479
1476
  event_ = event;
1480
1477
  });
1481
1478
  await lock.run(async () => {
@@ -1491,12 +1488,12 @@ export function lockProviderTestSuite(settings) {
1491
1488
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
1492
1489
  const key = "a";
1493
1490
  const owner = "b";
1494
- const lock = lockProviderA.create(key, {
1491
+ const lock = lockProvider.create(key, {
1495
1492
  owner,
1496
1493
  ttl: TTL,
1497
1494
  });
1498
1495
  let event_ = null;
1499
- const unsubscribe = await lockProviderA.subscribe(KeyAcquiredLockEvent, (event) => {
1496
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
1500
1497
  event_ = event;
1501
1498
  });
1502
1499
  await lock.runBlocking(async () => {
@@ -1514,12 +1511,12 @@ export function lockProviderTestSuite(settings) {
1514
1511
  test("Should dispatch KeyReleasedLockEvent when lock is not acquired", async () => {
1515
1512
  const key = "a";
1516
1513
  const owner = "b";
1517
- const lock = lockProviderA.create(key, {
1514
+ const lock = lockProvider.create(key, {
1518
1515
  owner,
1519
1516
  ttl: TTL,
1520
1517
  });
1521
1518
  let event_ = null;
1522
- const unsubscribe = await lockProviderA.subscribe(KeyReleasedLockEvent, (event) => {
1519
+ const unsubscribe = await lockProvider.subscribe(KeyReleasedLockEvent, (event) => {
1523
1520
  event_ = event;
1524
1521
  });
1525
1522
  await lock.runBlocking(async () => {
@@ -1536,12 +1533,12 @@ export function lockProviderTestSuite(settings) {
1536
1533
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1537
1534
  const key = "a";
1538
1535
  const owner = "b";
1539
- const lock = lockProviderA.create(key, {
1536
+ const lock = lockProvider.create(key, {
1540
1537
  owner,
1541
1538
  });
1542
1539
  let event_ = null;
1543
1540
  await lock.acquire();
1544
- const unsubscribe = await lockProviderA.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1541
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1545
1542
  event_ = event;
1546
1543
  });
1547
1544
  await lock.runBlocking(async () => {
@@ -1560,12 +1557,12 @@ export function lockProviderTestSuite(settings) {
1560
1557
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
1561
1558
  const key = "a";
1562
1559
  const owner = "b";
1563
- const lock = lockProviderA.create(key, {
1560
+ const lock = lockProvider.create(key, {
1564
1561
  owner,
1565
1562
  ttl: TTL,
1566
1563
  });
1567
1564
  let event_ = null;
1568
- const unsubscribe = await lockProviderA.subscribe(KeyAcquiredLockEvent, (event) => {
1565
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
1569
1566
  event_ = event;
1570
1567
  });
1571
1568
  await lock.runOrFail(async () => {
@@ -1580,12 +1577,12 @@ export function lockProviderTestSuite(settings) {
1580
1577
  test("Should dispatch KeyReleasedLockEvent when lock is not acquired", async () => {
1581
1578
  const key = "a";
1582
1579
  const owner = "b";
1583
- const lock = lockProviderA.create(key, {
1580
+ const lock = lockProvider.create(key, {
1584
1581
  owner,
1585
1582
  ttl: TTL,
1586
1583
  });
1587
1584
  let event_ = null;
1588
- const unsubscribe = await lockProviderA.subscribe(KeyReleasedLockEvent, (event) => {
1585
+ const unsubscribe = await lockProvider.subscribe(KeyReleasedLockEvent, (event) => {
1589
1586
  event_ = event;
1590
1587
  });
1591
1588
  await lock.runOrFail(async () => {
@@ -1599,12 +1596,12 @@ export function lockProviderTestSuite(settings) {
1599
1596
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1600
1597
  const key = "a";
1601
1598
  const owner = "b";
1602
- const lock = lockProviderA.create(key, {
1599
+ const lock = lockProvider.create(key, {
1603
1600
  owner,
1604
1601
  });
1605
1602
  let event_ = null;
1606
1603
  await lock.acquire();
1607
- const unsubscribe = await lockProviderA.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1604
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1608
1605
  event_ = event;
1609
1606
  });
1610
1607
  try {
@@ -1625,12 +1622,12 @@ export function lockProviderTestSuite(settings) {
1625
1622
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
1626
1623
  const key = "a";
1627
1624
  const owner = "b";
1628
- const lock = lockProviderA.create(key, {
1625
+ const lock = lockProvider.create(key, {
1629
1626
  owner,
1630
1627
  ttl: TTL,
1631
1628
  });
1632
1629
  let event_ = null;
1633
- const unsubscribe = await lockProviderA.subscribe(KeyAcquiredLockEvent, (event) => {
1630
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
1634
1631
  event_ = event;
1635
1632
  });
1636
1633
  await lock.acquire();
@@ -1643,12 +1640,12 @@ export function lockProviderTestSuite(settings) {
1643
1640
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1644
1641
  const key = "a";
1645
1642
  const owner = "b";
1646
- const lock = lockProviderA.create(key, {
1643
+ const lock = lockProvider.create(key, {
1647
1644
  owner,
1648
1645
  });
1649
1646
  let event_ = null;
1650
1647
  await lock.acquire();
1651
- const unsubscribe = await lockProviderA.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1648
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1652
1649
  event_ = event;
1653
1650
  });
1654
1651
  await lock.acquire();
@@ -1662,12 +1659,12 @@ export function lockProviderTestSuite(settings) {
1662
1659
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
1663
1660
  const key = "a";
1664
1661
  const owner = "b";
1665
- const lock = lockProviderA.create(key, {
1662
+ const lock = lockProvider.create(key, {
1666
1663
  owner,
1667
1664
  ttl: TTL,
1668
1665
  });
1669
1666
  let event_ = null;
1670
- const unsubscribe = await lockProviderA.subscribe(KeyAcquiredLockEvent, (event) => {
1667
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
1671
1668
  event_ = event;
1672
1669
  });
1673
1670
  await lock.acquire();
@@ -1680,12 +1677,12 @@ export function lockProviderTestSuite(settings) {
1680
1677
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1681
1678
  const key = "a";
1682
1679
  const owner = "b";
1683
- const lock = lockProviderA.create(key, {
1680
+ const lock = lockProvider.create(key, {
1684
1681
  owner,
1685
1682
  });
1686
1683
  let event_ = null;
1687
1684
  await lock.acquire();
1688
- const unsubscribe = await lockProviderA.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1685
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1689
1686
  event_ = event;
1690
1687
  });
1691
1688
  await lock.acquire();
@@ -1699,12 +1696,12 @@ export function lockProviderTestSuite(settings) {
1699
1696
  test("Should dispatch KeyAcquiredLockEvent when lock is not acquired", async () => {
1700
1697
  const key = "a";
1701
1698
  const owner = "b";
1702
- const lock = lockProviderA.create(key, {
1699
+ const lock = lockProvider.create(key, {
1703
1700
  owner,
1704
1701
  ttl: TTL,
1705
1702
  });
1706
1703
  let event_ = null;
1707
- const unsubscribe = await lockProviderA.subscribe(KeyAcquiredLockEvent, (event) => {
1704
+ const unsubscribe = await lockProvider.subscribe(KeyAcquiredLockEvent, (event) => {
1708
1705
  event_ = event;
1709
1706
  });
1710
1707
  await lock.acquireOrFail();
@@ -1717,12 +1714,12 @@ export function lockProviderTestSuite(settings) {
1717
1714
  test("Should dispatch KeyAlreadyAcquiredLockEvent when lock is acquired", async () => {
1718
1715
  const key = "a";
1719
1716
  const owner = "b";
1720
- const lock = lockProviderA.create(key, {
1717
+ const lock = lockProvider.create(key, {
1721
1718
  owner,
1722
1719
  });
1723
1720
  let event_ = null;
1724
1721
  await lock.acquireOrFail();
1725
- const unsubscribe = await lockProviderA.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1722
+ const unsubscribe = await lockProvider.subscribe(KeyAlreadyAcquiredLockEvent, (event) => {
1726
1723
  event_ = event;
1727
1724
  });
1728
1725
  try {
@@ -1741,12 +1738,12 @@ export function lockProviderTestSuite(settings) {
1741
1738
  test("Should dispatch KeyReleasedLockEvent when released by same owner", async () => {
1742
1739
  const key = "a";
1743
1740
  const owner = "b";
1744
- const lock = lockProviderA.create(key, {
1741
+ const lock = lockProvider.create(key, {
1745
1742
  owner,
1746
1743
  });
1747
1744
  await lock.acquire();
1748
1745
  let event_ = null;
1749
- const unsubscribe = await lockProviderA.subscribe(KeyReleasedLockEvent, (event) => {
1746
+ const unsubscribe = await lockProvider.subscribe(KeyReleasedLockEvent, (event) => {
1750
1747
  event_ = event;
1751
1748
  });
1752
1749
  await lock.release();
@@ -1758,16 +1755,16 @@ export function lockProviderTestSuite(settings) {
1758
1755
  test("Should dispatch UnownedReleaseLockEvent when released by same owner", async () => {
1759
1756
  const key = "a";
1760
1757
  const owner1 = "b";
1761
- const lock1 = lockProviderA.create(key, {
1758
+ const lock1 = lockProvider.create(key, {
1762
1759
  owner: owner1,
1763
1760
  });
1764
1761
  await lock1.acquire();
1765
1762
  const owner2 = "c";
1766
- const lock2 = lockProviderA.create(key, {
1763
+ const lock2 = lockProvider.create(key, {
1767
1764
  owner: owner2,
1768
1765
  });
1769
1766
  let event_ = null;
1770
- const unsubscribe = await lock1.subscribe(UnownedReleaseLockEvent, (event) => {
1767
+ const unsubscribe = await lockProvider.subscribe(UnownedReleaseLockEvent, (event) => {
1771
1768
  event_ = event;
1772
1769
  });
1773
1770
  await lock2.release();
@@ -1781,12 +1778,12 @@ export function lockProviderTestSuite(settings) {
1781
1778
  test("Should dispatch KeyReleasedLockEvent when released by same owner", async () => {
1782
1779
  const key = "a";
1783
1780
  const owner = "b";
1784
- const lock = lockProviderA.create(key, {
1781
+ const lock = lockProvider.create(key, {
1785
1782
  owner,
1786
1783
  });
1787
1784
  await lock.acquire();
1788
1785
  let event_ = null;
1789
- const unsubscribe = await lockProviderA.subscribe(KeyReleasedLockEvent, (event) => {
1786
+ const unsubscribe = await lockProvider.subscribe(KeyReleasedLockEvent, (event) => {
1790
1787
  event_ = event;
1791
1788
  });
1792
1789
  await lock.releaseOrFail();
@@ -1798,16 +1795,16 @@ export function lockProviderTestSuite(settings) {
1798
1795
  test("Should dispatch UnownedReleaseLockEvent when released by same owner", async () => {
1799
1796
  const key = "a";
1800
1797
  const owner1 = "b";
1801
- const lock1 = lockProviderA.create(key, {
1798
+ const lock1 = lockProvider.create(key, {
1802
1799
  owner: owner1,
1803
1800
  });
1804
1801
  await lock1.acquire();
1805
1802
  const owner2 = "c";
1806
- const lock2 = lockProviderA.create(key, {
1803
+ const lock2 = lockProvider.create(key, {
1807
1804
  owner: owner2,
1808
1805
  });
1809
1806
  let event_ = null;
1810
- const unsubscribe = await lock1.subscribe(UnownedReleaseLockEvent, (event) => {
1807
+ const unsubscribe = await lockProvider.subscribe(UnownedReleaseLockEvent, (event) => {
1811
1808
  event_ = event;
1812
1809
  });
1813
1810
  try {
@@ -1826,16 +1823,16 @@ export function lockProviderTestSuite(settings) {
1826
1823
  test("Should dispatch KeyForceReleasedLockEvent when lock forcefully released", async () => {
1827
1824
  const key = "a";
1828
1825
  const owner1 = "b";
1829
- const lock1 = lockProviderA.create(key, {
1826
+ const lock1 = lockProvider.create(key, {
1830
1827
  owner: owner1,
1831
1828
  });
1832
1829
  await lock1.acquire();
1833
1830
  const owner2 = "c";
1834
- const lock2 = lockProviderA.create(key, {
1831
+ const lock2 = lockProvider.create(key, {
1835
1832
  owner: owner2,
1836
1833
  });
1837
1834
  let event_ = null;
1838
- const unsubscribe = await lock1.subscribe(KeyForceReleasedLockEvent, (event) => {
1835
+ const unsubscribe = await lockProvider.subscribe(KeyForceReleasedLockEvent, (event) => {
1839
1836
  event_ = event;
1840
1837
  });
1841
1838
  await lock2.forceRelease();
@@ -1848,13 +1845,13 @@ export function lockProviderTestSuite(settings) {
1848
1845
  test("Should dispatch KeyRefreshedLockEvent when refreshed by same owner", async () => {
1849
1846
  const key = "a";
1850
1847
  const owner = "b";
1851
- const lock = lockProviderA.create(key, {
1848
+ const lock = lockProvider.create(key, {
1852
1849
  owner,
1853
1850
  ttl: TTL,
1854
1851
  });
1855
1852
  await lock.acquire();
1856
1853
  let event_ = null;
1857
- const unsubscribe = await lockProviderA.subscribe(KeyRefreshedLockEvent, (event) => {
1854
+ const unsubscribe = await lockProvider.subscribe(KeyRefreshedLockEvent, (event) => {
1858
1855
  event_ = event;
1859
1856
  });
1860
1857
  await LazyPromise.delay(TTL.divide(2));
@@ -1869,17 +1866,17 @@ export function lockProviderTestSuite(settings) {
1869
1866
  test("Should dispatch UnownedRefreshLockEvent when refreshed by different owner", async () => {
1870
1867
  const key = "a";
1871
1868
  const owner1 = "b";
1872
- const lock1 = lockProviderA.create(key, {
1869
+ const lock1 = lockProvider.create(key, {
1873
1870
  owner: owner1,
1874
1871
  ttl: TTL,
1875
1872
  });
1876
1873
  await lock1.acquire();
1877
1874
  const owner2 = "c";
1878
- const lock2 = lockProviderA.create(key, {
1875
+ const lock2 = lockProvider.create(key, {
1879
1876
  owner: owner2,
1880
1877
  });
1881
1878
  let event_ = null;
1882
- const unsubscribe = await lock1.subscribe(UnownedRefreshLockEvent, (event) => {
1879
+ const unsubscribe = await lockProvider.subscribe(UnownedRefreshLockEvent, (event) => {
1883
1880
  event_ = event;
1884
1881
  });
1885
1882
  await LazyPromise.delay(TTL.divide(2));
@@ -1895,13 +1892,13 @@ export function lockProviderTestSuite(settings) {
1895
1892
  test("Should dispatch KeyRefreshedLockEvent when refreshed by same owner", async () => {
1896
1893
  const key = "a";
1897
1894
  const owner = "b";
1898
- const lock = lockProviderA.create(key, {
1895
+ const lock = lockProvider.create(key, {
1899
1896
  owner,
1900
1897
  ttl: TTL,
1901
1898
  });
1902
1899
  await lock.acquire();
1903
1900
  let event_ = null;
1904
- const unsubscribe = await lockProviderA.subscribe(KeyRefreshedLockEvent, (event) => {
1901
+ const unsubscribe = await lockProvider.subscribe(KeyRefreshedLockEvent, (event) => {
1905
1902
  event_ = event;
1906
1903
  });
1907
1904
  await LazyPromise.delay(TTL.divide(2));
@@ -1916,17 +1913,17 @@ export function lockProviderTestSuite(settings) {
1916
1913
  test("Should dispatch UnownedRefreshLockEvent when refreshed by different owner", async () => {
1917
1914
  const key = "a";
1918
1915
  const owner1 = "b";
1919
- const lock1 = lockProviderA.create(key, {
1916
+ const lock1 = lockProvider.create(key, {
1920
1917
  owner: owner1,
1921
1918
  ttl: TTL,
1922
1919
  });
1923
1920
  await lock1.acquire();
1924
1921
  const owner2 = "c";
1925
- const lock2 = lockProviderA.create(key, {
1922
+ const lock2 = lockProvider.create(key, {
1926
1923
  owner: owner2,
1927
1924
  });
1928
1925
  let event_ = null;
1929
- const unsubscribe = await lock1.subscribe(UnownedRefreshLockEvent, (event) => {
1926
+ const unsubscribe = await lockProvider.subscribe(UnownedRefreshLockEvent, (event) => {
1930
1927
  event_ = event;
1931
1928
  });
1932
1929
  await LazyPromise.delay(TTL.divide(2));
@@ -1945,489 +1942,11 @@ export function lockProviderTestSuite(settings) {
1945
1942
  });
1946
1943
  });
1947
1944
  });
1948
- describe("Group tests:", () => {
1949
- test("method: run", async () => {
1950
- const key = "a";
1951
- const ownerA = "b";
1952
- const lockA = lockProviderA.create(key, {
1953
- owner: ownerA,
1954
- });
1955
- const promiseA = lockA.run(async () => {
1956
- await LazyPromise.delay(DELAY_TIME);
1957
- return "a";
1958
- });
1959
- const ownerB = "c";
1960
- const lockB = lockProviderB.create(key, {
1961
- owner: ownerB,
1962
- });
1963
- const promiseB = lockB.run(async () => {
1964
- await LazyPromise.delay(DELAY_TIME);
1965
- return "a";
1966
- });
1967
- const [[resultA, errorA], [resultB, errorB]] = await Promise.all([
1968
- promiseA,
1969
- promiseB,
1970
- ]);
1971
- expect(resultA).toBe("a");
1972
- expect(errorA).toBeNull();
1973
- expect(resultB).toBe("a");
1974
- expect(errorB).toBeNull();
1975
- });
1976
- test("method: runBlocking", async () => {
1977
- const key = "a";
1978
- const ownerA = "b";
1979
- const lockA = lockProviderA.create(key, {
1980
- owner: ownerA,
1981
- });
1982
- const promiseA = lockA.run(async () => {
1983
- await LazyPromise.delay(DELAY_TIME);
1984
- return "a";
1985
- });
1986
- const ownerB = "c";
1987
- const lockB = lockProviderB.create(key, {
1988
- owner: ownerB,
1989
- });
1990
- const promiseB = lockB.runBlocking(async () => {
1991
- await LazyPromise.delay(DELAY_TIME);
1992
- return "a";
1993
- }, {
1994
- time: TimeSpan.fromMilliseconds(5),
1995
- interval: TimeSpan.fromMilliseconds(5),
1996
- });
1997
- const [[resultA, errorA], [resultB, errorB]] = await Promise.all([
1998
- promiseA,
1999
- promiseB,
2000
- ]);
2001
- expect(resultA).toBe("a");
2002
- expect(errorA).toBeNull();
2003
- expect(resultB).toBe("a");
2004
- expect(errorB).toBeNull();
2005
- });
2006
- test("method: runOrFail", async () => {
2007
- const key = "a";
2008
- const ownerA = "b";
2009
- const lockA = lockProviderA.create(key, {
2010
- owner: ownerA,
2011
- });
2012
- const promiseA = lockA.runOrFail(async () => {
2013
- await LazyPromise.delay(DELAY_TIME);
2014
- return "a";
2015
- });
2016
- const ownerB = "c";
2017
- const lockB = lockProviderB.create(key, {
2018
- owner: ownerB,
2019
- });
2020
- const promiseB = lockB.runOrFail(async () => {
2021
- await LazyPromise.delay(DELAY_TIME);
2022
- return "a";
2023
- });
2024
- const [resultA, resultB] = await Promise.all([promiseA, promiseB]);
2025
- expect(resultA).toBe("a");
2026
- expect(resultB).toBe("a");
2027
- });
2028
- test("method: acquire", async () => {
2029
- const key = "a";
2030
- const ownerA = "b";
2031
- const lockA = lockProviderA.create(key, {
2032
- owner: ownerA,
2033
- });
2034
- const resultA = await lockA.acquire();
2035
- const ownerB = "c";
2036
- const lockB = lockProviderB.create(key, {
2037
- owner: ownerB,
2038
- });
2039
- const resultB = await lockB.acquire();
2040
- expect(resultA).toBe(true);
2041
- expect(resultB).toBe(true);
2042
- });
2043
- test("method: acquireBlocking", async () => {
2044
- const key = "a";
2045
- const ownerA = "b";
2046
- const lockA = lockProviderA.create(key, {
2047
- owner: ownerA,
2048
- });
2049
- const resultA = await lockA.acquireBlocking({
2050
- time: TimeSpan.fromMilliseconds(5),
2051
- interval: TimeSpan.fromMilliseconds(5),
2052
- });
2053
- const ownerB = "c";
2054
- const lockB = lockProviderB.create(key, {
2055
- owner: ownerB,
2056
- });
2057
- const resultB = await lockB.acquire();
2058
- expect(resultA).toBe(true);
2059
- expect(resultB).toBe(true);
2060
- });
2061
- test("method: acquireOrFail", async () => {
2062
- const key = "a";
2063
- const ownerA = "b";
2064
- const lockA = lockProviderA.create(key, {
2065
- owner: ownerA,
2066
- });
2067
- const promiseA = lockA.acquireOrFail();
2068
- const ownerB = "c";
2069
- const lockB = lockProviderB.create(key, {
2070
- owner: ownerB,
2071
- });
2072
- const promiseB = lockB.acquireOrFail();
2073
- await expect(promiseA).resolves.toBeUndefined();
2074
- await expect(promiseB).resolves.toBeUndefined();
2075
- });
2076
- test("method: release", async () => {
2077
- const key = "a";
2078
- const owner = "b";
2079
- const lockA = lockProviderA.create(key, {
2080
- owner,
2081
- });
2082
- await lockA.acquire();
2083
- const lockB = lockProviderB.create(key, {
2084
- owner,
2085
- });
2086
- await lockB.acquire();
2087
- await lockA.release();
2088
- const resultA = await lockA.isLocked();
2089
- const resultB = await lockB.isLocked();
2090
- expect(resultA).toBe(false);
2091
- expect(resultB).toBe(true);
2092
- });
2093
- test("method: releaseOrFail", async () => {
2094
- const key = "a";
2095
- const owner = "b";
2096
- const lockA = lockProviderA.create(key, {
2097
- owner,
2098
- });
2099
- await lockA.acquire();
2100
- const lockB = lockProviderB.create(key, {
2101
- owner,
2102
- });
2103
- await lockB.acquire();
2104
- await lockA.releaseOrFail();
2105
- const resultA = await lockA.isLocked();
2106
- const resultB = await lockB.isLocked();
2107
- expect(resultA).toBe(false);
2108
- expect(resultB).toBe(true);
2109
- });
2110
- test("method: forceRelease", async () => {
2111
- const key = "a";
2112
- const owner = "b";
2113
- const lockA = lockProviderA.create(key, {
2114
- owner,
2115
- });
2116
- await lockA.acquire();
2117
- const lockB = lockProviderB.create(key, {
2118
- owner,
2119
- });
2120
- await lockB.acquire();
2121
- await lockA.forceRelease();
2122
- const resultA = await lockA.isLocked();
2123
- const resultB = await lockB.isLocked();
2124
- expect(resultA).toBe(false);
2125
- expect(resultB).toBe(true);
2126
- });
2127
- test("method: isExpired", async () => {
2128
- const key = "a";
2129
- const owner = "b";
2130
- const lockA = lockProviderA.create(key, { owner });
2131
- const lockB = lockProviderB.create(key, { owner });
2132
- await lockA.acquire();
2133
- await lockB.acquire();
2134
- await lockA.release();
2135
- const resultA = await lockA.isExpired();
2136
- const resultB = await lockB.isExpired();
2137
- expect(resultA).toBe(true);
2138
- expect(resultB).toBe(false);
2139
- });
2140
- test("method: isLocked", async () => {
2141
- const key = "a";
2142
- const owner = "b";
2143
- const lockA = lockProviderA.create(key, { owner });
2144
- const lockB = lockProviderB.create(key, { owner });
2145
- await lockA.acquire();
2146
- await lockB.acquire();
2147
- await lockA.release();
2148
- const resultA = await lockA.isLocked();
2149
- const resultB = await lockB.isLocked();
2150
- expect(resultA).toBe(false);
2151
- expect(resultB).toBe(true);
2152
- });
2153
- test("method: refresh", async () => {
2154
- const key = "a";
2155
- const owner = "b";
2156
- const ttl = TTL;
2157
- const lockA = lockProviderA.create(key, {
2158
- owner,
2159
- ttl,
2160
- });
2161
- const lockB = lockProviderB.create(key, {
2162
- owner,
2163
- ttl,
2164
- });
2165
- await Promise.all([lockA.acquire(), lockB.acquire()]);
2166
- await LazyPromise.delay(ttl.divide(2));
2167
- await lockA.refresh();
2168
- await LazyPromise.delay(ttl.divide(2));
2169
- const resultA = await lockA.isExpired();
2170
- const resultB = await lockB.isExpired();
2171
- expect(resultA).toBe(false);
2172
- expect(resultB).toBe(true);
2173
- });
2174
- test("method: refreshOrFail", async () => {
2175
- const key = "a";
2176
- const owner = "b";
2177
- const ttl = TTL;
2178
- const lockA = lockProviderA.create(key, {
2179
- owner,
2180
- ttl,
2181
- });
2182
- const lockB = lockProviderB.create(key, {
2183
- owner,
2184
- ttl,
2185
- });
2186
- await Promise.all([lockA.acquire(), lockB.acquire()]);
2187
- await LazyPromise.delay(ttl.divide(2));
2188
- await lockA.refreshOrFail();
2189
- await LazyPromise.delay(ttl.divide(2));
2190
- const resultA = await lockA.isExpired();
2191
- const resultB = await lockB.isExpired();
2192
- expect(resultA).toBe(false);
2193
- expect(resultB).toBe(true);
2194
- });
2195
- describe("class: Lock", () => {
2196
- test("method: addListener / dispatch", async () => {
2197
- let result_a = null;
2198
- const key = "a";
2199
- const lockA = lockProviderA.create(key);
2200
- await lockA.addListener(KeyAcquiredLockEvent, (event) => {
2201
- result_a = event;
2202
- });
2203
- let result_b = null;
2204
- const lockB = lockProviderB.create(key);
2205
- await lockB.addListener(KeyAcquiredLockEvent, (event) => {
2206
- result_b = event;
2207
- });
2208
- await lockA.acquire();
2209
- await LazyPromise.delay(DELAY_TIME);
2210
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2211
- expect(result_b).toBeNull();
2212
- });
2213
- test("method: addListenerMany / dispatch", async () => {
2214
- let result_a = null;
2215
- const key = "a";
2216
- const lockA = lockProviderA.create(key);
2217
- await lockA.addListenerMany([KeyAcquiredLockEvent], (event) => {
2218
- result_a = event;
2219
- });
2220
- let result_b = null;
2221
- const lockB = lockProviderB.create(key);
2222
- await lockB.addListenerMany([KeyAcquiredLockEvent], (event) => {
2223
- result_b = event;
2224
- });
2225
- await lockA.acquire();
2226
- await LazyPromise.delay(DELAY_TIME);
2227
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2228
- expect(result_b).toBeNull();
2229
- });
2230
- test("method: removeListener / addListener / dispatch", async () => {
2231
- let result_a = null;
2232
- const key = "a";
2233
- const lockA = lockProviderA.create(key);
2234
- await lockA.addListener(KeyAcquiredLockEvent, (event) => {
2235
- result_a = event;
2236
- });
2237
- let result_b = null;
2238
- const listenerB = (event) => {
2239
- result_b = event;
2240
- };
2241
- const lockB = lockProviderB.create(key);
2242
- await lockB.addListener(KeyAcquiredLockEvent, listenerB);
2243
- await lockB.removeListener(KeyAcquiredLockEvent, listenerB);
2244
- await lockA.acquire();
2245
- await lockB.acquire();
2246
- await LazyPromise.delay(DELAY_TIME);
2247
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2248
- expect(result_b).toBeNull();
2249
- });
2250
- test("method: removeListenerMany / addListener / dispatch", async () => {
2251
- let result_a = null;
2252
- const key = "a";
2253
- const lockA = lockProviderA.create(key);
2254
- await lockA.addListener(KeyAcquiredLockEvent, (event) => {
2255
- result_a = event;
2256
- });
2257
- let result_b = null;
2258
- const listenerB = (event) => {
2259
- result_b = event;
2260
- };
2261
- const lockB = lockProviderB.create(key);
2262
- await lockB.addListener(KeyAcquiredLockEvent, listenerB);
2263
- await lockB.removeListenerMany([KeyAcquiredLockEvent], listenerB);
2264
- await lockA.acquire();
2265
- await lockB.acquire();
2266
- await LazyPromise.delay(DELAY_TIME);
2267
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2268
- expect(result_b).toBeNull();
2269
- });
2270
- test("method: subscribe / dispatch", async () => {
2271
- let result_a = null;
2272
- const key = "a";
2273
- const lockA = lockProviderA.create(key);
2274
- await lockA.subscribe(KeyAcquiredLockEvent, (event) => {
2275
- result_a = event;
2276
- });
2277
- let result_b = null;
2278
- const listenerB = (event) => {
2279
- result_b = event;
2280
- };
2281
- const lockB = lockProviderB.create(key);
2282
- const unsubscribe = await lockB.subscribe(KeyAcquiredLockEvent, listenerB);
2283
- await unsubscribe();
2284
- await lockA.acquire();
2285
- await lockB.acquire();
2286
- await LazyPromise.delay(DELAY_TIME);
2287
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2288
- expect(result_b).toBeNull();
2289
- });
2290
- test("method: subscribeMany / dispatch", async () => {
2291
- let result_a = null;
2292
- const key = "a";
2293
- const lockA = lockProviderA.create(key);
2294
- await lockA.subscribeMany([KeyAcquiredLockEvent], (event) => {
2295
- result_a = event;
2296
- });
2297
- let result_b = null;
2298
- const listenerB = (event) => {
2299
- result_b = event;
2300
- };
2301
- const lockB = lockProviderB.create(key);
2302
- const unsubscribe = await lockB.subscribeMany([KeyAcquiredLockEvent], listenerB);
2303
- await unsubscribe();
2304
- await lockA.acquire();
2305
- await lockB.acquire();
2306
- await LazyPromise.delay(DELAY_TIME);
2307
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2308
- expect(result_b).toBeNull();
2309
- });
2310
- });
2311
- describe("class: LockProvider", () => {
2312
- test("method: addListener / dispatch", async () => {
2313
- let result_a = null;
2314
- const key = "a";
2315
- const lockA = lockProviderA.create(key);
2316
- await lockProviderA.addListener(KeyAcquiredLockEvent, (event) => {
2317
- result_a = event;
2318
- });
2319
- let result_b = null;
2320
- await lockProviderB.addListener(KeyAcquiredLockEvent, (event) => {
2321
- result_b = event;
2322
- });
2323
- await lockA.acquire();
2324
- await LazyPromise.delay(DELAY_TIME);
2325
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2326
- expect(result_b).toBeNull();
2327
- });
2328
- test("method: addListenerMany / dispatch", async () => {
2329
- let result_a = null;
2330
- const key = "a";
2331
- const lockA = lockProviderA.create(key);
2332
- await lockProviderA.addListenerMany([KeyAcquiredLockEvent], (event) => {
2333
- result_a = event;
2334
- });
2335
- let result_b = null;
2336
- await lockProviderB.addListenerMany([KeyAcquiredLockEvent], (event) => {
2337
- result_b = event;
2338
- });
2339
- await lockA.acquire();
2340
- await LazyPromise.delay(DELAY_TIME);
2341
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2342
- expect(result_b).toBeNull();
2343
- });
2344
- test("method: removeListener / addListener / dispatch", async () => {
2345
- let result_a = null;
2346
- const key = "a";
2347
- const lockA = lockProviderA.create(key);
2348
- await lockProviderA.addListener(KeyAcquiredLockEvent, (event) => {
2349
- result_a = event;
2350
- });
2351
- let result_b = null;
2352
- const listenerB = (event) => {
2353
- result_b = event;
2354
- };
2355
- const lockB = lockProviderB.create(key);
2356
- await lockProviderB.addListener(KeyAcquiredLockEvent, listenerB);
2357
- await lockProviderB.removeListener(KeyAcquiredLockEvent, listenerB);
2358
- await lockA.acquire();
2359
- await lockB.acquire();
2360
- await LazyPromise.delay(DELAY_TIME);
2361
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2362
- expect(result_b).toBeNull();
2363
- });
2364
- test("method: removeListenerMany / addListener / dispatch", async () => {
2365
- let result_a = null;
2366
- const key = "a";
2367
- const lockA = lockProviderA.create(key);
2368
- await lockProviderA.addListener(KeyAcquiredLockEvent, (event) => {
2369
- result_a = event;
2370
- });
2371
- let result_b = null;
2372
- const listenerB = (event) => {
2373
- result_b = event;
2374
- };
2375
- const lockB = lockProviderB.create(key);
2376
- await lockProviderB.addListener(KeyAcquiredLockEvent, listenerB);
2377
- await lockProviderB.removeListenerMany([KeyAcquiredLockEvent], listenerB);
2378
- await lockA.acquire();
2379
- await lockB.acquire();
2380
- await LazyPromise.delay(DELAY_TIME);
2381
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2382
- expect(result_b).toBeNull();
2383
- });
2384
- test("method: subscribe / dispatch", async () => {
2385
- let result_a = null;
2386
- const key = "a";
2387
- const lockA = lockProviderA.create(key);
2388
- await lockProviderA.subscribe(KeyAcquiredLockEvent, (event) => {
2389
- result_a = event;
2390
- });
2391
- let result_b = null;
2392
- const listenerB = (event) => {
2393
- result_b = event;
2394
- };
2395
- const lockB = lockProviderB.create(key);
2396
- const unsubscribe = await lockProviderB.subscribe(KeyAcquiredLockEvent, listenerB);
2397
- await unsubscribe();
2398
- await lockA.acquire();
2399
- await lockB.acquire();
2400
- await LazyPromise.delay(DELAY_TIME);
2401
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2402
- expect(result_b).toBeNull();
2403
- });
2404
- test("method: subscribeMany / dispatch", async () => {
2405
- let result_a = null;
2406
- const key = "a";
2407
- const lockA = lockProviderA.create(key);
2408
- await lockProviderA.subscribeMany([KeyAcquiredLockEvent], (event) => {
2409
- result_a = event;
2410
- });
2411
- let result_b = null;
2412
- const listenerB = (event) => {
2413
- result_b = event;
2414
- };
2415
- const lockB = lockProviderB.create(key);
2416
- const unsubscribe = await lockProviderB.subscribeMany([KeyAcquiredLockEvent], listenerB);
2417
- await unsubscribe();
2418
- await lockA.acquire();
2419
- await lockB.acquire();
2420
- await LazyPromise.delay(DELAY_TIME);
2421
- expect(result_a).toBeInstanceOf(KeyAcquiredLockEvent);
2422
- expect(result_b).toBeNull();
2423
- });
2424
- });
2425
- });
2426
1945
  describe("Serde tests:", () => {
2427
1946
  test("Should preserve state", async () => {
2428
1947
  const key = "a";
2429
1948
  const owner = "b";
2430
- const lock = lockProviderA.create(key, {
1949
+ const lock = lockProvider.create(key, {
2431
1950
  owner,
2432
1951
  });
2433
1952
  await lock.acquire();
@@ -2438,7 +1957,7 @@ export function lockProviderTestSuite(settings) {
2438
1957
  test("Should preserve owner", async () => {
2439
1958
  const key = "a";
2440
1959
  const owner = "b";
2441
- const lock = lockProviderA.create(key, {
1960
+ const lock = lockProvider.create(key, {
2442
1961
  owner,
2443
1962
  });
2444
1963
  const deserializedLock = serde.deserialize(serde.serialize(lock));
@@ -2448,7 +1967,7 @@ export function lockProviderTestSuite(settings) {
2448
1967
  const key = "a";
2449
1968
  const owner = "b";
2450
1969
  const ttl = TTL.multiply(2);
2451
- const lock = lockProviderA.create(key, {
1970
+ const lock = lockProvider.create(key, {
2452
1971
  owner,
2453
1972
  ttl,
2454
1973
  });