@daiso-tech/core 0.49.1 → 0.50.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 (474) hide show
  1. package/README.md +1 -1
  2. package/dist/cache/contracts/_module-exports.d.ts +1 -1
  3. package/dist/cache/contracts/_module.d.ts +1 -1
  4. package/dist/cache/contracts/{cache-factory.contract.d.ts → cache-resolver.contract.d.ts} +2 -2
  5. package/dist/cache/contracts/{cache-factory.contract.js → cache-resolver.contract.js} +1 -1
  6. package/dist/cache/contracts/cache-resolver.contract.js.map +1 -0
  7. package/dist/cache/contracts/cache.contract.d.ts +2 -2
  8. package/dist/cache/contracts/cache.errors.d.ts +3 -1
  9. package/dist/cache/contracts/cache.errors.js +5 -3
  10. package/dist/cache/contracts/cache.errors.js.map +1 -1
  11. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +1 -1
  12. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +1 -2
  13. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
  14. package/dist/cache/implementations/derivables/_module-exports.d.ts +1 -1
  15. package/dist/cache/implementations/derivables/_module-exports.js +1 -1
  16. package/dist/cache/implementations/derivables/_module-exports.js.map +1 -1
  17. package/dist/cache/implementations/derivables/_module.d.ts +1 -1
  18. package/dist/cache/implementations/derivables/_module.js +1 -1
  19. package/dist/cache/implementations/derivables/_module.js.map +1 -1
  20. package/dist/cache/implementations/derivables/{cache-factory → cache-resolver}/_module.d.ts +1 -1
  21. package/dist/cache/implementations/derivables/cache-resolver/_module.js +2 -0
  22. package/dist/cache/implementations/derivables/cache-resolver/_module.js.map +1 -0
  23. package/dist/cache/implementations/derivables/{cache-factory/cache-factory.d.ts → cache-resolver/cache-resolver.d.ts} +18 -18
  24. package/dist/cache/implementations/derivables/{cache-factory/cache-factory.js → cache-resolver/cache-resolver.js} +17 -17
  25. package/dist/cache/implementations/derivables/cache-resolver/cache-resolver.js.map +1 -0
  26. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +10 -0
  27. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +47 -43
  28. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js.map +1 -1
  29. package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +10 -0
  30. package/dist/cache/implementations/test-utilities/cache.test-suite.js +34 -34
  31. package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
  32. package/dist/circuit-breaker/contracts/_module-exports.d.ts +2 -2
  33. package/dist/circuit-breaker/contracts/_module-exports.js +1 -1
  34. package/dist/circuit-breaker/contracts/_module-exports.js.map +1 -1
  35. package/dist/circuit-breaker/contracts/_module.d.ts +2 -2
  36. package/dist/circuit-breaker/contracts/_module.js +1 -1
  37. package/dist/circuit-breaker/contracts/_module.js.map +1 -1
  38. package/dist/circuit-breaker/contracts/circuit-breaker-adapter.contract.d.ts +1 -1
  39. package/dist/circuit-breaker/contracts/circuit-breaker-adapter.contract.js +1 -1
  40. package/dist/circuit-breaker/contracts/circuit-breaker-adapter.contract.js.map +1 -1
  41. package/dist/circuit-breaker/contracts/{circuit-breaker-provider-factory.contract.d.ts → circuit-breaker-factory-resolver.contract.d.ts} +4 -4
  42. package/dist/circuit-breaker/contracts/{circuit-breaker-provider-factory.contract.js → circuit-breaker-factory-resolver.contract.js} +2 -2
  43. package/dist/circuit-breaker/contracts/circuit-breaker-factory-resolver.contract.js.map +1 -0
  44. package/dist/circuit-breaker/contracts/{circuit-breaker-provider.contract.d.ts → circuit-breaker-factory.contract.d.ts} +4 -4
  45. package/dist/circuit-breaker/contracts/{circuit-breaker-provider.contract.js → circuit-breaker-factory.contract.js} +1 -1
  46. package/dist/circuit-breaker/contracts/circuit-breaker-factory.contract.js.map +1 -0
  47. package/dist/circuit-breaker/contracts/circuit-breaker.errors.d.ts +2 -1
  48. package/dist/circuit-breaker/contracts/circuit-breaker.errors.js +4 -3
  49. package/dist/circuit-breaker/contracts/circuit-breaker.errors.js.map +1 -1
  50. package/dist/circuit-breaker/implementations/adapters/memory-circuit-breaker-storage-adapter/memory-circuit-breaker-storage-adapter.d.ts +1 -1
  51. package/dist/circuit-breaker/implementations/adapters/memory-circuit-breaker-storage-adapter/memory-circuit-breaker-storage-adapter.js +1 -1
  52. package/dist/circuit-breaker/implementations/adapters/no-op-circuit-breaker-adapter/no-op-circuit-breaker-adapter.d.ts +1 -1
  53. package/dist/circuit-breaker/implementations/adapters/no-op-circuit-breaker-adapter/no-op-circuit-breaker-adapter.js +1 -1
  54. package/dist/circuit-breaker/implementations/adapters/no-op-circuit-breaker-storage-adapter/no-op-circuit-breaker-storage-adapter.d.ts +1 -1
  55. package/dist/circuit-breaker/implementations/adapters/no-op-circuit-breaker-storage-adapter/no-op-circuit-breaker-storage-adapter.js +1 -1
  56. package/dist/circuit-breaker/implementations/derivables/_module-exports.d.ts +2 -2
  57. package/dist/circuit-breaker/implementations/derivables/_module-exports.js +2 -2
  58. package/dist/circuit-breaker/implementations/derivables/_module-exports.js.map +1 -1
  59. package/dist/circuit-breaker/implementations/derivables/_module.d.ts +2 -2
  60. package/dist/circuit-breaker/implementations/derivables/_module.js +2 -2
  61. package/dist/circuit-breaker/implementations/derivables/_module.js.map +1 -1
  62. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider → circuit-breaker-factory}/_module.d.ts +1 -1
  63. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-factory/_module.js +2 -0
  64. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider → circuit-breaker-factory}/_module.js.map +1 -1
  65. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider/circuit-breaker-provider.d.ts → circuit-breaker-factory/circuit-breaker-factory.d.ts} +9 -9
  66. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider/circuit-breaker-provider.js → circuit-breaker-factory/circuit-breaker-factory.js} +7 -7
  67. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-factory/circuit-breaker-factory.js.map +1 -0
  68. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider → circuit-breaker-factory}/circuit-breaker-serde-transformer.d.ts +1 -1
  69. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider → circuit-breaker-factory}/circuit-breaker-serde-transformer.js +1 -1
  70. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-factory/circuit-breaker-serde-transformer.js.map +1 -0
  71. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-factory/circuit-breaker.js.map +1 -0
  72. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-factory-resolver/_module.d.ts +2 -0
  73. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-factory-resolver/_module.js +3 -0
  74. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider-factory → circuit-breaker-factory-resolver}/_module.js.map +1 -1
  75. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider-factory/circuit-breaker-provider-factory.d.ts → circuit-breaker-factory-resolver/circuit-breaker-factory-resolver.d.ts} +18 -18
  76. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider-factory/circuit-breaker-provider-factory.js → circuit-breaker-factory-resolver/circuit-breaker-factory-resolver.js} +17 -17
  77. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider-factory/circuit-breaker-provider-factory.js.map → circuit-breaker-factory-resolver/circuit-breaker-factory-resolver.js.map} +1 -1
  78. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider-factory/database-circuit-breaker-provider-factory.d.ts → circuit-breaker-factory-resolver/database-circuit-breaker-factory-resolver.d.ts} +20 -20
  79. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider-factory/database-circuit-breaker-provider-factory.js → circuit-breaker-factory-resolver/database-circuit-breaker-factory-resolver.js} +19 -19
  80. package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider-factory/database-circuit-breaker-provider-factory.js.map → circuit-breaker-factory-resolver/database-circuit-breaker-factory-resolver.js.map} +1 -1
  81. package/dist/circuit-breaker/implementations/test-utilities/consecutive-breaker.test-suite.d.ts +10 -0
  82. package/dist/circuit-breaker/implementations/test-utilities/consecutive-breaker.test-suite.js +12 -11
  83. package/dist/circuit-breaker/implementations/test-utilities/consecutive-breaker.test-suite.js.map +1 -1
  84. package/dist/circuit-breaker/implementations/test-utilities/count-breaker.test-suite.d.ts +10 -0
  85. package/dist/circuit-breaker/implementations/test-utilities/count-breaker.test-suite.js +13 -12
  86. package/dist/circuit-breaker/implementations/test-utilities/count-breaker.test-suite.js.map +1 -1
  87. package/dist/circuit-breaker/implementations/test-utilities/sampling-breaker.test-suite.d.ts +10 -0
  88. package/dist/circuit-breaker/implementations/test-utilities/sampling-breaker.test-suite.js +3 -2
  89. package/dist/circuit-breaker/implementations/test-utilities/sampling-breaker.test-suite.js.map +1 -1
  90. package/dist/codec/contracts/codec.errors.d.ts +2 -1
  91. package/dist/codec/contracts/codec.errors.js +4 -3
  92. package/dist/codec/contracts/codec.errors.js.map +1 -1
  93. package/dist/collection/contracts/collection.errors.d.ts +11 -0
  94. package/dist/collection/contracts/collection.errors.js +13 -0
  95. package/dist/collection/contracts/collection.errors.js.map +1 -1
  96. package/dist/event-bus/contracts/_module-exports.d.ts +1 -1
  97. package/dist/event-bus/contracts/_module.d.ts +1 -1
  98. package/dist/event-bus/contracts/{event-bus-factory.contract.d.ts → event-bus-resolver.contract.d.ts} +2 -2
  99. package/dist/event-bus/contracts/{event-bus-factory.contract.js → event-bus-resolver.contract.js} +1 -1
  100. package/dist/event-bus/contracts/event-bus-resolver.contract.js.map +1 -0
  101. package/dist/event-bus/contracts/event-bus.contract.d.ts +1 -1
  102. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +1 -1
  103. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +1 -1
  104. package/dist/event-bus/implementations/derivables/_module-exports.d.ts +1 -1
  105. package/dist/event-bus/implementations/derivables/_module-exports.js +1 -1
  106. package/dist/event-bus/implementations/derivables/_module-exports.js.map +1 -1
  107. package/dist/event-bus/implementations/derivables/_module.d.ts +1 -1
  108. package/dist/event-bus/implementations/derivables/_module.js +1 -1
  109. package/dist/event-bus/implementations/derivables/_module.js.map +1 -1
  110. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +0 -2
  111. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  112. package/dist/event-bus/implementations/derivables/{event-bus-factory → event-bus-resolver}/_module.d.ts +1 -1
  113. package/dist/event-bus/implementations/derivables/event-bus-resolver/_module.js +2 -0
  114. package/dist/event-bus/implementations/derivables/event-bus-resolver/_module.js.map +1 -0
  115. package/dist/event-bus/implementations/derivables/{event-bus-factory/event-bus-factory.d.ts → event-bus-resolver/event-bus-resolver.d.ts} +18 -16
  116. package/dist/event-bus/implementations/derivables/{event-bus-factory/event-bus-factory.js → event-bus-resolver/event-bus-resolver.js} +17 -15
  117. package/dist/event-bus/implementations/derivables/event-bus-resolver/event-bus-resolver.js.map +1 -0
  118. package/dist/file-storage/contracts/_module-exports.d.ts +1 -1
  119. package/dist/file-storage/contracts/_module.d.ts +1 -1
  120. package/dist/file-storage/contracts/{file-storage-factory.contract.d.ts → file-storage-resolver.contract.d.ts} +2 -2
  121. package/dist/file-storage/contracts/{file-storage-factory.contract.js → file-storage-resolver.contract.js} +1 -1
  122. package/dist/file-storage/contracts/file-storage-resolver.contract.js.map +1 -0
  123. package/dist/file-storage/contracts/file-storage.contract.d.ts +2 -2
  124. package/dist/file-storage/contracts/file.errors.d.ts +2 -1
  125. package/dist/file-storage/contracts/file.errors.js +4 -3
  126. package/dist/file-storage/contracts/file.errors.js.map +1 -1
  127. package/dist/file-storage/implementations/derivables/_module-exports.d.ts +2 -2
  128. package/dist/file-storage/implementations/derivables/_module-exports.js +2 -2
  129. package/dist/file-storage/implementations/derivables/_module-exports.js.map +1 -1
  130. package/dist/file-storage/implementations/derivables/_module.d.ts +1 -1
  131. package/dist/file-storage/implementations/derivables/_module.js +1 -1
  132. package/dist/file-storage/implementations/derivables/_module.js.map +1 -1
  133. package/dist/file-storage/implementations/derivables/{file-storage-factory → file-storage-resolver}/_module.d.ts +1 -1
  134. package/dist/file-storage/implementations/derivables/file-storage-resolver/_module.js +2 -0
  135. package/dist/file-storage/implementations/derivables/{file-storage-factory → file-storage-resolver}/_module.js.map +1 -1
  136. package/dist/file-storage/implementations/derivables/{file-storage-factory/file-storage-factory.d.ts → file-storage-resolver/file-storage-resolver.d.ts} +16 -16
  137. package/dist/file-storage/implementations/derivables/{file-storage-factory/file-storage-factory.js → file-storage-resolver/file-storage-resolver.js} +15 -15
  138. package/dist/file-storage/implementations/derivables/file-storage-resolver/file-storage-resolver.js.map +1 -0
  139. package/dist/file-storage/implementations/test-utilities/file-storage-adapter.test-suite.js +1 -42
  140. package/dist/file-storage/implementations/test-utilities/file-storage-adapter.test-suite.js.map +1 -1
  141. package/dist/file-storage/implementations/test-utilities/file-storage.test-suite.js +1 -59
  142. package/dist/file-storage/implementations/test-utilities/file-storage.test-suite.js.map +1 -1
  143. package/dist/lock/contracts/_module-exports.d.ts +2 -2
  144. package/dist/lock/contracts/_module.d.ts +2 -2
  145. package/dist/lock/contracts/database-lock-adapter.contract.d.ts +7 -7
  146. package/dist/lock/contracts/lock-adapter.contract.d.ts +1 -1
  147. package/dist/lock/contracts/lock-adapter.contract.js +1 -1
  148. package/dist/lock/contracts/lock-adapter.contract.js.map +1 -1
  149. package/dist/lock/contracts/{lock-provider-factory.contract.d.ts → lock-factory-resolver.contract.d.ts} +4 -4
  150. package/dist/lock/contracts/{lock-provider-factory.contract.js → lock-factory-resolver.contract.js} +2 -2
  151. package/dist/lock/contracts/lock-factory-resolver.contract.js.map +1 -0
  152. package/dist/lock/contracts/{lock-provider.contract.d.ts → lock-factory.contract.d.ts} +6 -6
  153. package/dist/lock/contracts/{lock-provider.contract.js → lock-factory.contract.js} +1 -1
  154. package/dist/lock/contracts/lock-factory.contract.js.map +1 -0
  155. package/dist/lock/contracts/lock.contract.d.ts +2 -1
  156. package/dist/lock/contracts/lock.contract.js +1 -0
  157. package/dist/lock/contracts/lock.contract.js.map +1 -1
  158. package/dist/lock/contracts/lock.errors.d.ts +3 -2
  159. package/dist/lock/contracts/lock.errors.js +5 -4
  160. package/dist/lock/contracts/lock.errors.js.map +1 -1
  161. package/dist/lock/contracts/lock.events.d.ts +2 -2
  162. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +1 -1
  163. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +1 -1
  164. package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +1 -1
  165. package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +1 -1
  166. package/dist/lock/implementations/derivables/_module-exports.d.ts +2 -2
  167. package/dist/lock/implementations/derivables/_module-exports.js +2 -2
  168. package/dist/lock/implementations/derivables/_module-exports.js.map +1 -1
  169. package/dist/lock/implementations/derivables/_module.d.ts +2 -2
  170. package/dist/lock/implementations/derivables/_module.js +2 -2
  171. package/dist/lock/implementations/derivables/_module.js.map +1 -1
  172. package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/_module.d.ts +2 -2
  173. package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/_module.js +2 -2
  174. package/dist/lock/implementations/derivables/lock-factory/_module.js.map +1 -0
  175. package/dist/lock/implementations/derivables/lock-factory/database-lock-adapter.js.map +1 -0
  176. package/dist/lock/implementations/derivables/lock-factory/is-database-lock-adapter.js.map +1 -0
  177. package/dist/lock/implementations/derivables/{lock-provider/lock-provider.d.ts → lock-factory/lock-factory.d.ts} +14 -14
  178. package/dist/lock/implementations/derivables/{lock-provider/lock-provider.js → lock-factory/lock-factory.js} +12 -12
  179. package/dist/lock/implementations/derivables/lock-factory/lock-factory.js.map +1 -0
  180. package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/lock-serde-transformer.d.ts +1 -1
  181. package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/lock-serde-transformer.js +1 -1
  182. package/dist/lock/implementations/derivables/lock-factory/lock-serde-transformer.js.map +1 -0
  183. package/dist/lock/implementations/derivables/lock-factory/lock.js.map +1 -0
  184. package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/resolve-lock-adapter.js +2 -2
  185. package/dist/lock/implementations/derivables/lock-factory/resolve-lock-adapter.js.map +1 -0
  186. package/dist/lock/implementations/derivables/{lock-provider-factory → lock-factory-resolver}/_module.d.ts +1 -1
  187. package/dist/lock/implementations/derivables/lock-factory-resolver/_module.js +2 -0
  188. package/dist/lock/implementations/derivables/lock-factory-resolver/_module.js.map +1 -0
  189. package/dist/lock/implementations/derivables/{lock-provider-factory/lock-provider-factory.d.ts → lock-factory-resolver/lock-factory-resolver.d.ts} +20 -20
  190. package/dist/lock/implementations/derivables/{lock-provider-factory/lock-provider-factory.js → lock-factory-resolver/lock-factory-resolver.js} +19 -19
  191. package/dist/lock/implementations/derivables/lock-factory-resolver/lock-factory-resolver.js.map +1 -0
  192. package/dist/lock/implementations/test-utilities/_module-exports.d.ts +1 -1
  193. package/dist/lock/implementations/test-utilities/_module-exports.js +1 -1
  194. package/dist/lock/implementations/test-utilities/_module-exports.js.map +1 -1
  195. package/dist/lock/implementations/test-utilities/_module.d.ts +1 -1
  196. package/dist/lock/implementations/test-utilities/_module.js +1 -1
  197. package/dist/lock/implementations/test-utilities/_module.js.map +1 -1
  198. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +10 -0
  199. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +147 -164
  200. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js.map +1 -1
  201. package/dist/lock/implementations/test-utilities/{lock-provider.test-suite.d.ts → lock-factory.test-suite.d.ts} +37 -13
  202. package/dist/lock/implementations/test-utilities/{lock-provider.test-suite.js → lock-factory.test-suite.js} +488 -549
  203. package/dist/lock/implementations/test-utilities/lock-factory.test-suite.js.map +1 -0
  204. package/dist/rate-limiter/contracts/_module-exports.d.ts +2 -2
  205. package/dist/rate-limiter/contracts/_module.d.ts +2 -2
  206. package/dist/rate-limiter/contracts/rate-limiter-adapter.contract.d.ts +1 -1
  207. package/dist/rate-limiter/contracts/rate-limiter-adapter.contract.js +1 -1
  208. package/dist/rate-limiter/contracts/rate-limiter-adapter.contract.js.map +1 -1
  209. package/dist/rate-limiter/contracts/{rate-limiter-provider-factory.contract.d.ts → rate-limiter-factory-resolver.contract.d.ts} +4 -4
  210. package/dist/rate-limiter/contracts/{rate-limiter-provider-factory.contract.js → rate-limiter-factory-resolver.contract.js} +2 -2
  211. package/dist/rate-limiter/contracts/rate-limiter-factory-resolver.contract.js.map +1 -0
  212. package/dist/rate-limiter/contracts/{rate-limiter-provider.contract.d.ts → rate-limiter-factory.contract.d.ts} +4 -4
  213. package/dist/rate-limiter/contracts/{rate-limiter-provider.contract.js → rate-limiter-factory.contract.js} +1 -1
  214. package/dist/rate-limiter/contracts/rate-limiter-factory.contract.js.map +1 -0
  215. package/dist/rate-limiter/contracts/rate-limiter.errors.d.ts +3 -2
  216. package/dist/rate-limiter/contracts/rate-limiter.errors.js +6 -5
  217. package/dist/rate-limiter/contracts/rate-limiter.errors.js.map +1 -1
  218. package/dist/rate-limiter/implementations/adapters/memory-rate-limiter-storage-adapter/memory-rate-limiter-storage-adapter.d.ts +1 -1
  219. package/dist/rate-limiter/implementations/adapters/memory-rate-limiter-storage-adapter/memory-rate-limiter-storage-adapter.js +1 -1
  220. package/dist/rate-limiter/implementations/adapters/no-op-rate-limiter-adapter/no-op-rate-limiter-adapter.d.ts +1 -1
  221. package/dist/rate-limiter/implementations/adapters/no-op-rate-limiter-adapter/no-op-rate-limiter-adapter.js +1 -1
  222. package/dist/rate-limiter/implementations/adapters/no-op-rate-limiter-storage-adapter/no-op-rate-limiter-storage-adapter.d.ts +1 -1
  223. package/dist/rate-limiter/implementations/adapters/no-op-rate-limiter-storage-adapter/no-op-rate-limiter-storage-adapter.js +1 -1
  224. package/dist/rate-limiter/implementations/derivables/_module-exports.d.ts +2 -2
  225. package/dist/rate-limiter/implementations/derivables/_module-exports.js +2 -2
  226. package/dist/rate-limiter/implementations/derivables/_module-exports.js.map +1 -1
  227. package/dist/rate-limiter/implementations/derivables/_module.d.ts +2 -2
  228. package/dist/rate-limiter/implementations/derivables/_module.js +2 -2
  229. package/dist/rate-limiter/implementations/derivables/_module.js.map +1 -1
  230. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider → rate-limiter-factory}/_module.d.ts +1 -1
  231. package/dist/rate-limiter/implementations/derivables/rate-limiter-factory/_module.js +2 -0
  232. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider → rate-limiter-factory}/_module.js.map +1 -1
  233. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider/rate-limiter-provider.d.ts → rate-limiter-factory/rate-limiter-factory.d.ts} +8 -8
  234. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider/rate-limiter-provider.js → rate-limiter-factory/rate-limiter-factory.js} +6 -6
  235. package/dist/rate-limiter/implementations/derivables/rate-limiter-factory/rate-limiter-factory.js.map +1 -0
  236. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider → rate-limiter-factory}/rate-limiter-serde-transformer.d.ts +1 -1
  237. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider → rate-limiter-factory}/rate-limiter-serde-transformer.js +1 -1
  238. package/dist/rate-limiter/implementations/derivables/rate-limiter-factory/rate-limiter-serde-transformer.js.map +1 -0
  239. package/dist/rate-limiter/implementations/derivables/rate-limiter-factory/rate-limiter.js.map +1 -0
  240. package/dist/rate-limiter/implementations/derivables/rate-limiter-factory-resolver/_module.d.ts +2 -0
  241. package/dist/rate-limiter/implementations/derivables/rate-limiter-factory-resolver/_module.js +3 -0
  242. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider-factory → rate-limiter-factory-resolver}/_module.js.map +1 -1
  243. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider-factory/database-rate-limiter-provider-factory.d.ts → rate-limiter-factory-resolver/database-rate-limiter-factory-resolver.d.ts} +19 -19
  244. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider-factory/database-rate-limiter-provider-factory.js → rate-limiter-factory-resolver/database-rate-limiter-factory-resolver.js} +18 -18
  245. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider-factory/database-rate-limiter-provider-factory.js.map → rate-limiter-factory-resolver/database-rate-limiter-factory-resolver.js.map} +1 -1
  246. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider-factory/rate-limiter-provider-factory.d.ts → rate-limiter-factory-resolver/rate-limiter-factory-resolver.d.ts} +17 -17
  247. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider-factory/rate-limiter-provider-factory.js → rate-limiter-factory-resolver/rate-limiter-factory-resolver.js} +16 -16
  248. package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider-factory/rate-limiter-provider-factory.js.map → rate-limiter-factory-resolver/rate-limiter-factory-resolver.js.map} +1 -1
  249. package/dist/rate-limiter/implementations/test-utilities/fixed-window-limiter.test-suite.d.ts +10 -0
  250. package/dist/rate-limiter/implementations/test-utilities/fixed-window-limiter.test-suite.js +7 -6
  251. package/dist/rate-limiter/implementations/test-utilities/fixed-window-limiter.test-suite.js.map +1 -1
  252. package/dist/rate-limiter/implementations/test-utilities/sliding-window-limiter.test-suite.d.ts +10 -0
  253. package/dist/rate-limiter/implementations/test-utilities/sliding-window-limiter.test-suite.js +3 -2
  254. package/dist/rate-limiter/implementations/test-utilities/sliding-window-limiter.test-suite.js.map +1 -1
  255. package/dist/resilience/middlewares/timeout/timeout.middleware.js.map +1 -1
  256. package/dist/semaphore/contracts/_module-exports.d.ts +2 -2
  257. package/dist/semaphore/contracts/_module.d.ts +2 -2
  258. package/dist/semaphore/contracts/semaphore-adapter.contract.d.ts +1 -1
  259. package/dist/semaphore/contracts/semaphore-adapter.contract.js +1 -1
  260. package/dist/semaphore/contracts/semaphore-adapter.contract.js.map +1 -1
  261. package/dist/semaphore/contracts/{semaphore-provider-factory.contract.d.ts → semaphore-factory-resolver.contract.d.ts} +4 -4
  262. package/dist/semaphore/contracts/{semaphore-provider-factory.contract.js → semaphore-factory-resolver.contract.js} +2 -2
  263. package/dist/semaphore/contracts/semaphore-factory-resolver.contract.js.map +1 -0
  264. package/dist/semaphore/contracts/{semaphore-provider.contract.d.ts → semaphore-factory.contract.d.ts} +6 -6
  265. package/dist/semaphore/contracts/{semaphore-provider.contract.js → semaphore-factory.contract.js} +1 -1
  266. package/dist/semaphore/contracts/semaphore-factory.contract.js.map +1 -0
  267. package/dist/semaphore/contracts/semaphore.contract.d.ts +2 -1
  268. package/dist/semaphore/contracts/semaphore.contract.js +1 -0
  269. package/dist/semaphore/contracts/semaphore.contract.js.map +1 -1
  270. package/dist/semaphore/contracts/semaphore.errors.d.ts +3 -2
  271. package/dist/semaphore/contracts/semaphore.errors.js +4 -3
  272. package/dist/semaphore/contracts/semaphore.errors.js.map +1 -1
  273. package/dist/semaphore/contracts/semaphore.events.d.ts +4 -4
  274. package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/memory-semaphore-adapter.d.ts +1 -1
  275. package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/memory-semaphore-adapter.js +1 -1
  276. package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/no-op-semaphore-adapter.d.ts +1 -1
  277. package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/no-op-semaphore-adapter.js +1 -1
  278. package/dist/semaphore/implementations/derivables/_module-exports.d.ts +2 -2
  279. package/dist/semaphore/implementations/derivables/_module-exports.js +1 -1
  280. package/dist/semaphore/implementations/derivables/_module-exports.js.map +1 -1
  281. package/dist/semaphore/implementations/derivables/_module.d.ts +2 -2
  282. package/dist/semaphore/implementations/derivables/_module.js +1 -1
  283. package/dist/semaphore/implementations/derivables/_module.js.map +1 -1
  284. package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/_module.d.ts +1 -1
  285. package/dist/semaphore/implementations/derivables/semaphore-factory/_module.js +2 -0
  286. package/dist/{event-bus/implementations/derivables/event-bus-factory → semaphore/implementations/derivables/semaphore-factory}/_module.js.map +1 -1
  287. package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/database-semaphore-adapter.js +8 -8
  288. package/dist/semaphore/implementations/derivables/semaphore-factory/database-semaphore-adapter.js.map +1 -0
  289. package/dist/semaphore/implementations/derivables/semaphore-factory/is-database-semaphore-adapter.js.map +1 -0
  290. package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/resolve-semaphore-adapter.js +2 -2
  291. package/dist/semaphore/implementations/derivables/semaphore-factory/resolve-semaphore-adapter.js.map +1 -0
  292. package/dist/semaphore/implementations/derivables/{semaphore-provider/semaphore-provider.d.ts → semaphore-factory/semaphore-factory.d.ts} +11 -11
  293. package/dist/semaphore/implementations/derivables/{semaphore-provider/semaphore-provider.js → semaphore-factory/semaphore-factory.js} +9 -9
  294. package/dist/semaphore/implementations/derivables/semaphore-factory/semaphore-factory.js.map +1 -0
  295. package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/semaphore-serde-transformer.d.ts +1 -1
  296. package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/semaphore-serde-transformer.js +1 -1
  297. package/dist/semaphore/implementations/derivables/semaphore-factory/semaphore-serde-transformer.js.map +1 -0
  298. package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/semaphore.js +0 -1
  299. package/dist/semaphore/implementations/derivables/semaphore-factory/semaphore.js.map +1 -0
  300. package/dist/semaphore/implementations/derivables/{semaphore-provider-factory → semaphore-factory-resolver}/_module.d.ts +1 -1
  301. package/dist/semaphore/implementations/derivables/semaphore-factory-resolver/_module.js.map +1 -0
  302. package/dist/semaphore/implementations/derivables/{semaphore-provider-factory/semaphore-provider-factory.d.ts → semaphore-factory-resolver/semaphore-factory-resolver.d.ts} +19 -19
  303. package/dist/semaphore/implementations/derivables/{semaphore-provider-factory/semaphore-provider-factory.js → semaphore-factory-resolver/semaphore-factory-resolver.js} +18 -18
  304. package/dist/semaphore/implementations/derivables/semaphore-factory-resolver/semaphore-factory-resolver.js.map +1 -0
  305. package/dist/semaphore/implementations/test-utilities/_module-exports.d.ts +1 -1
  306. package/dist/semaphore/implementations/test-utilities/_module-exports.js +1 -1
  307. package/dist/semaphore/implementations/test-utilities/_module-exports.js.map +1 -1
  308. package/dist/semaphore/implementations/test-utilities/_module.d.ts +1 -1
  309. package/dist/semaphore/implementations/test-utilities/_module.js +1 -1
  310. package/dist/semaphore/implementations/test-utilities/_module.js.map +1 -1
  311. package/dist/semaphore/implementations/test-utilities/semaphore-adapter.test-suite.d.ts +10 -0
  312. package/dist/semaphore/implementations/test-utilities/semaphore-adapter.test-suite.js +11 -42
  313. package/dist/semaphore/implementations/test-utilities/semaphore-adapter.test-suite.js.map +1 -1
  314. package/dist/semaphore/implementations/test-utilities/{semaphore-provider.test-suite.d.ts → semaphore-factory.test-suite.d.ts} +37 -13
  315. package/dist/semaphore/implementations/test-utilities/{semaphore-provider.test-suite.js → semaphore-factory.test-suite.js} +453 -476
  316. package/dist/semaphore/implementations/test-utilities/semaphore-factory.test-suite.js.map +1 -0
  317. package/dist/shared-lock/contracts/_module-exports.d.ts +2 -3
  318. package/dist/shared-lock/contracts/_module-exports.js.map +1 -1
  319. package/dist/shared-lock/contracts/_module.d.ts +2 -3
  320. package/dist/shared-lock/contracts/_module.js.map +1 -1
  321. package/dist/shared-lock/contracts/database-shared-lock-adapter.contract.d.ts +6 -6
  322. package/dist/shared-lock/contracts/shared-lock-adapter.contract.d.ts +1 -1
  323. package/dist/shared-lock/contracts/shared-lock-adapter.contract.js +1 -1
  324. package/dist/shared-lock/contracts/shared-lock-adapter.contract.js.map +1 -1
  325. package/dist/shared-lock/contracts/{shared-lock-provider-factory.contract.d.ts → shared-lock-factory-resolver.contract.d.ts} +4 -4
  326. package/dist/shared-lock/contracts/{shared-lock-provider-factory.contract.js → shared-lock-factory-resolver.contract.js} +2 -2
  327. package/dist/shared-lock/contracts/shared-lock-factory-resolver.contract.js.map +1 -0
  328. package/dist/shared-lock/contracts/{shared-lock-provider.contract.d.ts → shared-lock-factory.contract.d.ts} +6 -6
  329. package/dist/shared-lock/contracts/{shared-lock-provider.contract.js → shared-lock-factory.contract.js} +1 -1
  330. package/dist/shared-lock/contracts/shared-lock-factory.contract.js.map +1 -0
  331. package/dist/shared-lock/contracts/shared-lock.errors.d.ts +20 -17
  332. package/dist/shared-lock/contracts/shared-lock.errors.js +17 -16
  333. package/dist/shared-lock/contracts/shared-lock.errors.js.map +1 -1
  334. package/dist/shared-lock/contracts/shared-lock.events.d.ts +17 -19
  335. package/dist/shared-lock/contracts/shared-lock.events.js +0 -1
  336. package/dist/shared-lock/contracts/shared-lock.events.js.map +1 -1
  337. package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/memory-shared-lock-adapter.d.ts +1 -1
  338. package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/memory-shared-lock-adapter.js +1 -1
  339. package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/no-op-shared-lock-adapter.d.ts +1 -1
  340. package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/no-op-shared-lock-adapter.js +1 -1
  341. package/dist/shared-lock/implementations/derivables/_module-exports.d.ts +2 -2
  342. package/dist/shared-lock/implementations/derivables/_module-exports.js +2 -2
  343. package/dist/shared-lock/implementations/derivables/_module-exports.js.map +1 -1
  344. package/dist/shared-lock/implementations/derivables/_module.d.ts +2 -2
  345. package/dist/shared-lock/implementations/derivables/_module.js +2 -2
  346. package/dist/shared-lock/implementations/derivables/_module.js.map +1 -1
  347. package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/_module.d.ts +1 -1
  348. package/dist/shared-lock/implementations/derivables/shared-lock-factory/_module.js +2 -0
  349. package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/_module.js.map +1 -1
  350. package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/database-shared-lock-adapter.js +8 -8
  351. package/dist/shared-lock/implementations/derivables/shared-lock-factory/database-shared-lock-adapter.js.map +1 -0
  352. package/dist/shared-lock/implementations/derivables/shared-lock-factory/is-database-shared-lock-adapter.js.map +1 -0
  353. package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/resolve-shared-lock-adapter.js +2 -2
  354. package/dist/shared-lock/implementations/derivables/shared-lock-factory/resolve-shared-lock-adapter.js.map +1 -0
  355. package/dist/shared-lock/implementations/derivables/{shared-lock-provider/shared-lock-provider.d.ts → shared-lock-factory/shared-lock-factory.d.ts} +14 -14
  356. package/dist/shared-lock/implementations/derivables/{shared-lock-provider/shared-lock-provider.js → shared-lock-factory/shared-lock-factory.js} +12 -12
  357. package/dist/shared-lock/implementations/derivables/shared-lock-factory/shared-lock-factory.js.map +1 -0
  358. package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/shared-lock-serde-transformer.d.ts +1 -1
  359. package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/shared-lock-serde-transformer.js +1 -1
  360. package/dist/shared-lock/implementations/derivables/shared-lock-factory/shared-lock-serde-transformer.js.map +1 -0
  361. package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/shared-lock.js +1 -1
  362. package/dist/shared-lock/implementations/derivables/shared-lock-factory/shared-lock.js.map +1 -0
  363. package/dist/shared-lock/implementations/derivables/{shared-lock-provider-factory → shared-lock-factory-resolver}/_module.d.ts +1 -1
  364. package/dist/shared-lock/implementations/derivables/shared-lock-factory-resolver/_module.js +2 -0
  365. package/dist/shared-lock/implementations/derivables/{shared-lock-provider-factory → shared-lock-factory-resolver}/_module.js.map +1 -1
  366. package/dist/shared-lock/implementations/derivables/{shared-lock-provider-factory/shared-lock-provider-factory.d.ts → shared-lock-factory-resolver/shared-lock-factory-resolver.d.ts} +18 -18
  367. package/dist/shared-lock/implementations/derivables/{shared-lock-provider-factory/shared-lock-provider-factory.js → shared-lock-factory-resolver/shared-lock-factory-resolver.js} +17 -17
  368. package/dist/shared-lock/implementations/derivables/shared-lock-factory-resolver/shared-lock-factory-resolver.js.map +1 -0
  369. package/dist/shared-lock/implementations/test-utilities/_module-exports.d.ts +1 -1
  370. package/dist/shared-lock/implementations/test-utilities/_module-exports.js +1 -1
  371. package/dist/shared-lock/implementations/test-utilities/_module-exports.js.map +1 -1
  372. package/dist/shared-lock/implementations/test-utilities/_module.d.ts +1 -1
  373. package/dist/shared-lock/implementations/test-utilities/_module.js +1 -1
  374. package/dist/shared-lock/implementations/test-utilities/_module.js.map +1 -1
  375. package/dist/shared-lock/implementations/test-utilities/shared-lock-adapter.test-suite.d.ts +10 -0
  376. package/dist/shared-lock/implementations/test-utilities/shared-lock-adapter.test-suite.js +206 -276
  377. package/dist/shared-lock/implementations/test-utilities/shared-lock-adapter.test-suite.js.map +1 -1
  378. package/dist/shared-lock/implementations/test-utilities/{shared-lock-provider.test-suite.d.ts → shared-lock-factory.test-suite.d.ts} +37 -13
  379. package/dist/shared-lock/implementations/test-utilities/{shared-lock-provider.test-suite.js → shared-lock-factory.test-suite.js} +1642 -1318
  380. package/dist/shared-lock/implementations/test-utilities/shared-lock-factory.test-suite.js.map +1 -0
  381. package/dist/test-utilities/_module.d.ts +18 -0
  382. package/dist/test-utilities/_module.js +96 -0
  383. package/dist/test-utilities/_module.js.map +1 -0
  384. package/dist/utilities/types/_module.d.ts +1 -0
  385. package/dist/utilities/types/infer-instance.type.d.ts +9 -0
  386. package/dist/utilities/types/infer-instance.type.js +5 -0
  387. package/dist/utilities/types/infer-instance.type.js.map +1 -0
  388. package/package.json +2 -2
  389. package/dist/cache/contracts/cache-factory.contract.js.map +0 -1
  390. package/dist/cache/implementations/derivables/cache-factory/_module.js +0 -2
  391. package/dist/cache/implementations/derivables/cache-factory/_module.js.map +0 -1
  392. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +0 -1
  393. package/dist/circuit-breaker/contracts/circuit-breaker-provider-factory.contract.js.map +0 -1
  394. package/dist/circuit-breaker/contracts/circuit-breaker-provider.contract.js.map +0 -1
  395. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-provider/_module.js +0 -2
  396. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-provider/circuit-breaker-provider.js.map +0 -1
  397. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-provider/circuit-breaker-serde-transformer.js.map +0 -1
  398. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-provider/circuit-breaker.js.map +0 -1
  399. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-provider-factory/_module.d.ts +0 -2
  400. package/dist/circuit-breaker/implementations/derivables/circuit-breaker-provider-factory/_module.js +0 -3
  401. package/dist/event-bus/contracts/event-bus-factory.contract.js.map +0 -1
  402. package/dist/event-bus/implementations/derivables/event-bus-factory/_module.js +0 -2
  403. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +0 -1
  404. package/dist/file-storage/contracts/file-storage-factory.contract.js.map +0 -1
  405. package/dist/file-storage/implementations/derivables/file-storage-factory/_module.js +0 -2
  406. package/dist/file-storage/implementations/derivables/file-storage-factory/file-storage-factory.js.map +0 -1
  407. package/dist/lock/contracts/lock-provider-factory.contract.js.map +0 -1
  408. package/dist/lock/contracts/lock-provider.contract.js.map +0 -1
  409. package/dist/lock/implementations/derivables/lock-provider/_module.js.map +0 -1
  410. package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +0 -1
  411. package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js.map +0 -1
  412. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +0 -1
  413. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +0 -1
  414. package/dist/lock/implementations/derivables/lock-provider/lock.js.map +0 -1
  415. package/dist/lock/implementations/derivables/lock-provider/resolve-lock-adapter.js.map +0 -1
  416. package/dist/lock/implementations/derivables/lock-provider-factory/_module.js +0 -2
  417. package/dist/lock/implementations/derivables/lock-provider-factory/_module.js.map +0 -1
  418. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +0 -1
  419. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +0 -1
  420. package/dist/rate-limiter/contracts/rate-limiter-provider-factory.contract.js.map +0 -1
  421. package/dist/rate-limiter/contracts/rate-limiter-provider.contract.js.map +0 -1
  422. package/dist/rate-limiter/implementations/derivables/rate-limiter-provider/_module.js +0 -2
  423. package/dist/rate-limiter/implementations/derivables/rate-limiter-provider/rate-limiter-provider.js.map +0 -1
  424. package/dist/rate-limiter/implementations/derivables/rate-limiter-provider/rate-limiter-serde-transformer.js.map +0 -1
  425. package/dist/rate-limiter/implementations/derivables/rate-limiter-provider/rate-limiter.js.map +0 -1
  426. package/dist/rate-limiter/implementations/derivables/rate-limiter-provider-factory/_module.d.ts +0 -2
  427. package/dist/rate-limiter/implementations/derivables/rate-limiter-provider-factory/_module.js +0 -3
  428. package/dist/semaphore/contracts/semaphore-provider-factory.contract.js.map +0 -1
  429. package/dist/semaphore/contracts/semaphore-provider.contract.js.map +0 -1
  430. package/dist/semaphore/implementations/derivables/semaphore-provider/_module.js +0 -2
  431. package/dist/semaphore/implementations/derivables/semaphore-provider/_module.js.map +0 -1
  432. package/dist/semaphore/implementations/derivables/semaphore-provider/database-semaphore-adapter.js.map +0 -1
  433. package/dist/semaphore/implementations/derivables/semaphore-provider/is-database-semaphore-adapter.js.map +0 -1
  434. package/dist/semaphore/implementations/derivables/semaphore-provider/resolve-semaphore-adapter.js.map +0 -1
  435. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-provider.js.map +0 -1
  436. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-serde-transformer.js.map +0 -1
  437. package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore.js.map +0 -1
  438. package/dist/semaphore/implementations/derivables/semaphore-provider-factory/_module.js.map +0 -1
  439. package/dist/semaphore/implementations/derivables/semaphore-provider-factory/semaphore-provider-factory.js.map +0 -1
  440. package/dist/semaphore/implementations/test-utilities/semaphore-provider.test-suite.js.map +0 -1
  441. package/dist/shared-lock/contracts/shared-lock-provider-factory.contract.js.map +0 -1
  442. package/dist/shared-lock/contracts/shared-lock-provider.contract.js.map +0 -1
  443. package/dist/shared-lock/implementations/derivables/shared-lock-provider/_module.js +0 -2
  444. package/dist/shared-lock/implementations/derivables/shared-lock-provider/database-shared-lock-adapter.js.map +0 -1
  445. package/dist/shared-lock/implementations/derivables/shared-lock-provider/is-database-shared-lock-adapter.js.map +0 -1
  446. package/dist/shared-lock/implementations/derivables/shared-lock-provider/resolve-shared-lock-adapter.js.map +0 -1
  447. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-provider.js.map +0 -1
  448. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-serde-transformer.js.map +0 -1
  449. package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock.js.map +0 -1
  450. package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/_module.js +0 -2
  451. package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/shared-lock-provider-factory.js.map +0 -1
  452. package/dist/shared-lock/implementations/test-utilities/shared-lock-provider.test-suite.js.map +0 -1
  453. /package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider → circuit-breaker-factory}/circuit-breaker.d.ts +0 -0
  454. /package/dist/circuit-breaker/implementations/derivables/{circuit-breaker-provider → circuit-breaker-factory}/circuit-breaker.js +0 -0
  455. /package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/database-lock-adapter.d.ts +0 -0
  456. /package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/database-lock-adapter.js +0 -0
  457. /package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/is-database-lock-adapter.d.ts +0 -0
  458. /package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/is-database-lock-adapter.js +0 -0
  459. /package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/lock.d.ts +0 -0
  460. /package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/lock.js +0 -0
  461. /package/dist/lock/implementations/derivables/{lock-provider → lock-factory}/resolve-lock-adapter.d.ts +0 -0
  462. /package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider → rate-limiter-factory}/rate-limiter.d.ts +0 -0
  463. /package/dist/rate-limiter/implementations/derivables/{rate-limiter-provider → rate-limiter-factory}/rate-limiter.js +0 -0
  464. /package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/database-semaphore-adapter.d.ts +0 -0
  465. /package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/is-database-semaphore-adapter.d.ts +0 -0
  466. /package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/is-database-semaphore-adapter.js +0 -0
  467. /package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/resolve-semaphore-adapter.d.ts +0 -0
  468. /package/dist/semaphore/implementations/derivables/{semaphore-provider → semaphore-factory}/semaphore.d.ts +0 -0
  469. /package/dist/semaphore/implementations/derivables/{semaphore-provider-factory → semaphore-factory-resolver}/_module.js +0 -0
  470. /package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/database-shared-lock-adapter.d.ts +0 -0
  471. /package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/is-database-shared-lock-adapter.d.ts +0 -0
  472. /package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/is-database-shared-lock-adapter.js +0 -0
  473. /package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/resolve-shared-lock-adapter.d.ts +0 -0
  474. /package/dist/shared-lock/implementations/derivables/{shared-lock-provider → shared-lock-factory}/shared-lock.d.ts +0 -0
@@ -5,11 +5,12 @@ import { vi, } from "vitest";
5
5
  import { FailedAcquireLockError, FailedReleaseLockError, LOCK_EVENTS, FailedRefreshLockError, LOCK_STATE, } from "../../../lock/contracts/_module.js";
6
6
  import {} from "../../../serde/contracts/_module.js";
7
7
  import { Task } from "../../../task/implementations/_module.js";
8
- import { TO_MILLISECONDS } from "../../../time-span/contracts/_module.js";
8
+ import { createIsTimeSpanEqualityTester } from "../../../test-utilities/_module.js";
9
+ import { TO_MILLISECONDS, } from "../../../time-span/contracts/_module.js";
9
10
  import { TimeSpan } from "../../../time-span/implementations/_module.js";
10
11
  import {} from "../../../utilities/_module.js";
11
12
  /**
12
- * The `lockProviderTestSuite` function simplifies the process of testing your custom implementation of {@link ILock | `ILock`} with `vitest`.
13
+ * The `lockFactoryTestSuite` function simplifies the process of testing your custom implementation of {@link ILock | `ILock`} with `vitest`.
13
14
  *
14
15
  * IMPORT_PATH: `"@daiso-tech/core/lock/test-utilities"`
15
16
  * @group Utilities
@@ -17,23 +18,23 @@ import {} from "../../../utilities/_module.js";
17
18
  * ```ts
18
19
  * import { describe, expect, test, beforeEach } from "vitest";
19
20
  * import { MemoryLockAdapter } from "@daiso-tech/core/lock/memory-lock-adapter";
20
- * import { LockProvider } from "@daiso-tech/core/lock";
21
+ * import { LockFactory } from "@daiso-tech/core/lock";
21
22
  * import { EventBus } from "@daiso-tech/core/event-bus";
22
23
  * import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/memory-event-bus-adapter";
23
- * import { lockProviderTestSuite } from "@daiso-tech/core/lock/test-utilities";
24
+ * import { lockFactoryTestSuite } from "@daiso-tech/core/lock/test-utilities";
24
25
  * import { Serde } from "@daiso-tech/core/serde";
25
26
  * import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/super-json-serde-adapter";
26
27
  * import type { ILockData } from "@daiso-tech/core/lock/contracts";
27
28
  *
28
- * describe("class: LockProvider", () => {
29
- * lockProviderTestSuite({
30
- * createLockProvider: () => {
29
+ * describe("class: LockFactory", () => {
30
+ * lockFactoryTestSuite({
31
+ * createLockFactory: () => {
31
32
  * const serde = new Serde(new SuperJsonSerdeAdapter());
32
- * const lockProvider = new LockProvider({
33
+ * const lockFactory = new LockFactory({
33
34
  * serde,
34
35
  * adapter: new MemoryLockAdapter(),
35
36
  * });
36
- * return { lockProvider, serde };
37
+ * return { lockFactory, serde };
37
38
  * },
38
39
  * beforeEach,
39
40
  * describe,
@@ -44,18 +45,18 @@ import {} from "../../../utilities/_module.js";
44
45
  * });
45
46
  * ```
46
47
  */
47
- export function lockProviderTestSuite(settings) {
48
- const { expect, test, createLockProvider, describe, beforeEach, excludeEventTests = false, excludeSerdeTests = false, } = settings;
49
- let lockProvider;
48
+ export function lockFactoryTestSuite(settings) {
49
+ const { expect, test, createLockFactory, describe, beforeEach, excludeEventTests = false, excludeSerdeTests = false, retry = 0, delayBuffer = TimeSpan.fromMilliseconds(10), timeSpanEqualityBuffer = TimeSpan.fromMilliseconds(10), } = settings;
50
+ let lockFactory;
50
51
  let serde;
51
52
  async function delay(time) {
52
- await Task.delay(time.addMilliseconds(10));
53
+ await Task.delay(TimeSpan.fromTimeSpan(time).addTimeSpan(delayBuffer));
53
54
  }
54
55
  const RETURN_VALUE = "RETURN_VALUE";
55
- describe("ILockProvider tests:", () => {
56
+ describe("ILockFactory tests:", () => {
56
57
  beforeEach(async () => {
57
- const { lockProvider: lockProvider_, serde: serde_ } = await createLockProvider();
58
- lockProvider = lockProvider_;
58
+ const { lockFactory: lockFactory_, serde: serde_ } = await createLockFactory();
59
+ lockFactory = lockFactory_;
59
60
  serde = serde_;
60
61
  });
61
62
  describe("Api tests:", () => {
@@ -63,7 +64,7 @@ export function lockProviderTestSuite(settings) {
63
64
  test("Should call acquireOrFail method", async () => {
64
65
  const key = "a";
65
66
  const ttl = null;
66
- const lock = lockProvider.create(key, {
67
+ const lock = lockFactory.create(key, {
67
68
  ttl,
68
69
  });
69
70
  const acquireSpy = vi.spyOn(lock, "acquireOrFail");
@@ -75,7 +76,7 @@ export function lockProviderTestSuite(settings) {
75
76
  test("Should call acquireOrFail before release method", async () => {
76
77
  const key = "a";
77
78
  const ttl = null;
78
- const lock = lockProvider.create(key, {
79
+ const lock = lockFactory.create(key, {
79
80
  ttl,
80
81
  });
81
82
  const acquireSpy = vi.spyOn(lock, "acquireOrFail");
@@ -88,7 +89,7 @@ export function lockProviderTestSuite(settings) {
88
89
  test("Should call release method", async () => {
89
90
  const key = "a";
90
91
  const ttl = null;
91
- const lock = lockProvider.create(key, {
92
+ const lock = lockFactory.create(key, {
92
93
  ttl,
93
94
  });
94
95
  const releaseSpy = vi.spyOn(lock, "release");
@@ -100,7 +101,7 @@ export function lockProviderTestSuite(settings) {
100
101
  test("Should call release after acquireOrFail method", async () => {
101
102
  const key = "a";
102
103
  const ttl = null;
103
- const lock = lockProvider.create(key, {
104
+ const lock = lockFactory.create(key, {
104
105
  ttl,
105
106
  });
106
107
  const releaseSpy = vi.spyOn(lock, "release");
@@ -113,7 +114,7 @@ export function lockProviderTestSuite(settings) {
113
114
  test("Should call release when an error is thrown", async () => {
114
115
  const key = "a";
115
116
  const ttl = null;
116
- const lock = lockProvider.create(key, {
117
+ const lock = lockFactory.create(key, {
117
118
  ttl,
118
119
  });
119
120
  const releaseSpy = vi.spyOn(lock, "release");
@@ -130,7 +131,7 @@ export function lockProviderTestSuite(settings) {
130
131
  test("Should propagate thrown error", async () => {
131
132
  const key = "a";
132
133
  const ttl = null;
133
- const lock = lockProvider.create(key, {
134
+ const lock = lockFactory.create(key, {
134
135
  ttl,
135
136
  });
136
137
  class CustomError extends Error {
@@ -146,32 +147,28 @@ export function lockProviderTestSuite(settings) {
146
147
  const handlerFn = vi.fn(() => {
147
148
  return Promise.resolve(RETURN_VALUE);
148
149
  });
149
- await lockProvider
150
+ await lockFactory
150
151
  .create(key, {
151
152
  ttl,
152
153
  })
153
154
  .runOrFail(handlerFn);
154
155
  expect(handlerFn).toHaveBeenCalledTimes(1);
155
156
  });
156
- test("Should call handler function when key is expired", {
157
- retry: 10,
158
- }, async () => {
157
+ test("Should call handler function when key is expired", async () => {
159
158
  const key = "a";
160
159
  const ttl = TimeSpan.fromMilliseconds(50);
161
- await lockProvider.create(key, { ttl }).acquire();
160
+ await lockFactory.create(key, { ttl }).acquire();
162
161
  await delay(ttl);
163
162
  const handlerFn = vi.fn(() => {
164
163
  return Promise.resolve(RETURN_VALUE);
165
164
  });
166
- await lockProvider
167
- .create(key, { ttl })
168
- .runOrFail(handlerFn);
165
+ await lockFactory.create(key, { ttl }).runOrFail(handlerFn);
169
166
  expect(handlerFn).toHaveBeenCalledTimes(1);
170
167
  });
171
- test("Should call handler function when key is unexpireable and acquired by same lockId", async () => {
168
+ test("Should call handler function when key is unexpireable and acquired by same lock-id", async () => {
172
169
  const key = "a";
173
170
  const ttl = null;
174
- const lock = lockProvider.create(key, { ttl });
171
+ const lock = lockFactory.create(key, { ttl });
175
172
  await lock.acquire();
176
173
  const handlerFn = vi.fn(() => {
177
174
  return Promise.resolve(RETURN_VALUE);
@@ -184,10 +181,10 @@ export function lockProviderTestSuite(settings) {
184
181
  }
185
182
  expect(handlerFn).toHaveBeenCalledTimes(1);
186
183
  });
187
- test("Should call handler function when key is unexpired and acquired by same lockId", async () => {
184
+ test("Should call handler function when key is unexpired and acquired by same lock-id", async () => {
188
185
  const key = "a";
189
186
  const ttl = TimeSpan.fromMilliseconds(50);
190
- const lock = lockProvider.create(key, {
187
+ const lock = lockFactory.create(key, {
191
188
  ttl,
192
189
  });
193
190
  await lock.acquire();
@@ -202,15 +199,15 @@ export function lockProviderTestSuite(settings) {
202
199
  }
203
200
  expect(handlerFn).toHaveBeenCalledTimes(1);
204
201
  });
205
- test("Should not call handler function when key is unexpireable and acquired by different lockId", async () => {
202
+ test("Should not call handler function when key is unexpireable and acquired by different lock-id", async () => {
206
203
  const key = "a";
207
204
  const ttl = null;
208
- await lockProvider.create(key, { ttl }).acquire();
205
+ await lockFactory.create(key, { ttl }).acquire();
209
206
  const handlerFn = vi.fn(() => {
210
207
  return Promise.resolve(RETURN_VALUE);
211
208
  });
212
209
  try {
213
- await lockProvider
210
+ await lockFactory
214
211
  .create(key, { ttl })
215
212
  .runOrFail(handlerFn);
216
213
  }
@@ -219,15 +216,15 @@ export function lockProviderTestSuite(settings) {
219
216
  }
220
217
  expect(handlerFn).not.toHaveBeenCalled();
221
218
  });
222
- test("Should not call handler function when key is unexpired and acquired by different lockId", async () => {
219
+ test("Should not call handler function when key is unexpired and acquired by different lock-id", async () => {
223
220
  const key = "a";
224
221
  const ttl = TimeSpan.fromMilliseconds(50);
225
- await lockProvider.create(key, { ttl }).acquire();
222
+ await lockFactory.create(key, { ttl }).acquire();
226
223
  const handlerFn = vi.fn(() => {
227
224
  return Promise.resolve(RETURN_VALUE);
228
225
  });
229
226
  try {
230
- await lockProvider
227
+ await lockFactory
231
228
  .create(key, { ttl })
232
229
  .runOrFail(handlerFn);
233
230
  }
@@ -239,7 +236,7 @@ export function lockProviderTestSuite(settings) {
239
236
  test("Should return value when key doesnt exists", async () => {
240
237
  const key = "a";
241
238
  const ttl = null;
242
- const result = await lockProvider
239
+ const result = await lockFactory
243
240
  .create(key, {
244
241
  ttl,
245
242
  })
@@ -248,34 +245,32 @@ export function lockProviderTestSuite(settings) {
248
245
  });
249
246
  expect(result).toBe(RETURN_VALUE);
250
247
  });
251
- test("Should return value when key is expired", {
252
- retry: 10,
253
- }, async () => {
248
+ test("Should return value when key is expired", async () => {
254
249
  const key = "a";
255
250
  const ttl = TimeSpan.fromMilliseconds(50);
256
- await lockProvider.create(key, { ttl }).acquire();
251
+ await lockFactory.create(key, { ttl }).acquire();
257
252
  await delay(ttl);
258
- const result = await lockProvider
253
+ const result = await lockFactory
259
254
  .create(key, { ttl })
260
255
  .runOrFail(() => {
261
256
  return Promise.resolve(RETURN_VALUE);
262
257
  });
263
258
  expect(result).toBe(RETURN_VALUE);
264
259
  });
265
- test("Should not throw error when key is unexpireable and acquired by same lockId", async () => {
260
+ test("Should not throw error when key is unexpireable and acquired by same lock-id", async () => {
266
261
  const key = "a";
267
262
  const ttl = null;
268
- const lock = lockProvider.create(key, { ttl });
263
+ const lock = lockFactory.create(key, { ttl });
269
264
  await lock.acquire();
270
265
  const result = await lock.runOrFail(() => {
271
266
  return Promise.resolve(RETURN_VALUE);
272
267
  });
273
268
  expect(result).toBe(RETURN_VALUE);
274
269
  });
275
- test("Should not throw error when key is unexpired and acquired by same lockId", async () => {
270
+ test("Should not throw error when key is unexpired and acquired by same lock-id", async () => {
276
271
  const key = "a";
277
272
  const ttl = TimeSpan.fromMilliseconds(50);
278
- const lock = lockProvider.create(key, {
273
+ const lock = lockFactory.create(key, {
279
274
  ttl,
280
275
  });
281
276
  await lock.acquire();
@@ -284,22 +279,22 @@ export function lockProviderTestSuite(settings) {
284
279
  });
285
280
  expect(result).toBe(RETURN_VALUE);
286
281
  });
287
- test("Should throw FailedAcquireLockError when key is unexpireable and acquired by different lockId", async () => {
282
+ test("Should throw FailedAcquireLockError when key is unexpireable and acquired by different lock-id", async () => {
288
283
  const key = "a";
289
284
  const ttl = null;
290
- await lockProvider.create(key, { ttl }).acquire();
291
- const result = lockProvider
285
+ await lockFactory.create(key, { ttl }).acquire();
286
+ const result = lockFactory
292
287
  .create(key, { ttl })
293
288
  .runOrFail(() => {
294
289
  return Promise.resolve(RETURN_VALUE);
295
290
  });
296
291
  await expect(result).rejects.toBeInstanceOf(FailedAcquireLockError);
297
292
  });
298
- test("Should throw FailedAcquireLockError when key is unexpired and acquired by different lockId", async () => {
293
+ test("Should throw FailedAcquireLockError when key is unexpired and acquired by different lock-id", async () => {
299
294
  const key = "a";
300
295
  const ttl = TimeSpan.fromMilliseconds(50);
301
- await lockProvider.create(key, { ttl }).acquire();
302
- const result = lockProvider
296
+ await lockFactory.create(key, { ttl }).acquire();
297
+ const result = lockFactory
303
298
  .create(key, { ttl })
304
299
  .runOrFail(() => {
305
300
  return Promise.resolve(RETURN_VALUE);
@@ -311,7 +306,7 @@ export function lockProviderTestSuite(settings) {
311
306
  test("Should call acquireBlockingOrFail method", async () => {
312
307
  const key = "a";
313
308
  const ttl = null;
314
- const lock = lockProvider.create(key, {
309
+ const lock = lockFactory.create(key, {
315
310
  ttl,
316
311
  });
317
312
  const acquireSpy = vi.spyOn(lock, "acquireBlockingOrFail");
@@ -326,7 +321,7 @@ export function lockProviderTestSuite(settings) {
326
321
  test("Should call acquireBlockingOrFail before release method", async () => {
327
322
  const key = "a";
328
323
  const ttl = null;
329
- const lock = lockProvider.create(key, {
324
+ const lock = lockFactory.create(key, {
330
325
  ttl,
331
326
  });
332
327
  const acquireSpy = vi.spyOn(lock, "acquireBlockingOrFail");
@@ -342,7 +337,7 @@ export function lockProviderTestSuite(settings) {
342
337
  test("Should call release method", async () => {
343
338
  const key = "a";
344
339
  const ttl = null;
345
- const lock = lockProvider.create(key, {
340
+ const lock = lockFactory.create(key, {
346
341
  ttl,
347
342
  });
348
343
  const releaseSpy = vi.spyOn(lock, "release");
@@ -357,7 +352,7 @@ export function lockProviderTestSuite(settings) {
357
352
  test("Should call release after acquireBlockingOrFail method", async () => {
358
353
  const key = "a";
359
354
  const ttl = null;
360
- const lock = lockProvider.create(key, {
355
+ const lock = lockFactory.create(key, {
361
356
  ttl,
362
357
  });
363
358
  const releaseSpy = vi.spyOn(lock, "release");
@@ -373,7 +368,7 @@ export function lockProviderTestSuite(settings) {
373
368
  test("Should call release when an error is thrown", async () => {
374
369
  const key = "a";
375
370
  const ttl = null;
376
- const lock = lockProvider.create(key, {
371
+ const lock = lockFactory.create(key, {
377
372
  ttl,
378
373
  });
379
374
  const releaseSpy = vi.spyOn(lock, "release");
@@ -393,7 +388,7 @@ export function lockProviderTestSuite(settings) {
393
388
  test("Should propagate thrown error", async () => {
394
389
  const key = "a";
395
390
  const ttl = null;
396
- const lock = lockProvider.create(key, {
391
+ const lock = lockFactory.create(key, {
397
392
  ttl,
398
393
  });
399
394
  class CustomError extends Error {
@@ -412,7 +407,7 @@ export function lockProviderTestSuite(settings) {
412
407
  const handlerFn = vi.fn(() => {
413
408
  return Promise.resolve(RETURN_VALUE);
414
409
  });
415
- await lockProvider
410
+ await lockFactory
416
411
  .create(key, {
417
412
  ttl,
418
413
  })
@@ -422,17 +417,15 @@ export function lockProviderTestSuite(settings) {
422
417
  });
423
418
  expect(handlerFn).toHaveBeenCalledTimes(1);
424
419
  });
425
- test("Should call handler function when key is expired", {
426
- retry: 10,
427
- }, async () => {
420
+ test("Should call handler function when key is expired", async () => {
428
421
  const key = "a";
429
422
  const ttl = TimeSpan.fromMilliseconds(50);
430
- await lockProvider.create(key, { ttl }).acquire();
423
+ await lockFactory.create(key, { ttl }).acquire();
431
424
  await delay(ttl);
432
425
  const handlerFn = vi.fn(() => {
433
426
  return Promise.resolve(RETURN_VALUE);
434
427
  });
435
- await lockProvider
428
+ await lockFactory
436
429
  .create(key, { ttl })
437
430
  .runBlockingOrFail(handlerFn, {
438
431
  time: TimeSpan.fromMilliseconds(5),
@@ -440,10 +433,10 @@ export function lockProviderTestSuite(settings) {
440
433
  });
441
434
  expect(handlerFn).toHaveBeenCalledTimes(1);
442
435
  });
443
- test("Should call handler function when key is unexpireable and acquired by same lockId", async () => {
436
+ test("Should call handler function when key is unexpireable and acquired by same lock-id", async () => {
444
437
  const key = "a";
445
438
  const ttl = null;
446
- const lock = lockProvider.create(key, { ttl });
439
+ const lock = lockFactory.create(key, { ttl });
447
440
  await lock.acquire();
448
441
  const handlerFn = vi.fn(() => {
449
442
  return Promise.resolve(RETURN_VALUE);
@@ -459,10 +452,10 @@ export function lockProviderTestSuite(settings) {
459
452
  }
460
453
  expect(handlerFn).toHaveBeenCalledTimes(1);
461
454
  });
462
- test("Should call handler function when key is unexpired and acquired by same lockId", async () => {
455
+ test("Should call handler function when key is unexpired and acquired by same lock-id", async () => {
463
456
  const key = "a";
464
457
  const ttl = TimeSpan.fromMilliseconds(50);
465
- const lock = lockProvider.create(key, {
458
+ const lock = lockFactory.create(key, {
466
459
  ttl,
467
460
  });
468
461
  await lock.acquire();
@@ -480,15 +473,15 @@ export function lockProviderTestSuite(settings) {
480
473
  }
481
474
  expect(handlerFn).toHaveBeenCalledTimes(1);
482
475
  });
483
- test("Should not call handler function when key is unexpireable and acquired by different lockId", async () => {
476
+ test("Should not call handler function when key is unexpireable and acquired by different lock-id", async () => {
484
477
  const key = "a";
485
478
  const ttl = null;
486
- await lockProvider.create(key, { ttl }).acquire();
479
+ await lockFactory.create(key, { ttl }).acquire();
487
480
  const handlerFn = vi.fn(() => {
488
481
  return Promise.resolve(RETURN_VALUE);
489
482
  });
490
483
  try {
491
- await lockProvider
484
+ await lockFactory
492
485
  .create(key, { ttl })
493
486
  .runBlockingOrFail(handlerFn, {
494
487
  time: TimeSpan.fromMilliseconds(5),
@@ -500,15 +493,15 @@ export function lockProviderTestSuite(settings) {
500
493
  }
501
494
  expect(handlerFn).not.toHaveBeenCalled();
502
495
  });
503
- test("Should not call handler function when key is unexpired and acquired by different lockId", async () => {
496
+ test("Should not call handler function when key is unexpired and acquired by different lock-id", async () => {
504
497
  const key = "a";
505
498
  const ttl = TimeSpan.fromMilliseconds(50);
506
- await lockProvider.create(key, { ttl }).acquire();
499
+ await lockFactory.create(key, { ttl }).acquire();
507
500
  const handlerFn = vi.fn(() => {
508
501
  return Promise.resolve(RETURN_VALUE);
509
502
  });
510
503
  try {
511
- await lockProvider
504
+ await lockFactory
512
505
  .create(key, { ttl })
513
506
  .runBlockingOrFail(handlerFn, {
514
507
  time: TimeSpan.fromMilliseconds(5),
@@ -523,7 +516,7 @@ export function lockProviderTestSuite(settings) {
523
516
  test("Should return value when key doesnt exists", async () => {
524
517
  const key = "a";
525
518
  const ttl = null;
526
- const result = await lockProvider
519
+ const result = await lockFactory
527
520
  .create(key, {
528
521
  ttl,
529
522
  })
@@ -538,9 +531,9 @@ export function lockProviderTestSuite(settings) {
538
531
  test("Should return value when key is expired", async () => {
539
532
  const key = "a";
540
533
  const ttl = TimeSpan.fromMilliseconds(50);
541
- await lockProvider.create(key, { ttl }).acquire();
534
+ await lockFactory.create(key, { ttl }).acquire();
542
535
  await delay(ttl);
543
- const result = await lockProvider
536
+ const result = await lockFactory
544
537
  .create(key, { ttl })
545
538
  .runBlockingOrFail(() => {
546
539
  return Promise.resolve(RETURN_VALUE);
@@ -550,10 +543,10 @@ export function lockProviderTestSuite(settings) {
550
543
  });
551
544
  expect(result).toBe(RETURN_VALUE);
552
545
  });
553
- test("Should return value when key is unexpireable and acquired by same lockId", async () => {
546
+ test("Should return value when key is unexpireable and acquired by same lock-id", async () => {
554
547
  const key = "a";
555
548
  const ttl = null;
556
- const lock = lockProvider.create(key, { ttl });
549
+ const lock = lockFactory.create(key, { ttl });
557
550
  await lock.acquire();
558
551
  const result = await lock.runBlockingOrFail(() => {
559
552
  return Promise.resolve(RETURN_VALUE);
@@ -563,10 +556,10 @@ export function lockProviderTestSuite(settings) {
563
556
  });
564
557
  expect(result).toBe(RETURN_VALUE);
565
558
  });
566
- test("Should return value when key is unexpired and acquired by same lockId", async () => {
559
+ test("Should return value when key is unexpired and acquired by same lock-id", async () => {
567
560
  const key = "a";
568
561
  const ttl = TimeSpan.fromMilliseconds(50);
569
- const lock = lockProvider.create(key, {
562
+ const lock = lockFactory.create(key, {
570
563
  ttl,
571
564
  });
572
565
  await lock.acquire();
@@ -578,11 +571,11 @@ export function lockProviderTestSuite(settings) {
578
571
  });
579
572
  expect(result).toBe(RETURN_VALUE);
580
573
  });
581
- test("Should throw FailedAcquireLockError when key is unexpireable and acquired by different lockId", async () => {
574
+ test("Should throw FailedAcquireLockError when key is unexpireable and acquired by different lock-id", async () => {
582
575
  const key = "a";
583
576
  const ttl = null;
584
- await lockProvider.create(key, { ttl }).acquire();
585
- const result = lockProvider
577
+ await lockFactory.create(key, { ttl }).acquire();
578
+ const result = lockFactory
586
579
  .create(key, { ttl })
587
580
  .runBlockingOrFail(() => {
588
581
  return Promise.resolve(RETURN_VALUE);
@@ -592,11 +585,11 @@ export function lockProviderTestSuite(settings) {
592
585
  });
593
586
  await expect(result).rejects.toBeInstanceOf(FailedAcquireLockError);
594
587
  });
595
- test("Should throw FailedAcquireLockError when key is unexpired and acquired by different lockId", async () => {
588
+ test("Should throw FailedAcquireLockError when key is unexpired and acquired by different lock-id", async () => {
596
589
  const key = "a";
597
590
  const ttl = TimeSpan.fromMilliseconds(50);
598
- await lockProvider.create(key, { ttl }).acquire();
599
- const result = lockProvider
591
+ await lockFactory.create(key, { ttl }).acquire();
592
+ const result = lockFactory
600
593
  .create(key, { ttl })
601
594
  .runBlockingOrFail(() => {
602
595
  return Promise.resolve(RETURN_VALUE);
@@ -606,16 +599,16 @@ export function lockProviderTestSuite(settings) {
606
599
  });
607
600
  await expect(result).rejects.toBeInstanceOf(FailedAcquireLockError);
608
601
  });
609
- test("Should retry acquire the lock", async () => {
602
+ test("Should retry acquire the lock", { retry }, async () => {
610
603
  const key = "a";
611
604
  const ttl = TimeSpan.fromMilliseconds(50);
612
- const lock1 = lockProvider.create(key, {
605
+ const lock1 = lockFactory.create(key, {
613
606
  ttl,
614
607
  });
615
608
  await lock1.acquire();
616
609
  const handlerFn = vi.fn(() => { });
617
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
618
- const lock2 = lockProvider.create(key, {
610
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
611
+ const lock2 = lockFactory.create(key, {
619
612
  ttl,
620
613
  });
621
614
  try {
@@ -636,57 +629,55 @@ export function lockProviderTestSuite(settings) {
636
629
  test("Should return true when key doesnt exists", async () => {
637
630
  const key = "a";
638
631
  const ttl = null;
639
- const result = await lockProvider
632
+ const result = await lockFactory
640
633
  .create(key, {
641
634
  ttl,
642
635
  })
643
636
  .acquire();
644
637
  expect(result).toBe(true);
645
638
  });
646
- test("Should return true when key is expired", {
647
- retry: 10,
648
- }, async () => {
639
+ test("Should return true when key is expired", async () => {
649
640
  const key = "a";
650
641
  const ttl = TimeSpan.fromMilliseconds(50);
651
- await lockProvider.create(key, { ttl }).acquire();
642
+ await lockFactory.create(key, { ttl }).acquire();
652
643
  await delay(ttl);
653
- const result = await lockProvider
644
+ const result = await lockFactory
654
645
  .create(key, { ttl })
655
646
  .acquire();
656
647
  expect(result).toBe(true);
657
648
  });
658
- test("Should return true when key is unexpireable and acquired by same lockId", async () => {
649
+ test("Should return true when key is unexpireable and acquired by same lock-id", async () => {
659
650
  const key = "a";
660
651
  const ttl = null;
661
- const lock = lockProvider.create(key, { ttl });
652
+ const lock = lockFactory.create(key, { ttl });
662
653
  await lock.acquire();
663
654
  const result = await lock.acquire();
664
655
  expect(result).toBe(true);
665
656
  });
666
- test("Should return true when key is unexpired and acquired by same lockId", async () => {
657
+ test("Should return true when key is unexpired and acquired by same lock-id", async () => {
667
658
  const key = "a";
668
659
  const ttl = TimeSpan.fromMilliseconds(50);
669
- const lock = lockProvider.create(key, {
660
+ const lock = lockFactory.create(key, {
670
661
  ttl,
671
662
  });
672
663
  await lock.acquire();
673
664
  const result = await lock.acquire();
674
665
  expect(result).toBe(true);
675
666
  });
676
- test("Should return false when key is unexpireable and acquired by different lockId", async () => {
667
+ test("Should return false when key is unexpireable and acquired by different lock-id", async () => {
677
668
  const key = "a";
678
669
  const ttl = null;
679
- await lockProvider.create(key, { ttl }).acquire();
680
- const result = await lockProvider
670
+ await lockFactory.create(key, { ttl }).acquire();
671
+ const result = await lockFactory
681
672
  .create(key, { ttl })
682
673
  .acquire();
683
674
  expect(result).toBe(false);
684
675
  });
685
- test("Should return false when key is unexpired and acquired by different lockId", async () => {
676
+ test("Should return false when key is unexpired and acquired by different lock-id", async () => {
686
677
  const key = "a";
687
678
  const ttl = TimeSpan.fromMilliseconds(50);
688
- await lockProvider.create(key, { ttl }).acquire();
689
- const result = await lockProvider
679
+ await lockFactory.create(key, { ttl }).acquire();
680
+ const result = await lockFactory
690
681
  .create(key, { ttl })
691
682
  .acquire();
692
683
  expect(result).toBe(false);
@@ -696,57 +687,55 @@ export function lockProviderTestSuite(settings) {
696
687
  test("Should not throw error when key doesnt exists", async () => {
697
688
  const key = "a";
698
689
  const ttl = null;
699
- const result = lockProvider
690
+ const result = lockFactory
700
691
  .create(key, {
701
692
  ttl,
702
693
  })
703
694
  .acquireOrFail();
704
695
  await expect(result).resolves.toBeUndefined();
705
696
  });
706
- test("Should not throw error when key is expired", {
707
- retry: 10,
708
- }, async () => {
697
+ test("Should not throw error when key is expired", async () => {
709
698
  const key = "a";
710
699
  const ttl = TimeSpan.fromMilliseconds(50);
711
- await lockProvider.create(key, { ttl }).acquireOrFail();
700
+ await lockFactory.create(key, { ttl }).acquireOrFail();
712
701
  await delay(ttl);
713
- const result = lockProvider
702
+ const result = lockFactory
714
703
  .create(key, { ttl })
715
704
  .acquireOrFail();
716
705
  await expect(result).resolves.toBeUndefined();
717
706
  });
718
- test("Should not throw error when key is unexpireable and acquired by same lockId", async () => {
707
+ test("Should not throw error when key is unexpireable and acquired by same lock-id", async () => {
719
708
  const key = "a";
720
709
  const ttl = null;
721
- const lock = lockProvider.create(key, { ttl });
710
+ const lock = lockFactory.create(key, { ttl });
722
711
  await lock.acquireOrFail();
723
712
  const result = lock.acquireOrFail();
724
713
  await expect(result).resolves.toBeUndefined();
725
714
  });
726
- test("Should not throw error when key is unexpired and acquired by same lockId", async () => {
715
+ test("Should not throw error when key is unexpired and acquired by same lock-id", async () => {
727
716
  const key = "a";
728
717
  const ttl = TimeSpan.fromMilliseconds(50);
729
- const lock = lockProvider.create(key, {
718
+ const lock = lockFactory.create(key, {
730
719
  ttl,
731
720
  });
732
721
  await lock.acquireOrFail();
733
722
  const result = lock.acquireOrFail();
734
723
  await expect(result).resolves.toBeUndefined();
735
724
  });
736
- test("Should throw FailedAcquireLockError when key is unexpireable and acquired by different lockId", async () => {
725
+ test("Should throw FailedAcquireLockError when key is unexpireable and acquired by different lock-id", async () => {
737
726
  const key = "a";
738
727
  const ttl = null;
739
- await lockProvider.create(key, { ttl }).acquireOrFail();
740
- const result = lockProvider
728
+ await lockFactory.create(key, { ttl }).acquireOrFail();
729
+ const result = lockFactory
741
730
  .create(key, { ttl })
742
731
  .acquireOrFail();
743
732
  await expect(result).rejects.toBeInstanceOf(FailedAcquireLockError);
744
733
  });
745
- test("Should throw FailedAcquireLockError when key is unexpired and acquired by different lockId", async () => {
734
+ test("Should throw FailedAcquireLockError when key is unexpired and acquired by different lock-id", async () => {
746
735
  const key = "a";
747
736
  const ttl = TimeSpan.fromMilliseconds(50);
748
- await lockProvider.create(key, { ttl }).acquireOrFail();
749
- const result = lockProvider
737
+ await lockFactory.create(key, { ttl }).acquireOrFail();
738
+ const result = lockFactory
750
739
  .create(key, { ttl })
751
740
  .acquireOrFail();
752
741
  await expect(result).rejects.toBeInstanceOf(FailedAcquireLockError);
@@ -756,7 +745,7 @@ export function lockProviderTestSuite(settings) {
756
745
  test("Should return true when key doesnt exists", async () => {
757
746
  const key = "a";
758
747
  const ttl = null;
759
- const result = await lockProvider
748
+ const result = await lockFactory
760
749
  .create(key, {
761
750
  ttl,
762
751
  })
@@ -766,14 +755,12 @@ export function lockProviderTestSuite(settings) {
766
755
  });
767
756
  expect(result).toBe(true);
768
757
  });
769
- test("Should return true when key is expired", {
770
- retry: 10,
771
- }, async () => {
758
+ test("Should return true when key is expired", async () => {
772
759
  const key = "a";
773
760
  const ttl = TimeSpan.fromMilliseconds(50);
774
- await lockProvider.create(key, { ttl }).acquire();
761
+ await lockFactory.create(key, { ttl }).acquire();
775
762
  await delay(ttl);
776
- const result = await lockProvider
763
+ const result = await lockFactory
777
764
  .create(key, { ttl })
778
765
  .acquireBlocking({
779
766
  time: TimeSpan.fromMilliseconds(5),
@@ -781,10 +768,10 @@ export function lockProviderTestSuite(settings) {
781
768
  });
782
769
  expect(result).toBe(true);
783
770
  });
784
- test("Should return true when key is unexpireable and acquired by same lockId", async () => {
771
+ test("Should return true when key is unexpireable and acquired by same lock-id", async () => {
785
772
  const key = "a";
786
773
  const ttl = null;
787
- const lock = lockProvider.create(key, { ttl });
774
+ const lock = lockFactory.create(key, { ttl });
788
775
  await lock.acquire();
789
776
  const result = await lock.acquireBlocking({
790
777
  time: TimeSpan.fromMilliseconds(5),
@@ -792,10 +779,10 @@ export function lockProviderTestSuite(settings) {
792
779
  });
793
780
  expect(result).toBe(true);
794
781
  });
795
- test("Should return true when key is unexpired and acquired by same lockId", async () => {
782
+ test("Should return true when key is unexpired and acquired by same lock-id", async () => {
796
783
  const key = "a";
797
784
  const ttl = TimeSpan.fromMilliseconds(50);
798
- const lock = lockProvider.create(key, {
785
+ const lock = lockFactory.create(key, {
799
786
  ttl,
800
787
  });
801
788
  await lock.acquire();
@@ -805,11 +792,11 @@ export function lockProviderTestSuite(settings) {
805
792
  });
806
793
  expect(result).toBe(true);
807
794
  });
808
- test("Should return false when key is unexpireable and acquired by different lockId", async () => {
795
+ test("Should return false when key is unexpireable and acquired by different lock-id", async () => {
809
796
  const key = "a";
810
797
  const ttl = null;
811
- await lockProvider.create(key, { ttl }).acquire();
812
- const result = await lockProvider
798
+ await lockFactory.create(key, { ttl }).acquire();
799
+ const result = await lockFactory
813
800
  .create(key, { ttl })
814
801
  .acquireBlocking({
815
802
  time: TimeSpan.fromMilliseconds(5),
@@ -817,11 +804,11 @@ export function lockProviderTestSuite(settings) {
817
804
  });
818
805
  expect(result).toBe(false);
819
806
  });
820
- test("Should return false when key is unexpired and acquired by different lockId", async () => {
807
+ test("Should return false when key is unexpired and acquired by different lock-id", async () => {
821
808
  const key = "a";
822
809
  const ttl = TimeSpan.fromMilliseconds(50);
823
- await lockProvider.create(key, { ttl }).acquire();
824
- const result = await lockProvider
810
+ await lockFactory.create(key, { ttl }).acquire();
811
+ const result = await lockFactory
825
812
  .create(key, { ttl })
826
813
  .acquireBlocking({
827
814
  time: TimeSpan.fromMilliseconds(5),
@@ -829,16 +816,16 @@ export function lockProviderTestSuite(settings) {
829
816
  });
830
817
  expect(result).toBe(false);
831
818
  });
832
- test("Should retry acquire the lock", async () => {
819
+ test("Should retry acquire the lock", { retry }, async () => {
833
820
  const key = "a";
834
821
  const ttl = TimeSpan.fromMilliseconds(50);
835
- const lock1 = lockProvider.create(key, {
822
+ const lock1 = lockFactory.create(key, {
836
823
  ttl,
837
824
  });
838
825
  await lock1.acquire();
839
826
  const handlerFn = vi.fn(() => { });
840
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
841
- const lock2 = lockProvider.create(key, {
827
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
828
+ const lock2 = lockFactory.create(key, {
842
829
  ttl,
843
830
  });
844
831
  await lock2.acquireBlocking({
@@ -852,7 +839,7 @@ export function lockProviderTestSuite(settings) {
852
839
  test("Should not throw error when key doesnt exists", async () => {
853
840
  const key = "a";
854
841
  const ttl = null;
855
- const result = lockProvider
842
+ const result = lockFactory
856
843
  .create(key, {
857
844
  ttl,
858
845
  })
@@ -862,14 +849,12 @@ export function lockProviderTestSuite(settings) {
862
849
  });
863
850
  await expect(result).resolves.toBeUndefined();
864
851
  });
865
- test("Should not throw error when key is expired", {
866
- retry: 10,
867
- }, async () => {
852
+ test("Should not throw error when key is expired", async () => {
868
853
  const key = "a";
869
854
  const ttl = TimeSpan.fromMilliseconds(50);
870
- await lockProvider.create(key, { ttl }).acquire();
855
+ await lockFactory.create(key, { ttl }).acquire();
871
856
  await delay(ttl);
872
- const result = lockProvider
857
+ const result = lockFactory
873
858
  .create(key, { ttl })
874
859
  .acquireBlockingOrFail({
875
860
  time: TimeSpan.fromMilliseconds(5),
@@ -877,10 +862,10 @@ export function lockProviderTestSuite(settings) {
877
862
  });
878
863
  await expect(result).resolves.toBeUndefined();
879
864
  });
880
- test("Should not throw error when key is unexpireable and acquired by same lockId", async () => {
865
+ test("Should not throw error when key is unexpireable and acquired by same lock-id", async () => {
881
866
  const key = "a";
882
867
  const ttl = null;
883
- const lock = lockProvider.create(key, { ttl });
868
+ const lock = lockFactory.create(key, { ttl });
884
869
  await lock.acquire();
885
870
  const result = lock.acquireBlockingOrFail({
886
871
  time: TimeSpan.fromMilliseconds(5),
@@ -888,10 +873,10 @@ export function lockProviderTestSuite(settings) {
888
873
  });
889
874
  await expect(result).resolves.toBeUndefined();
890
875
  });
891
- test("Should not throw error when key is unexpired and acquired by same lockId", async () => {
876
+ test("Should not throw error when key is unexpired and acquired by same lock-id", async () => {
892
877
  const key = "a";
893
878
  const ttl = TimeSpan.fromMilliseconds(50);
894
- const lock = lockProvider.create(key, {
879
+ const lock = lockFactory.create(key, {
895
880
  ttl,
896
881
  });
897
882
  await lock.acquire();
@@ -901,11 +886,11 @@ export function lockProviderTestSuite(settings) {
901
886
  });
902
887
  await expect(result).resolves.toBeUndefined();
903
888
  });
904
- test("Should throw FailedAcquireLockError when key is unexpireable and acquired by different lockId", async () => {
889
+ test("Should throw FailedAcquireLockError when key is unexpireable and acquired by different lock-id", async () => {
905
890
  const key = "a";
906
891
  const ttl = null;
907
- await lockProvider.create(key, { ttl }).acquire();
908
- const result = lockProvider
892
+ await lockFactory.create(key, { ttl }).acquire();
893
+ const result = lockFactory
909
894
  .create(key, { ttl })
910
895
  .acquireBlockingOrFail({
911
896
  time: TimeSpan.fromMilliseconds(5),
@@ -913,11 +898,11 @@ export function lockProviderTestSuite(settings) {
913
898
  });
914
899
  await expect(result).rejects.toBeInstanceOf(FailedAcquireLockError);
915
900
  });
916
- test("Should throw FailedAcquireLockError when key is unexpired and acquired by different lockId", async () => {
901
+ test("Should throw FailedAcquireLockError when key is unexpired and acquired by different lock-id", async () => {
917
902
  const key = "a";
918
903
  const ttl = TimeSpan.fromMilliseconds(50);
919
- await lockProvider.create(key, { ttl }).acquire();
920
- const result = lockProvider
904
+ await lockFactory.create(key, { ttl }).acquire();
905
+ const result = lockFactory
921
906
  .create(key, { ttl })
922
907
  .acquireBlockingOrFail({
923
908
  time: TimeSpan.fromMilliseconds(5),
@@ -925,16 +910,16 @@ export function lockProviderTestSuite(settings) {
925
910
  });
926
911
  await expect(result).rejects.toBeInstanceOf(FailedAcquireLockError);
927
912
  });
928
- test("Should retry acquire the lock", async () => {
913
+ test("Should retry acquire the lock", { retry }, async () => {
929
914
  const key = "a";
930
915
  const ttl = TimeSpan.fromMilliseconds(50);
931
- const lock1 = lockProvider.create(key, {
916
+ const lock1 = lockFactory.create(key, {
932
917
  ttl,
933
918
  });
934
919
  await lock1.acquire();
935
920
  const handlerFn = vi.fn(() => { });
936
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
937
- const lock2 = lockProvider.create(key, {
921
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
922
+ const lock2 = lockFactory.create(key, {
938
923
  ttl,
939
924
  });
940
925
  try {
@@ -953,107 +938,103 @@ export function lockProviderTestSuite(settings) {
953
938
  test("Should return false when key doesnt exists", async () => {
954
939
  const key = "a";
955
940
  const ttl = null;
956
- const result = await lockProvider
941
+ const result = await lockFactory
957
942
  .create(key, {
958
943
  ttl,
959
944
  })
960
945
  .release();
961
946
  expect(result).toBe(false);
962
947
  });
963
- test("Should return false when key is unexpireable and released by different lockId", async () => {
948
+ test("Should return false when key is unexpireable and released by different lock-id", async () => {
964
949
  const key = "a";
965
950
  const ttl = null;
966
- await lockProvider.create(key, { ttl }).acquire();
967
- const result = await lockProvider
951
+ await lockFactory.create(key, { ttl }).acquire();
952
+ const result = await lockFactory
968
953
  .create(key, { ttl })
969
954
  .release();
970
955
  expect(result).toBe(false);
971
956
  });
972
- test("Should return false when key is unexpired and released by different lockId", async () => {
957
+ test("Should return false when key is unexpired and released by different lock-id", async () => {
973
958
  const key = "a";
974
959
  const ttl = TimeSpan.fromMilliseconds(50);
975
- await lockProvider.create(key, { ttl }).acquire();
976
- const result = await lockProvider
960
+ await lockFactory.create(key, { ttl }).acquire();
961
+ const result = await lockFactory
977
962
  .create(key, { ttl })
978
963
  .release();
979
964
  expect(result).toBe(false);
980
965
  });
981
- test("Should return false when key is expired and released by different lockId", {
982
- retry: 10,
983
- }, async () => {
966
+ test("Should return false when key is expired and released by different lock-id", async () => {
984
967
  const key = "a";
985
968
  const ttl = TimeSpan.fromMilliseconds(50);
986
- await lockProvider.create(key, { ttl }).acquire();
987
- const result = await lockProvider
969
+ await lockFactory.create(key, { ttl }).acquire();
970
+ const result = await lockFactory
988
971
  .create(key, { ttl })
989
972
  .release();
990
973
  await delay(ttl);
991
974
  expect(result).toBe(false);
992
975
  });
993
- test("Should return false when key is expired and released by same lockId", {
994
- retry: 10,
995
- }, async () => {
976
+ test("Should return false when key is expired and released by same lock-id", async () => {
996
977
  const key = "a";
997
978
  const ttl = TimeSpan.fromMilliseconds(50);
998
- const lock = lockProvider.create(key, { ttl });
979
+ const lock = lockFactory.create(key, { ttl });
999
980
  await lock.acquire();
1000
981
  await delay(ttl);
1001
982
  const result = await lock.release();
1002
983
  expect(result).toBe(false);
1003
984
  });
1004
- test("Should return true when key is unexpireable and released by same lockId", async () => {
985
+ test("Should return true when key is unexpireable and released by same lock-id", async () => {
1005
986
  const key = "a";
1006
987
  const ttl = null;
1007
- const lock = lockProvider.create(key, { ttl });
988
+ const lock = lockFactory.create(key, { ttl });
1008
989
  await lock.acquire();
1009
990
  const result = await lock.release();
1010
991
  expect(result).toBe(true);
1011
992
  });
1012
- test("Should return true when key is unexpired and released by same lockId", async () => {
993
+ test("Should return true when key is unexpired and released by same lock-id", async () => {
1013
994
  const key = "a";
1014
995
  const ttl = TimeSpan.fromMilliseconds(50);
1015
- const lock = lockProvider.create(key, { ttl });
996
+ const lock = lockFactory.create(key, { ttl });
1016
997
  await lock.acquire();
1017
998
  const result = await lock.release();
1018
999
  expect(result).toBe(true);
1019
1000
  });
1020
- test("Should not be reacquirable when key is unexpireable and released by different lockId", async () => {
1001
+ test("Should not be reacquirable when key is unexpireable and released by different lock-id", async () => {
1021
1002
  const key = "a";
1022
1003
  const ttl = null;
1023
- const lock1 = lockProvider.create(key, { ttl });
1004
+ const lock1 = lockFactory.create(key, { ttl });
1024
1005
  await lock1.acquire();
1025
- const lock2 = lockProvider.create(key, { ttl });
1006
+ const lock2 = lockFactory.create(key, { ttl });
1026
1007
  await lock2.release();
1027
1008
  const result = await lock2.acquire();
1028
1009
  expect(result).toBe(false);
1029
1010
  });
1030
- test("Should not be reacquirable when key is unexpired and released by different lockId", async () => {
1011
+ test("Should not be reacquirable when key is unexpired and released by different lock-id", async () => {
1031
1012
  const key = "a";
1032
1013
  const ttl = TimeSpan.fromMilliseconds(50);
1033
- const lock1 = lockProvider.create(key, { ttl });
1014
+ const lock1 = lockFactory.create(key, { ttl });
1034
1015
  await lock1.acquire();
1035
- const lock2 = lockProvider.create(key, { ttl });
1016
+ const lock2 = lockFactory.create(key, { ttl });
1036
1017
  await lock2.release();
1037
1018
  const result = await lock2.acquire();
1038
1019
  expect(result).toBe(false);
1039
1020
  });
1040
- test("Should be reacquirable when key is unexpireable and released by same lockId", async () => {
1021
+ test("Should be reacquirable when key is unexpireable and released by same lock-id", async () => {
1041
1022
  const key = "a";
1042
1023
  const ttl = null;
1043
- const lock1 = lockProvider.create(key, { ttl });
1024
+ const lock1 = lockFactory.create(key, { ttl });
1044
1025
  await lock1.acquire();
1045
1026
  await lock1.release();
1046
- const lock2 = lockProvider.create(key, { ttl });
1027
+ const lock2 = lockFactory.create(key, { ttl });
1047
1028
  const result = await lock2.acquire();
1048
1029
  expect(result).toBe(true);
1049
1030
  });
1050
- test("Should be reacquirable when key is unexpired and released by same lockId", async () => {
1031
+ test("Should be reacquirable when key is unexpired and released by same lock-id", async () => {
1051
1032
  const key = "a";
1052
1033
  const ttl = TimeSpan.fromMilliseconds(50);
1053
- const lock1 = lockProvider.create(key, { ttl });
1034
+ const lock1 = lockFactory.create(key, { ttl });
1054
1035
  await lock1.acquire();
1055
1036
  await lock1.release();
1056
- const lock2 = lockProvider.create(key, { ttl });
1037
+ const lock2 = lockFactory.create(key, { ttl });
1057
1038
  const result = await lock2.acquire();
1058
1039
  expect(result).toBe(true);
1059
1040
  });
@@ -1062,76 +1043,72 @@ export function lockProviderTestSuite(settings) {
1062
1043
  test("Should throw FailedReleaseLockError when key doesnt exists", async () => {
1063
1044
  const key = "a";
1064
1045
  const ttl = null;
1065
- const result = lockProvider
1046
+ const result = lockFactory
1066
1047
  .create(key, {
1067
1048
  ttl,
1068
1049
  })
1069
1050
  .releaseOrFail();
1070
1051
  await expect(result).rejects.toBeInstanceOf(FailedReleaseLockError);
1071
1052
  });
1072
- test("Should throw FailedReleaseLockError when key is unexpireable and released by different lockId", async () => {
1053
+ test("Should throw FailedReleaseLockError when key is unexpireable and released by different lock-id", async () => {
1073
1054
  const key = "a";
1074
1055
  const ttl = null;
1075
- await lockProvider.create(key, { ttl }).acquire();
1076
- const result = lockProvider
1056
+ await lockFactory.create(key, { ttl }).acquire();
1057
+ const result = lockFactory
1077
1058
  .create(key, { ttl })
1078
1059
  .releaseOrFail();
1079
1060
  await expect(result).rejects.toBeInstanceOf(FailedReleaseLockError);
1080
1061
  });
1081
- test("Should throw FailedReleaseLockError when key is unexpired and released by different lockId", async () => {
1062
+ test("Should throw FailedReleaseLockError when key is unexpired and released by different lock-id", async () => {
1082
1063
  const key = "a";
1083
1064
  const ttl = TimeSpan.fromMilliseconds(50);
1084
- await lockProvider.create(key, { ttl }).acquire();
1085
- const result = lockProvider
1065
+ await lockFactory.create(key, { ttl }).acquire();
1066
+ const result = lockFactory
1086
1067
  .create(key, { ttl })
1087
1068
  .releaseOrFail();
1088
1069
  await expect(result).rejects.toBeInstanceOf(FailedReleaseLockError);
1089
1070
  });
1090
- test("Should throw FailedReleaseLockError when key is expired and released by different lockId", {
1091
- retry: 10,
1092
- }, async () => {
1071
+ test("Should throw FailedReleaseLockError when key is expired and released by different lock-id", async () => {
1093
1072
  const key = "a";
1094
1073
  const ttl = TimeSpan.fromMilliseconds(50);
1095
- await lockProvider.create(key, { ttl }).acquire();
1096
- const result = lockProvider
1074
+ await lockFactory.create(key, { ttl }).acquire();
1075
+ const result = lockFactory
1097
1076
  .create(key, { ttl })
1098
1077
  .releaseOrFail();
1099
1078
  await delay(ttl);
1100
1079
  await expect(result).rejects.toBeInstanceOf(FailedReleaseLockError);
1101
1080
  });
1102
- test("Should throw FailedReleaseLockError when key is expired and released by same lockId", {
1103
- retry: 10,
1104
- }, async () => {
1081
+ test("Should throw FailedReleaseLockError when key is expired and released by same lock-id", async () => {
1105
1082
  const key = "a";
1106
1083
  const ttl = TimeSpan.fromMilliseconds(50);
1107
- const lock = lockProvider.create(key, { ttl });
1084
+ const lock = lockFactory.create(key, { ttl });
1108
1085
  await lock.acquire();
1109
1086
  await delay(ttl);
1110
1087
  const result = lock.releaseOrFail();
1111
1088
  await expect(result).rejects.toBeInstanceOf(FailedReleaseLockError);
1112
1089
  });
1113
- test("Should not throw error when key is unexpireable and released by same lockId", async () => {
1090
+ test("Should not throw error when key is unexpireable and released by same lock-id", async () => {
1114
1091
  const key = "a";
1115
1092
  const ttl = null;
1116
- const lock = lockProvider.create(key, { ttl });
1093
+ const lock = lockFactory.create(key, { ttl });
1117
1094
  await lock.acquire();
1118
1095
  const result = lock.releaseOrFail();
1119
1096
  await expect(result).resolves.toBeUndefined();
1120
1097
  });
1121
- test("Should not throw error when key is unexpired and released by same lockId", async () => {
1098
+ test("Should not throw error when key is unexpired and released by same lock-id", async () => {
1122
1099
  const key = "a";
1123
1100
  const ttl = TimeSpan.fromMilliseconds(50);
1124
- const lock = lockProvider.create(key, { ttl });
1101
+ const lock = lockFactory.create(key, { ttl });
1125
1102
  await lock.acquire();
1126
1103
  const result = lock.releaseOrFail();
1127
1104
  await expect(result).resolves.toBeUndefined();
1128
1105
  });
1129
- test("Should not be reacquirable when key is unexpireable and released by different lockId", async () => {
1106
+ test("Should not be reacquirable when key is unexpireable and released by different lock-id", async () => {
1130
1107
  const key = "a";
1131
1108
  const ttl = null;
1132
- const lock1 = lockProvider.create(key, { ttl });
1109
+ const lock1 = lockFactory.create(key, { ttl });
1133
1110
  await lock1.acquire();
1134
- const lock2 = lockProvider.create(key, { ttl });
1111
+ const lock2 = lockFactory.create(key, { ttl });
1135
1112
  try {
1136
1113
  await lock2.releaseOrFail();
1137
1114
  }
@@ -1141,12 +1118,12 @@ export function lockProviderTestSuite(settings) {
1141
1118
  const result = await lock2.acquire();
1142
1119
  expect(result).toBe(false);
1143
1120
  });
1144
- test("Should not be reacquirable when key is unexpired and released by different lockId", async () => {
1121
+ test("Should not be reacquirable when key is unexpired and released by different lock-id", async () => {
1145
1122
  const key = "a";
1146
1123
  const ttl = TimeSpan.fromMilliseconds(50);
1147
- const lock1 = lockProvider.create(key, { ttl });
1124
+ const lock1 = lockFactory.create(key, { ttl });
1148
1125
  await lock1.acquire();
1149
- const lock2 = lockProvider.create(key, { ttl });
1126
+ const lock2 = lockFactory.create(key, { ttl });
1150
1127
  try {
1151
1128
  await lock2.releaseOrFail();
1152
1129
  }
@@ -1156,23 +1133,23 @@ export function lockProviderTestSuite(settings) {
1156
1133
  const result = await lock2.acquire();
1157
1134
  expect(result).toBe(false);
1158
1135
  });
1159
- test("Should be reacquirable when key is unexpireable and released by same lockId", async () => {
1136
+ test("Should be reacquirable when key is unexpireable and released by same lock-id", async () => {
1160
1137
  const key = "a";
1161
1138
  const ttl = null;
1162
- const lock1 = lockProvider.create(key, { ttl });
1139
+ const lock1 = lockFactory.create(key, { ttl });
1163
1140
  await lock1.acquire();
1164
1141
  await lock1.releaseOrFail();
1165
- const lock2 = lockProvider.create(key, { ttl });
1142
+ const lock2 = lockFactory.create(key, { ttl });
1166
1143
  const result = await lock2.acquire();
1167
1144
  expect(result).toBe(true);
1168
1145
  });
1169
- test("Should be reacquirable when key is unexpired and released by same lockId", async () => {
1146
+ test("Should be reacquirable when key is unexpired and released by same lock-id", async () => {
1170
1147
  const key = "a";
1171
1148
  const ttl = TimeSpan.fromMilliseconds(50);
1172
- const lock1 = lockProvider.create(key, { ttl });
1149
+ const lock1 = lockFactory.create(key, { ttl });
1173
1150
  await lock1.acquire();
1174
1151
  await lock1.releaseOrFail();
1175
- const lock2 = lockProvider.create(key, { ttl });
1152
+ const lock2 = lockFactory.create(key, { ttl });
1176
1153
  const result = await lock2.acquire();
1177
1154
  expect(result).toBe(true);
1178
1155
  });
@@ -1181,19 +1158,17 @@ export function lockProviderTestSuite(settings) {
1181
1158
  test("Should return false when key doesnt exists", async () => {
1182
1159
  const key = "a";
1183
1160
  const ttl = null;
1184
- const result = await lockProvider
1161
+ const result = await lockFactory
1185
1162
  .create(key, {
1186
1163
  ttl,
1187
1164
  })
1188
1165
  .forceRelease();
1189
1166
  expect(result).toBe(false);
1190
1167
  });
1191
- test("Should return false when key is expired", {
1192
- retry: 10,
1193
- }, async () => {
1168
+ test("Should return false when key is expired", async () => {
1194
1169
  const key = "a";
1195
1170
  const ttl = TimeSpan.fromMilliseconds(50);
1196
- const lock = lockProvider.create(key, {
1171
+ const lock = lockFactory.create(key, {
1197
1172
  ttl,
1198
1173
  });
1199
1174
  await lock.acquire();
@@ -1204,7 +1179,7 @@ export function lockProviderTestSuite(settings) {
1204
1179
  test("Should return true when key is unexpired", async () => {
1205
1180
  const key = "a";
1206
1181
  const ttl = TimeSpan.fromMilliseconds(50);
1207
- const lock = lockProvider.create(key, { ttl });
1182
+ const lock = lockFactory.create(key, { ttl });
1208
1183
  await lock.acquire();
1209
1184
  const result = await lock.forceRelease();
1210
1185
  expect(result).toBe(true);
@@ -1212,7 +1187,7 @@ export function lockProviderTestSuite(settings) {
1212
1187
  test("Should return true when key is unexpireable", async () => {
1213
1188
  const key = "a";
1214
1189
  const ttl = null;
1215
- const lock = lockProvider.create(key, { ttl });
1190
+ const lock = lockFactory.create(key, { ttl });
1216
1191
  await lock.acquire();
1217
1192
  const result = await lock.forceRelease();
1218
1193
  expect(result).toBe(true);
@@ -1220,7 +1195,7 @@ export function lockProviderTestSuite(settings) {
1220
1195
  test("Should be reacquirable when key is unexpired", async () => {
1221
1196
  const key = "a";
1222
1197
  const ttl = TimeSpan.fromMilliseconds(50);
1223
- const lock = lockProvider.create(key, { ttl });
1198
+ const lock = lockFactory.create(key, { ttl });
1224
1199
  await lock.acquire();
1225
1200
  await lock.forceRelease();
1226
1201
  const result = await lock.acquire();
@@ -1229,7 +1204,7 @@ export function lockProviderTestSuite(settings) {
1229
1204
  test("Should be reacquirable when key is unexpireable", async () => {
1230
1205
  const key = "a";
1231
1206
  const ttl = null;
1232
- const lock = lockProvider.create(key, { ttl });
1207
+ const lock = lockFactory.create(key, { ttl });
1233
1208
  await lock.acquire();
1234
1209
  await lock.forceRelease();
1235
1210
  const result = await lock.acquire();
@@ -1241,52 +1216,48 @@ export function lockProviderTestSuite(settings) {
1241
1216
  const key = "a";
1242
1217
  const ttl = null;
1243
1218
  const newTtl = TimeSpan.fromMinutes(1);
1244
- const result = await lockProvider
1219
+ const result = await lockFactory
1245
1220
  .create(key, {
1246
1221
  ttl,
1247
1222
  })
1248
1223
  .refresh(newTtl);
1249
1224
  expect(result).toBe(false);
1250
1225
  });
1251
- test("Should return false when key is unexpireable and refreshed by different lockId", async () => {
1226
+ test("Should return false when key is unexpireable and refreshed by different lock-id", async () => {
1252
1227
  const key = "a";
1253
1228
  const ttl = null;
1254
- const lock1 = lockProvider.create(key, { ttl });
1229
+ const lock1 = lockFactory.create(key, { ttl });
1255
1230
  await lock1.acquire();
1256
1231
  const newTtl = TimeSpan.fromMinutes(1);
1257
- const lock2 = lockProvider.create(key, { ttl });
1232
+ const lock2 = lockFactory.create(key, { ttl });
1258
1233
  const result = await lock2.refresh(newTtl);
1259
1234
  expect(result).toBe(false);
1260
1235
  });
1261
- test("Should return false when key is unexpired and refreshed by different lockId", async () => {
1236
+ test("Should return false when key is unexpired and refreshed by different lock-id", async () => {
1262
1237
  const key = "a";
1263
1238
  const ttl = TimeSpan.fromMilliseconds(50);
1264
- const lock1 = lockProvider.create(key, { ttl });
1239
+ const lock1 = lockFactory.create(key, { ttl });
1265
1240
  await lock1.acquire();
1266
1241
  const newTtl = TimeSpan.fromMinutes(1);
1267
- const lock2 = lockProvider.create(key, { ttl });
1242
+ const lock2 = lockFactory.create(key, { ttl });
1268
1243
  const result = await lock2.refresh(newTtl);
1269
1244
  expect(result).toBe(false);
1270
1245
  });
1271
- test("Should return false when key is expired and refreshed by different lockId", {
1272
- retry: 10,
1273
- }, async () => {
1246
+ test("Should return false when key is expired and refreshed by different lock-id", async () => {
1274
1247
  const key = "a";
1275
1248
  const ttl = TimeSpan.fromMilliseconds(50);
1276
- const lock1 = lockProvider.create(key, { ttl });
1249
+ const lock1 = lockFactory.create(key, { ttl });
1277
1250
  await lock1.acquire();
1278
1251
  await delay(ttl);
1279
1252
  const newTtl = TimeSpan.fromMinutes(1);
1280
- const lock2 = lockProvider.create(key, { ttl });
1253
+ const lock2 = lockFactory.create(key, { ttl });
1281
1254
  const result = await lock2.refresh(newTtl);
1282
1255
  expect(result).toBe(false);
1283
1256
  });
1284
- test("Should return false when key is expired and refreshed by same lockId", {
1285
- retry: 10,
1286
- }, async () => {
1257
+ test("Should return false when key is expired and refreshed by same lock-id", async () => {
1287
1258
  const key = "a";
1288
1259
  const ttl = TimeSpan.fromMilliseconds(50);
1289
- const lock = lockProvider.create(key, {
1260
+ const lock = lockFactory.create(key, {
1290
1261
  ttl,
1291
1262
  });
1292
1263
  await lock.acquire();
@@ -1295,49 +1266,45 @@ export function lockProviderTestSuite(settings) {
1295
1266
  const result = await lock.refresh(newTtl);
1296
1267
  expect(result).toBe(false);
1297
1268
  });
1298
- test("Should return false when key is unexpireable and refreshed by same lockId", async () => {
1269
+ test("Should return false when key is unexpireable and refreshed by same lock-id", async () => {
1299
1270
  const key = "a";
1300
1271
  const ttl = null;
1301
- const lock = lockProvider.create(key, { ttl });
1272
+ const lock = lockFactory.create(key, { ttl });
1302
1273
  await lock.acquire();
1303
1274
  const newTtl = TimeSpan.fromMinutes(1);
1304
1275
  const result = await lock.refresh(newTtl);
1305
1276
  expect(result).toBe(false);
1306
1277
  });
1307
- test("Should return true when key is unexpired and refreshed by same lockId", async () => {
1278
+ test("Should return true when key is unexpired and refreshed by same lock-id", async () => {
1308
1279
  const key = "a";
1309
1280
  const ttl = TimeSpan.fromMilliseconds(50);
1310
- const lock = lockProvider.create(key, { ttl });
1281
+ const lock = lockFactory.create(key, { ttl });
1311
1282
  await lock.acquire();
1312
1283
  const newTtl = TimeSpan.fromMinutes(1);
1313
1284
  const result = await lock.refresh(newTtl);
1314
1285
  expect(result).toBe(true);
1315
1286
  });
1316
- test("Should not update expiration when key is unexpireable and refreshed by same lockId", {
1317
- retry: 10,
1318
- }, async () => {
1287
+ test("Should not update expiration when key is unexpireable and refreshed by same lock-id", async () => {
1319
1288
  const key = "a";
1320
1289
  const ttl = null;
1321
- const lock1 = lockProvider.create(key, { ttl });
1290
+ const lock1 = lockFactory.create(key, { ttl });
1322
1291
  await lock1.acquire();
1323
1292
  const newTtl = TimeSpan.fromMilliseconds(50);
1324
1293
  await lock1.refresh(newTtl);
1325
1294
  await delay(newTtl);
1326
- const lock2 = lockProvider.create(key, { ttl });
1295
+ const lock2 = lockFactory.create(key, { ttl });
1327
1296
  const result = await lock2.acquire();
1328
1297
  expect(result).toBe(false);
1329
1298
  });
1330
- test("Should update expiration when key is unexpired and refreshed by same lockId", {
1331
- retry: 10,
1332
- }, async () => {
1299
+ test("Should update expiration when key is unexpired and refreshed by same lock-id", async () => {
1333
1300
  const key = "a";
1334
1301
  const ttl = TimeSpan.fromMilliseconds(50);
1335
- const lock1 = lockProvider.create(key, { ttl });
1302
+ const lock1 = lockFactory.create(key, { ttl });
1336
1303
  await lock1.acquire();
1337
1304
  const newTtl = TimeSpan.fromMilliseconds(100);
1338
1305
  await lock1.refresh(newTtl);
1339
1306
  await delay(newTtl.divide(2));
1340
- const lock2 = lockProvider.create(key, { ttl });
1307
+ const lock2 = lockFactory.create(key, { ttl });
1341
1308
  const result1 = await lock2.acquire();
1342
1309
  expect(result1).toBe(false);
1343
1310
  await delay(newTtl.divide(2));
@@ -1350,52 +1317,48 @@ export function lockProviderTestSuite(settings) {
1350
1317
  const key = "a";
1351
1318
  const ttl = null;
1352
1319
  const newTtl = TimeSpan.fromMinutes(1);
1353
- const result = lockProvider
1320
+ const result = lockFactory
1354
1321
  .create(key, {
1355
1322
  ttl,
1356
1323
  })
1357
1324
  .refreshOrFail(newTtl);
1358
1325
  await expect(result).rejects.toBeInstanceOf(FailedRefreshLockError);
1359
1326
  });
1360
- test("Should throw FailedRefreshLockError when key is unexpireable and refreshed by different lockId", async () => {
1327
+ test("Should throw FailedRefreshLockError when key is unexpireable and refreshed by different lock-id", async () => {
1361
1328
  const key = "a";
1362
1329
  const ttl = null;
1363
- const lock1 = lockProvider.create(key, { ttl });
1330
+ const lock1 = lockFactory.create(key, { ttl });
1364
1331
  await lock1.acquire();
1365
1332
  const newTtl = TimeSpan.fromMinutes(1);
1366
- const lock2 = lockProvider.create(key, { ttl });
1333
+ const lock2 = lockFactory.create(key, { ttl });
1367
1334
  const result = lock2.refreshOrFail(newTtl);
1368
1335
  await expect(result).rejects.toBeInstanceOf(FailedRefreshLockError);
1369
1336
  });
1370
- test("Should throw FailedRefreshLockError when key is unexpired and refreshed by different lockId", async () => {
1337
+ test("Should throw FailedRefreshLockError when key is unexpired and refreshed by different lock-id", async () => {
1371
1338
  const key = "a";
1372
1339
  const ttl = TimeSpan.fromMilliseconds(50);
1373
- const lock1 = lockProvider.create(key, { ttl });
1340
+ const lock1 = lockFactory.create(key, { ttl });
1374
1341
  await lock1.acquire();
1375
1342
  const newTtl = TimeSpan.fromMinutes(1);
1376
- const lock2 = lockProvider.create(key, { ttl });
1343
+ const lock2 = lockFactory.create(key, { ttl });
1377
1344
  const result = lock2.refreshOrFail(newTtl);
1378
1345
  await expect(result).rejects.toBeInstanceOf(FailedRefreshLockError);
1379
1346
  });
1380
- test("Should throw FailedRefreshLockError when key is expired and refreshed by different lockId", {
1381
- retry: 10,
1382
- }, async () => {
1347
+ test("Should throw FailedRefreshLockError when key is expired and refreshed by different lock-id", async () => {
1383
1348
  const key = "a";
1384
1349
  const ttl = TimeSpan.fromMilliseconds(50);
1385
- const lock1 = lockProvider.create(key, { ttl });
1350
+ const lock1 = lockFactory.create(key, { ttl });
1386
1351
  await lock1.acquire();
1387
1352
  await delay(ttl);
1388
1353
  const newTtl = TimeSpan.fromMinutes(1);
1389
- const lock2 = lockProvider.create(key, { ttl });
1354
+ const lock2 = lockFactory.create(key, { ttl });
1390
1355
  const result = lock2.refreshOrFail(newTtl);
1391
1356
  await expect(result).rejects.toBeInstanceOf(FailedRefreshLockError);
1392
1357
  });
1393
- test("Should throw FailedRefreshLockError when key is expired and refreshed by same lockId", {
1394
- retry: 10,
1395
- }, async () => {
1358
+ test("Should throw FailedRefreshLockError when key is expired and refreshed by same lock-id", async () => {
1396
1359
  const key = "a";
1397
1360
  const ttl = TimeSpan.fromMilliseconds(50);
1398
- const lock = lockProvider.create(key, {
1361
+ const lock = lockFactory.create(key, {
1399
1362
  ttl,
1400
1363
  });
1401
1364
  await lock.acquire();
@@ -1404,30 +1367,28 @@ export function lockProviderTestSuite(settings) {
1404
1367
  const result = lock.refreshOrFail(newTtl);
1405
1368
  await expect(result).rejects.toBeInstanceOf(FailedRefreshLockError);
1406
1369
  });
1407
- test("Should throw FailedRefreshLockError when key is unexpireable and refreshed by same lockId", async () => {
1370
+ test("Should throw FailedRefreshLockError when key is unexpireable and refreshed by same lock-id", async () => {
1408
1371
  const key = "a";
1409
1372
  const ttl = null;
1410
- const lock = lockProvider.create(key, { ttl });
1373
+ const lock = lockFactory.create(key, { ttl });
1411
1374
  await lock.acquire();
1412
1375
  const newTtl = TimeSpan.fromMinutes(1);
1413
1376
  const result = lock.refreshOrFail(newTtl);
1414
1377
  await expect(result).rejects.toBeInstanceOf(FailedRefreshLockError);
1415
1378
  });
1416
- test("Should not throw error when key is unexpired and refreshed by same lockId", async () => {
1379
+ test("Should not throw error when key is unexpired and refreshed by same lock-id", async () => {
1417
1380
  const key = "a";
1418
1381
  const ttl = TimeSpan.fromMilliseconds(50);
1419
- const lock = lockProvider.create(key, { ttl });
1382
+ const lock = lockFactory.create(key, { ttl });
1420
1383
  await lock.acquire();
1421
1384
  const newTtl = TimeSpan.fromMinutes(1);
1422
1385
  const result = lock.refreshOrFail(newTtl);
1423
1386
  await expect(result).resolves.toBeUndefined();
1424
1387
  });
1425
- test("Should not update expiration when key is unexpireable and refreshed by same lockId", {
1426
- retry: 10,
1427
- }, async () => {
1388
+ test("Should not update expiration when key is unexpireable and refreshed by same lock-id", async () => {
1428
1389
  const key = "a";
1429
1390
  const ttl = null;
1430
- const lock1 = lockProvider.create(key, { ttl });
1391
+ const lock1 = lockFactory.create(key, { ttl });
1431
1392
  await lock1.acquire();
1432
1393
  const newTtl = TimeSpan.fromMilliseconds(50);
1433
1394
  try {
@@ -1437,21 +1398,19 @@ export function lockProviderTestSuite(settings) {
1437
1398
  /* EMPTY */
1438
1399
  }
1439
1400
  await delay(newTtl);
1440
- const lock2 = lockProvider.create(key, { ttl });
1401
+ const lock2 = lockFactory.create(key, { ttl });
1441
1402
  const result = await lock2.acquire();
1442
1403
  expect(result).toBe(false);
1443
1404
  });
1444
- test("Should update expiration when key is unexpired and refreshed by same lockId", {
1445
- retry: 10,
1446
- }, async () => {
1405
+ test("Should update expiration when key is unexpired and refreshed by same lock-id", async () => {
1447
1406
  const key = "a";
1448
1407
  const ttl = TimeSpan.fromMilliseconds(50);
1449
- const lock1 = lockProvider.create(key, { ttl });
1408
+ const lock1 = lockFactory.create(key, { ttl });
1450
1409
  await lock1.acquire();
1451
1410
  const newTtl = TimeSpan.fromMilliseconds(100);
1452
1411
  await lock1.refreshOrFail(newTtl);
1453
1412
  await delay(newTtl.divide(2));
1454
- const lock2 = lockProvider.create(key, { ttl });
1413
+ const lock2 = lockFactory.create(key, { ttl });
1455
1414
  const result1 = await lock2.acquire();
1456
1415
  expect(result1).toBe(false);
1457
1416
  await delay(newTtl.divide(2));
@@ -1463,7 +1422,7 @@ export function lockProviderTestSuite(settings) {
1463
1422
  test("Should return lock id of ILock instance", () => {
1464
1423
  const key = "a";
1465
1424
  const lockId = "1";
1466
- const lock = lockProvider.create(key, {
1425
+ const lock = lockFactory.create(key, {
1467
1426
  lockId,
1468
1427
  });
1469
1428
  expect(lock.id).toBe(lockId);
@@ -1471,7 +1430,7 @@ export function lockProviderTestSuite(settings) {
1471
1430
  test("Should return lock id of ILock instance implicitly", () => {
1472
1431
  const key = "a";
1473
1432
  const ttl = null;
1474
- const lock = lockProvider.create(key, {
1433
+ const lock = lockFactory.create(key, {
1475
1434
  ttl,
1476
1435
  });
1477
1436
  expect(lock.id).toBeTypeOf("string");
@@ -1482,7 +1441,7 @@ export function lockProviderTestSuite(settings) {
1482
1441
  test("Should return null when given null ttl", () => {
1483
1442
  const key = "a";
1484
1443
  const ttl = null;
1485
- const lock = lockProvider.create(key, {
1444
+ const lock = lockFactory.create(key, {
1486
1445
  ttl,
1487
1446
  });
1488
1447
  expect(lock.ttl).toBeNull();
@@ -1490,7 +1449,7 @@ export function lockProviderTestSuite(settings) {
1490
1449
  test("Should return TimeSpan when given TimeSpan", () => {
1491
1450
  const key = "a";
1492
1451
  const ttl = TimeSpan.fromMilliseconds(100);
1493
- const lock = lockProvider.create(key, {
1452
+ const lock = lockFactory.create(key, {
1494
1453
  ttl,
1495
1454
  });
1496
1455
  expect(lock.ttl).toBeInstanceOf(TimeSpan);
@@ -1501,7 +1460,7 @@ export function lockProviderTestSuite(settings) {
1501
1460
  test("Should return ILockExpiredState when key doesnt exists", async () => {
1502
1461
  const key = "a";
1503
1462
  const ttl = TimeSpan.fromMilliseconds(50);
1504
- const lock = lockProvider.create(key, {
1463
+ const lock = lockFactory.create(key, {
1505
1464
  ttl,
1506
1465
  });
1507
1466
  const result = await lock.getState();
@@ -1509,12 +1468,10 @@ export function lockProviderTestSuite(settings) {
1509
1468
  type: LOCK_STATE.EXPIRED,
1510
1469
  });
1511
1470
  });
1512
- test("Should return ILockExpiredState when key is expired", {
1513
- retry: 10,
1514
- }, async () => {
1471
+ test("Should return ILockExpiredState when key is expired", async () => {
1515
1472
  const key = "a";
1516
1473
  const ttl = TimeSpan.fromMilliseconds(50);
1517
- const lock = lockProvider.create(key, {
1474
+ const lock = lockFactory.create(key, {
1518
1475
  ttl,
1519
1476
  });
1520
1477
  await lock.acquire();
@@ -1527,12 +1484,12 @@ export function lockProviderTestSuite(settings) {
1527
1484
  test("Should return ILockExpiredState when key is released with forceRelease method", async () => {
1528
1485
  const key = "a";
1529
1486
  const ttl1 = null;
1530
- const lock1 = lockProvider.create(key, {
1487
+ const lock1 = lockFactory.create(key, {
1531
1488
  ttl: ttl1,
1532
1489
  });
1533
1490
  await lock1.acquire();
1534
1491
  const ttl2 = null;
1535
- const lock2 = lockProvider.create(key, {
1492
+ const lock2 = lockFactory.create(key, {
1536
1493
  ttl: ttl2,
1537
1494
  });
1538
1495
  await lock2.acquire();
@@ -1545,12 +1502,12 @@ export function lockProviderTestSuite(settings) {
1545
1502
  test("Should return ILockExpiredState when key is released with release method", async () => {
1546
1503
  const key = "a";
1547
1504
  const ttl1 = null;
1548
- const lock1 = lockProvider.create(key, {
1505
+ const lock1 = lockFactory.create(key, {
1549
1506
  ttl: ttl1,
1550
1507
  });
1551
1508
  await lock1.acquire();
1552
1509
  const ttl2 = null;
1553
- const lock2 = lockProvider.create(key, {
1510
+ const lock2 = lockFactory.create(key, {
1554
1511
  ttl: ttl2,
1555
1512
  });
1556
1513
  await lock2.acquire();
@@ -1564,7 +1521,7 @@ export function lockProviderTestSuite(settings) {
1564
1521
  test("Should return ILockAcquiredState when key is unexpireable", async () => {
1565
1522
  const key = "a";
1566
1523
  const ttl = null;
1567
- const lock = lockProvider.create(key, {
1524
+ const lock = lockFactory.create(key, {
1568
1525
  ttl,
1569
1526
  });
1570
1527
  await lock.acquire();
@@ -1575,9 +1532,12 @@ export function lockProviderTestSuite(settings) {
1575
1532
  });
1576
1533
  });
1577
1534
  test("Should return ILockAcquiredState when key is unexpired", async () => {
1535
+ expect.addEqualityTesters([
1536
+ createIsTimeSpanEqualityTester(timeSpanEqualityBuffer),
1537
+ ]);
1578
1538
  const key = "a";
1579
1539
  const ttl = TimeSpan.fromMilliseconds(50);
1580
- const lock = lockProvider.create(key, {
1540
+ const lock = lockFactory.create(key, {
1581
1541
  ttl,
1582
1542
  });
1583
1543
  await lock.acquire();
@@ -1587,14 +1547,14 @@ export function lockProviderTestSuite(settings) {
1587
1547
  remainingTime: ttl,
1588
1548
  });
1589
1549
  });
1590
- test("Should return ILockUnavailableState when key is acquired by different owner", async () => {
1550
+ test("Should return ILockUnavailableState when key is acquired by different lock-id", async () => {
1591
1551
  const key = "a";
1592
1552
  const ttl = null;
1593
- const lock1 = lockProvider.create(key, {
1553
+ const lock1 = lockFactory.create(key, {
1594
1554
  ttl,
1595
1555
  });
1596
1556
  await lock1.acquire();
1597
- const lock2 = lockProvider.create(key, {
1557
+ const lock2 = lockFactory.create(key, {
1598
1558
  ttl,
1599
1559
  });
1600
1560
  const state = await lock2.getState();
@@ -1610,11 +1570,11 @@ export function lockProviderTestSuite(settings) {
1610
1570
  test("Should dispatch AcquiredLockEvent when key doesnt exists", async () => {
1611
1571
  const key = "a";
1612
1572
  const ttl = null;
1613
- const lock = lockProvider.create(key, {
1573
+ const lock = lockFactory.create(key, {
1614
1574
  ttl,
1615
1575
  });
1616
1576
  const handlerFn = vi.fn((_event) => { });
1617
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1577
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1618
1578
  await lock.acquire();
1619
1579
  expect(handlerFn).toHaveBeenCalledTimes(1);
1620
1580
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -1626,16 +1586,14 @@ export function lockProviderTestSuite(settings) {
1626
1586
  }),
1627
1587
  }));
1628
1588
  });
1629
- test("Should dispatch AcquiredLockEvent when key is expired", {
1630
- retry: 10,
1631
- }, async () => {
1589
+ test("Should dispatch AcquiredLockEvent when key is expired", async () => {
1632
1590
  const key = "a";
1633
1591
  const ttl = TimeSpan.fromMilliseconds(50);
1634
- await lockProvider.create(key, { ttl }).acquire();
1592
+ await lockFactory.create(key, { ttl }).acquire();
1635
1593
  await delay(ttl);
1636
- const lock = lockProvider.create(key, { ttl });
1594
+ const lock = lockFactory.create(key, { ttl });
1637
1595
  const handlerFn = vi.fn((_event) => { });
1638
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1596
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1639
1597
  await lock.acquire();
1640
1598
  expect(handlerFn).toHaveBeenCalledTimes(1);
1641
1599
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -1647,13 +1605,13 @@ export function lockProviderTestSuite(settings) {
1647
1605
  }),
1648
1606
  }));
1649
1607
  });
1650
- test("Should dispatch AcquiredLockEvent when key is unexpireable and acquired by same lockId", async () => {
1608
+ test("Should dispatch AcquiredLockEvent when key is unexpireable and acquired by same lock-id", async () => {
1651
1609
  const key = "a";
1652
1610
  const ttl = null;
1653
- const lock = lockProvider.create(key, { ttl });
1611
+ const lock = lockFactory.create(key, { ttl });
1654
1612
  await lock.acquire();
1655
1613
  const handlerFn = vi.fn((_event) => { });
1656
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1614
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1657
1615
  await lock.acquire();
1658
1616
  expect(handlerFn).toHaveBeenCalledTimes(1);
1659
1617
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -1665,15 +1623,15 @@ export function lockProviderTestSuite(settings) {
1665
1623
  }),
1666
1624
  }));
1667
1625
  });
1668
- test("Should dispatch AcquiredLockEvent when key is unexpired and acquired by same lockId", async () => {
1626
+ test("Should dispatch AcquiredLockEvent when key is unexpired and acquired by same lock-id", async () => {
1669
1627
  const key = "a";
1670
1628
  const ttl = TimeSpan.fromMilliseconds(50);
1671
- const lock = lockProvider.create(key, {
1629
+ const lock = lockFactory.create(key, {
1672
1630
  ttl,
1673
1631
  });
1674
1632
  await lock.acquire();
1675
1633
  const handlerFn = vi.fn((_event) => { });
1676
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1634
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1677
1635
  await lock.acquire();
1678
1636
  expect(handlerFn).toHaveBeenCalledTimes(1);
1679
1637
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -1685,15 +1643,15 @@ export function lockProviderTestSuite(settings) {
1685
1643
  }),
1686
1644
  }));
1687
1645
  });
1688
- test("Should dispatch UnavailableLockEvent when key is unexpireable and acquired by different lockId", async () => {
1646
+ test("Should dispatch UnavailableLockEvent when key is unexpireable and acquired by different lock-id", async () => {
1689
1647
  const key = "a";
1690
1648
  const ttl = null;
1691
- await lockProvider.create(key, { ttl }).acquire();
1692
- const lock = lockProvider.create(key, {
1649
+ await lockFactory.create(key, { ttl }).acquire();
1650
+ const lock = lockFactory.create(key, {
1693
1651
  ttl,
1694
1652
  });
1695
1653
  const handlerFn = vi.fn((_event) => { });
1696
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1654
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1697
1655
  await lock.acquire();
1698
1656
  expect(handlerFn).toHaveBeenCalledTimes(1);
1699
1657
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -1705,13 +1663,13 @@ export function lockProviderTestSuite(settings) {
1705
1663
  }),
1706
1664
  }));
1707
1665
  });
1708
- test("Should dispatch UnavailableLockEvent when key is unexpired and acquired by different lockId", async () => {
1666
+ test("Should dispatch UnavailableLockEvent when key is unexpired and acquired by different lock-id", async () => {
1709
1667
  const key = "a";
1710
1668
  const ttl = TimeSpan.fromMilliseconds(50);
1711
- await lockProvider.create(key, { ttl }).acquire();
1712
- const lock = lockProvider.create(key, { ttl });
1669
+ await lockFactory.create(key, { ttl }).acquire();
1670
+ const lock = lockFactory.create(key, { ttl });
1713
1671
  const handlerFn = vi.fn((_event) => { });
1714
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1672
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1715
1673
  await lock.acquire();
1716
1674
  expect(handlerFn).toHaveBeenCalledTimes(1);
1717
1675
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -1728,11 +1686,11 @@ export function lockProviderTestSuite(settings) {
1728
1686
  test("Should dispatch AcquiredLockEvent when key doesnt exists", async () => {
1729
1687
  const key = "a";
1730
1688
  const ttl = null;
1731
- const lock = lockProvider.create(key, {
1689
+ const lock = lockFactory.create(key, {
1732
1690
  ttl,
1733
1691
  });
1734
1692
  const handlerFn = vi.fn((_event) => { });
1735
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1693
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1736
1694
  await lock.acquireOrFail();
1737
1695
  expect(handlerFn).toHaveBeenCalledTimes(1);
1738
1696
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -1744,16 +1702,14 @@ export function lockProviderTestSuite(settings) {
1744
1702
  }),
1745
1703
  }));
1746
1704
  });
1747
- test("Should dispatch AcquiredLockEvent when key is expired", {
1748
- retry: 10,
1749
- }, async () => {
1705
+ test("Should dispatch AcquiredLockEvent when key is expired", async () => {
1750
1706
  const key = "a";
1751
1707
  const ttl = TimeSpan.fromMilliseconds(50);
1752
- await lockProvider.create(key, { ttl }).acquire();
1708
+ await lockFactory.create(key, { ttl }).acquire();
1753
1709
  await delay(ttl);
1754
- const lock = lockProvider.create(key, { ttl });
1710
+ const lock = lockFactory.create(key, { ttl });
1755
1711
  const handlerFn = vi.fn((_event) => { });
1756
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1712
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1757
1713
  await lock.acquireOrFail();
1758
1714
  expect(handlerFn).toHaveBeenCalledTimes(1);
1759
1715
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -1765,13 +1721,13 @@ export function lockProviderTestSuite(settings) {
1765
1721
  }),
1766
1722
  }));
1767
1723
  });
1768
- test("Should dispatch AcquiredLockEvent when key is unexpireable and acquired by same lockId", async () => {
1724
+ test("Should dispatch AcquiredLockEvent when key is unexpireable and acquired by same lock-id", async () => {
1769
1725
  const key = "a";
1770
1726
  const ttl = null;
1771
- const lock = lockProvider.create(key, { ttl });
1727
+ const lock = lockFactory.create(key, { ttl });
1772
1728
  await lock.acquire();
1773
1729
  const handlerFn = vi.fn((_event) => { });
1774
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1730
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1775
1731
  await lock.acquireOrFail();
1776
1732
  expect(handlerFn).toHaveBeenCalledTimes(1);
1777
1733
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -1783,15 +1739,15 @@ export function lockProviderTestSuite(settings) {
1783
1739
  }),
1784
1740
  }));
1785
1741
  });
1786
- test("Should dispatch AcquiredLockEvent when key is unexpired and acquired by same lockId", async () => {
1742
+ test("Should dispatch AcquiredLockEvent when key is unexpired and acquired by same lock-id", async () => {
1787
1743
  const key = "a";
1788
1744
  const ttl = TimeSpan.fromMilliseconds(50);
1789
- const lock = lockProvider.create(key, {
1745
+ const lock = lockFactory.create(key, {
1790
1746
  ttl,
1791
1747
  });
1792
1748
  await lock.acquire();
1793
1749
  const handlerFn = vi.fn((_event) => { });
1794
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1750
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1795
1751
  await lock.acquireOrFail();
1796
1752
  expect(handlerFn).toHaveBeenCalledTimes(1);
1797
1753
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -1803,15 +1759,15 @@ export function lockProviderTestSuite(settings) {
1803
1759
  }),
1804
1760
  }));
1805
1761
  });
1806
- test("Should dispatch UnavailableLockEvent when key is unexpireable and acquired by different lockId", async () => {
1762
+ test("Should dispatch UnavailableLockEvent when key is unexpireable and acquired by different lock-id", async () => {
1807
1763
  const key = "a";
1808
1764
  const ttl = null;
1809
- await lockProvider.create(key, { ttl }).acquire();
1810
- const lock = lockProvider.create(key, {
1765
+ await lockFactory.create(key, { ttl }).acquire();
1766
+ const lock = lockFactory.create(key, {
1811
1767
  ttl,
1812
1768
  });
1813
1769
  const handlerFn = vi.fn((_event) => { });
1814
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1770
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1815
1771
  try {
1816
1772
  await lock.acquireOrFail();
1817
1773
  }
@@ -1828,13 +1784,13 @@ export function lockProviderTestSuite(settings) {
1828
1784
  }),
1829
1785
  }));
1830
1786
  });
1831
- test("Should dispatch UnavailableLockEvent when key is unexpired and acquired by different lockId", async () => {
1787
+ test("Should dispatch UnavailableLockEvent when key is unexpired and acquired by different lock-id", async () => {
1832
1788
  const key = "a";
1833
1789
  const ttl = TimeSpan.fromMilliseconds(50);
1834
- await lockProvider.create(key, { ttl }).acquire();
1835
- const lock = lockProvider.create(key, { ttl });
1790
+ await lockFactory.create(key, { ttl }).acquire();
1791
+ const lock = lockFactory.create(key, { ttl });
1836
1792
  const handlerFn = vi.fn((_event) => { });
1837
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1793
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1838
1794
  try {
1839
1795
  await lock.acquireOrFail();
1840
1796
  }
@@ -1856,11 +1812,11 @@ export function lockProviderTestSuite(settings) {
1856
1812
  test("Should dispatch AcquiredLockEvent when key doesnt exists", async () => {
1857
1813
  const key = "a";
1858
1814
  const ttl = null;
1859
- const lock = lockProvider.create(key, {
1815
+ const lock = lockFactory.create(key, {
1860
1816
  ttl,
1861
1817
  });
1862
1818
  const handlerFn = vi.fn((_event) => { });
1863
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1819
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1864
1820
  await lock.acquireBlocking({
1865
1821
  time: TimeSpan.fromMilliseconds(5),
1866
1822
  interval: TimeSpan.fromMilliseconds(5),
@@ -1875,16 +1831,14 @@ export function lockProviderTestSuite(settings) {
1875
1831
  }),
1876
1832
  }));
1877
1833
  });
1878
- test("Should dispatch AcquiredLockEvent when key is expired", {
1879
- retry: 10,
1880
- }, async () => {
1834
+ test("Should dispatch AcquiredLockEvent when key is expired", async () => {
1881
1835
  const key = "a";
1882
1836
  const ttl = TimeSpan.fromMilliseconds(50);
1883
- await lockProvider.create(key, { ttl }).acquire();
1837
+ await lockFactory.create(key, { ttl }).acquire();
1884
1838
  await delay(ttl);
1885
- const lock = lockProvider.create(key, { ttl });
1839
+ const lock = lockFactory.create(key, { ttl });
1886
1840
  const handlerFn = vi.fn((_event) => { });
1887
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1841
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1888
1842
  await lock.acquireBlocking({
1889
1843
  time: TimeSpan.fromMilliseconds(5),
1890
1844
  interval: TimeSpan.fromMilliseconds(5),
@@ -1899,13 +1853,13 @@ export function lockProviderTestSuite(settings) {
1899
1853
  }),
1900
1854
  }));
1901
1855
  });
1902
- test("Should dispatch AcquiredLockEvent when key is unexpireable and acquired by same lockId", async () => {
1856
+ test("Should dispatch AcquiredLockEvent when key is unexpireable and acquired by same lock-id", async () => {
1903
1857
  const key = "a";
1904
1858
  const ttl = null;
1905
- const lock = lockProvider.create(key, { ttl });
1859
+ const lock = lockFactory.create(key, { ttl });
1906
1860
  await lock.acquire();
1907
1861
  const handlerFn = vi.fn((_event) => { });
1908
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1862
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1909
1863
  await lock.acquireBlocking({
1910
1864
  time: TimeSpan.fromMilliseconds(5),
1911
1865
  interval: TimeSpan.fromMilliseconds(5),
@@ -1920,15 +1874,15 @@ export function lockProviderTestSuite(settings) {
1920
1874
  }),
1921
1875
  }));
1922
1876
  });
1923
- test("Should dispatch AcquiredLockEvent when key is unexpired and acquired by same lockId", async () => {
1877
+ test("Should dispatch AcquiredLockEvent when key is unexpired and acquired by same lock-id", async () => {
1924
1878
  const key = "a";
1925
1879
  const ttl = TimeSpan.fromMilliseconds(50);
1926
- const lock = lockProvider.create(key, {
1880
+ const lock = lockFactory.create(key, {
1927
1881
  ttl,
1928
1882
  });
1929
1883
  await lock.acquire();
1930
1884
  const handlerFn = vi.fn((_event) => { });
1931
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1885
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1932
1886
  await lock.acquireBlocking({
1933
1887
  time: TimeSpan.fromMilliseconds(5),
1934
1888
  interval: TimeSpan.fromMilliseconds(5),
@@ -1943,20 +1897,21 @@ export function lockProviderTestSuite(settings) {
1943
1897
  }),
1944
1898
  }));
1945
1899
  });
1946
- test("Should dispatch UnavailableLockEvent when key is unexpireable and acquired by different lockId", async () => {
1900
+ test("Should dispatch UnavailableLockEvent when key is unexpireable and acquired by different lock-id", async () => {
1947
1901
  const key = "a";
1948
1902
  const ttl = null;
1949
- await lockProvider.create(key, { ttl }).acquire();
1950
- const lock = lockProvider.create(key, {
1903
+ await lockFactory.create(key, { ttl }).acquire();
1904
+ const lock = lockFactory.create(key, {
1951
1905
  ttl,
1952
1906
  });
1953
1907
  const handlerFn = vi.fn((_event) => { });
1954
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1908
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1955
1909
  await lock.acquireBlocking({
1956
1910
  time: TimeSpan.fromMilliseconds(5),
1957
1911
  interval: TimeSpan.fromMilliseconds(5),
1958
1912
  });
1959
- expect(handlerFn).toHaveBeenCalledTimes(1);
1913
+ expect(handlerFn.mock.calls.length).toBeGreaterThanOrEqual(1);
1914
+ expect(handlerFn.mock.calls.length).toBeLessThanOrEqual(4);
1960
1915
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
1961
1916
  lock: expect.objectContaining({
1962
1917
  getState: expect.any(Function),
@@ -1966,18 +1921,19 @@ export function lockProviderTestSuite(settings) {
1966
1921
  }),
1967
1922
  }));
1968
1923
  });
1969
- test("Should dispatch UnavailableLockEvent when key is unexpired and acquired by different lockId", async () => {
1924
+ test("Should dispatch UnavailableLockEvent when key is unexpired and acquired by different lock-id", async () => {
1970
1925
  const key = "a";
1971
1926
  const ttl = TimeSpan.fromMilliseconds(50);
1972
- await lockProvider.create(key, { ttl }).acquire();
1973
- const lock = lockProvider.create(key, { ttl });
1927
+ await lockFactory.create(key, { ttl }).acquire();
1928
+ const lock = lockFactory.create(key, { ttl });
1974
1929
  const handlerFn = vi.fn((_event) => { });
1975
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1930
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
1976
1931
  await lock.acquireBlocking({
1977
1932
  time: TimeSpan.fromMilliseconds(5),
1978
1933
  interval: TimeSpan.fromMilliseconds(5),
1979
1934
  });
1980
- expect(handlerFn).toHaveBeenCalledTimes(1);
1935
+ expect(handlerFn.mock.calls.length).toBeGreaterThanOrEqual(1);
1936
+ expect(handlerFn.mock.calls.length).toBeLessThanOrEqual(4);
1981
1937
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
1982
1938
  lock: expect.objectContaining({
1983
1939
  getState: expect.any(Function),
@@ -1992,11 +1948,11 @@ export function lockProviderTestSuite(settings) {
1992
1948
  test("Should dispatch AcquiredLockEvent when key doesnt exists", async () => {
1993
1949
  const key = "a";
1994
1950
  const ttl = null;
1995
- const lock = lockProvider.create(key, {
1951
+ const lock = lockFactory.create(key, {
1996
1952
  ttl,
1997
1953
  });
1998
1954
  const handlerFn = vi.fn((_event) => { });
1999
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1955
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
2000
1956
  await lock.acquireBlockingOrFail({
2001
1957
  time: TimeSpan.fromMilliseconds(5),
2002
1958
  interval: TimeSpan.fromMilliseconds(5),
@@ -2011,16 +1967,14 @@ export function lockProviderTestSuite(settings) {
2011
1967
  }),
2012
1968
  }));
2013
1969
  });
2014
- test("Should dispatch AcquiredLockEvent when key is expired", {
2015
- retry: 10,
2016
- }, async () => {
1970
+ test("Should dispatch AcquiredLockEvent when key is expired", async () => {
2017
1971
  const key = "a";
2018
1972
  const ttl = TimeSpan.fromMilliseconds(50);
2019
- await lockProvider.create(key, { ttl }).acquire();
1973
+ await lockFactory.create(key, { ttl }).acquire();
2020
1974
  await delay(ttl);
2021
- const lock = lockProvider.create(key, { ttl });
1975
+ const lock = lockFactory.create(key, { ttl });
2022
1976
  const handlerFn = vi.fn((_event) => { });
2023
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1977
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
2024
1978
  await lock.acquireBlockingOrFail({
2025
1979
  time: TimeSpan.fromMilliseconds(5),
2026
1980
  interval: TimeSpan.fromMilliseconds(5),
@@ -2035,13 +1989,13 @@ export function lockProviderTestSuite(settings) {
2035
1989
  }),
2036
1990
  }));
2037
1991
  });
2038
- test("Should dispatch AcquiredLockEvent when key is unexpireable and acquired by same lockId", async () => {
1992
+ test("Should dispatch AcquiredLockEvent when key is unexpireable and acquired by same lock-id", async () => {
2039
1993
  const key = "a";
2040
1994
  const ttl = null;
2041
- const lock = lockProvider.create(key, { ttl });
1995
+ const lock = lockFactory.create(key, { ttl });
2042
1996
  await lock.acquire();
2043
1997
  const handlerFn = vi.fn((_event) => { });
2044
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
1998
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
2045
1999
  await lock.acquireBlockingOrFail({
2046
2000
  time: TimeSpan.fromMilliseconds(5),
2047
2001
  interval: TimeSpan.fromMilliseconds(5),
@@ -2056,15 +2010,15 @@ export function lockProviderTestSuite(settings) {
2056
2010
  }),
2057
2011
  }));
2058
2012
  });
2059
- test("Should dispatch AcquiredLockEvent when key is unexpired and acquired by same lockId", async () => {
2013
+ test("Should dispatch AcquiredLockEvent when key is unexpired and acquired by same lock-id", async () => {
2060
2014
  const key = "a";
2061
2015
  const ttl = TimeSpan.fromMilliseconds(50);
2062
- const lock = lockProvider.create(key, {
2016
+ const lock = lockFactory.create(key, {
2063
2017
  ttl,
2064
2018
  });
2065
2019
  await lock.acquire();
2066
2020
  const handlerFn = vi.fn((_event) => { });
2067
- await lockProvider.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
2021
+ await lockFactory.events.addListener(LOCK_EVENTS.ACQUIRED, handlerFn);
2068
2022
  await lock.acquireBlockingOrFail({
2069
2023
  time: TimeSpan.fromMilliseconds(5),
2070
2024
  interval: TimeSpan.fromMilliseconds(5),
@@ -2079,15 +2033,15 @@ export function lockProviderTestSuite(settings) {
2079
2033
  }),
2080
2034
  }));
2081
2035
  });
2082
- test("Should dispatch UnavailableLockEvent when key is unexpireable and acquired by different lockId", async () => {
2036
+ test("Should dispatch UnavailableLockEvent when key is unexpireable and acquired by different lock-id", async () => {
2083
2037
  const key = "a";
2084
2038
  const ttl = null;
2085
- await lockProvider.create(key, { ttl }).acquire();
2086
- const lock = lockProvider.create(key, {
2039
+ await lockFactory.create(key, { ttl }).acquire();
2040
+ const lock = lockFactory.create(key, {
2087
2041
  ttl,
2088
2042
  });
2089
2043
  const handlerFn = vi.fn((_event) => { });
2090
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
2044
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
2091
2045
  try {
2092
2046
  await lock.acquireBlockingOrFail({
2093
2047
  time: TimeSpan.fromMilliseconds(5),
@@ -2097,7 +2051,8 @@ export function lockProviderTestSuite(settings) {
2097
2051
  catch {
2098
2052
  /* EMPTY */
2099
2053
  }
2100
- expect(handlerFn).toHaveBeenCalledTimes(1);
2054
+ expect(handlerFn.mock.calls.length).toBeGreaterThanOrEqual(1);
2055
+ expect(handlerFn.mock.calls.length).toBeLessThanOrEqual(4);
2101
2056
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
2102
2057
  lock: expect.objectContaining({
2103
2058
  getState: expect.any(Function),
@@ -2107,13 +2062,13 @@ export function lockProviderTestSuite(settings) {
2107
2062
  }),
2108
2063
  }));
2109
2064
  });
2110
- test("Should dispatch UnavailableLockEvent when key is unexpired and acquired by different lockId", async () => {
2065
+ test("Should dispatch UnavailableLockEvent when key is unexpired and acquired by different lock-id", async () => {
2111
2066
  const key = "a";
2112
2067
  const ttl = TimeSpan.fromMilliseconds(50);
2113
- await lockProvider.create(key, { ttl }).acquire();
2114
- const lock = lockProvider.create(key, { ttl });
2068
+ await lockFactory.create(key, { ttl }).acquire();
2069
+ const lock = lockFactory.create(key, { ttl });
2115
2070
  const handlerFn = vi.fn((_event) => { });
2116
- await lockProvider.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
2071
+ await lockFactory.events.addListener(LOCK_EVENTS.UNAVAILABLE, handlerFn);
2117
2072
  try {
2118
2073
  await lock.acquireBlockingOrFail({
2119
2074
  time: TimeSpan.fromMilliseconds(5),
@@ -2123,7 +2078,8 @@ export function lockProviderTestSuite(settings) {
2123
2078
  catch {
2124
2079
  /* EMPTY */
2125
2080
  }
2126
- expect(handlerFn).toHaveBeenCalledTimes(1);
2081
+ expect(handlerFn.mock.calls.length).toBeGreaterThanOrEqual(1);
2082
+ expect(handlerFn.mock.calls.length).toBeLessThanOrEqual(4);
2127
2083
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
2128
2084
  lock: expect.objectContaining({
2129
2085
  getState: expect.any(Function),
@@ -2138,11 +2094,11 @@ export function lockProviderTestSuite(settings) {
2138
2094
  test("Should dispatch ForceReleasedLockEvent when key doesnt exists", async () => {
2139
2095
  const key = "a";
2140
2096
  const ttl = null;
2141
- const lock = lockProvider.create(key, {
2097
+ const lock = lockFactory.create(key, {
2142
2098
  ttl,
2143
2099
  });
2144
2100
  const handlerFn = vi.fn((_event) => { });
2145
- await lockProvider.events.addListener(LOCK_EVENTS.FORCE_RELEASED, handlerFn);
2101
+ await lockFactory.events.addListener(LOCK_EVENTS.FORCE_RELEASED, handlerFn);
2146
2102
  await lock.forceRelease();
2147
2103
  expect(handlerFn).toHaveBeenCalledTimes(1);
2148
2104
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2155,14 +2111,12 @@ export function lockProviderTestSuite(settings) {
2155
2111
  }),
2156
2112
  }));
2157
2113
  });
2158
- test("Should dispatch ForceReleasedLockEvent when key is expired", {
2159
- retry: 10,
2160
- }, async () => {
2114
+ test("Should dispatch ForceReleasedLockEvent when key is expired", async () => {
2161
2115
  const key = "a";
2162
2116
  const ttl = TimeSpan.fromMilliseconds(50);
2163
- const lock = lockProvider.create(key, { ttl });
2117
+ const lock = lockFactory.create(key, { ttl });
2164
2118
  const handlerFn = vi.fn((_event) => { });
2165
- await lockProvider.events.addListener(LOCK_EVENTS.FORCE_RELEASED, handlerFn);
2119
+ await lockFactory.events.addListener(LOCK_EVENTS.FORCE_RELEASED, handlerFn);
2166
2120
  await lock.acquire();
2167
2121
  await delay(ttl);
2168
2122
  await lock.forceRelease();
@@ -2180,9 +2134,9 @@ export function lockProviderTestSuite(settings) {
2180
2134
  test("Should dispatch ForceReleasedLockEvent when key exists and is acquired", async () => {
2181
2135
  const key = "a";
2182
2136
  const ttl = TimeSpan.fromMilliseconds(50);
2183
- const lock = lockProvider.create(key, { ttl });
2137
+ const lock = lockFactory.create(key, { ttl });
2184
2138
  const handlerFn = vi.fn((_event) => { });
2185
- await lockProvider.events.addListener(LOCK_EVENTS.FORCE_RELEASED, handlerFn);
2139
+ await lockFactory.events.addListener(LOCK_EVENTS.FORCE_RELEASED, handlerFn);
2186
2140
  await lock.acquire();
2187
2141
  await lock.forceRelease();
2188
2142
  expect(handlerFn).toHaveBeenCalledTimes(1);
@@ -2201,11 +2155,11 @@ export function lockProviderTestSuite(settings) {
2201
2155
  test("Should dispatch FailedReleaseLockEvent when key doesnt exists", async () => {
2202
2156
  const key = "a";
2203
2157
  const ttl = null;
2204
- const lock = lockProvider.create(key, {
2158
+ const lock = lockFactory.create(key, {
2205
2159
  ttl,
2206
2160
  });
2207
2161
  const handlerFn = vi.fn((_event) => { });
2208
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2162
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2209
2163
  await lock.release();
2210
2164
  expect(handlerFn).toHaveBeenCalledTimes(1);
2211
2165
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2217,13 +2171,13 @@ export function lockProviderTestSuite(settings) {
2217
2171
  }),
2218
2172
  }));
2219
2173
  });
2220
- test("Should dispatch FailedReleaseLockEvent when key is unexpireable and released by different lockId", async () => {
2174
+ test("Should dispatch FailedReleaseLockEvent when key is unexpireable and released by different lock-id", async () => {
2221
2175
  const key = "a";
2222
2176
  const ttl = null;
2223
- await lockProvider.create(key, { ttl }).acquire();
2224
- const lock = lockProvider.create(key, { ttl });
2177
+ await lockFactory.create(key, { ttl }).acquire();
2178
+ const lock = lockFactory.create(key, { ttl });
2225
2179
  const handlerFn = vi.fn((_event) => { });
2226
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2180
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2227
2181
  await lock.release();
2228
2182
  expect(handlerFn).toHaveBeenCalledTimes(1);
2229
2183
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2235,13 +2189,13 @@ export function lockProviderTestSuite(settings) {
2235
2189
  }),
2236
2190
  }));
2237
2191
  });
2238
- test("Should dispatch FailedReleaseLockEvent when key is unexpired and released by different lockId", async () => {
2192
+ test("Should dispatch FailedReleaseLockEvent when key is unexpired and released by different lock-id", async () => {
2239
2193
  const key = "a";
2240
2194
  const ttl = TimeSpan.fromMilliseconds(50);
2241
- await lockProvider.create(key, { ttl }).acquire();
2242
- const lock = lockProvider.create(key, { ttl });
2195
+ await lockFactory.create(key, { ttl }).acquire();
2196
+ const lock = lockFactory.create(key, { ttl });
2243
2197
  const handlerFn = vi.fn((_event) => { });
2244
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2198
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2245
2199
  await lock.release();
2246
2200
  expect(handlerFn).toHaveBeenCalledTimes(1);
2247
2201
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2253,15 +2207,13 @@ export function lockProviderTestSuite(settings) {
2253
2207
  }),
2254
2208
  }));
2255
2209
  });
2256
- test("Should dispatch FailedReleaseLockEvent when key is expired and released by different lockId", {
2257
- retry: 10,
2258
- }, async () => {
2210
+ test("Should dispatch FailedReleaseLockEvent when key is expired and released by different lock-id", async () => {
2259
2211
  const key = "a";
2260
2212
  const ttl = TimeSpan.fromMilliseconds(50);
2261
- await lockProvider.create(key, { ttl }).acquire();
2262
- const lock = lockProvider.create(key, { ttl });
2213
+ await lockFactory.create(key, { ttl }).acquire();
2214
+ const lock = lockFactory.create(key, { ttl });
2263
2215
  const handlerFn = vi.fn((_event) => { });
2264
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2216
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2265
2217
  await lock.release();
2266
2218
  await delay(ttl);
2267
2219
  expect(handlerFn).toHaveBeenCalledTimes(1);
@@ -2274,12 +2226,12 @@ export function lockProviderTestSuite(settings) {
2274
2226
  }),
2275
2227
  }));
2276
2228
  });
2277
- test("Should dispatch FailedReleaseLockEvent when key is expired and released by same lockId", async () => {
2229
+ test("Should dispatch FailedReleaseLockEvent when key is expired and released by same lock-id", async () => {
2278
2230
  const key = "a";
2279
2231
  const ttl = TimeSpan.fromMilliseconds(50);
2280
- const lock = lockProvider.create(key, { ttl });
2232
+ const lock = lockFactory.create(key, { ttl });
2281
2233
  const handlerFn = vi.fn((_event) => { });
2282
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2234
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2283
2235
  await lock.acquire();
2284
2236
  await delay(ttl);
2285
2237
  await lock.release();
@@ -2293,12 +2245,12 @@ export function lockProviderTestSuite(settings) {
2293
2245
  }),
2294
2246
  }));
2295
2247
  });
2296
- test("Should dispatch ReleasedLockEvent when key is unexpireable and released by same lockId", async () => {
2248
+ test("Should dispatch ReleasedLockEvent when key is unexpireable and released by same lock-id", async () => {
2297
2249
  const key = "a";
2298
2250
  const ttl = null;
2299
- const lock = lockProvider.create(key, { ttl });
2251
+ const lock = lockFactory.create(key, { ttl });
2300
2252
  const handlerFn = vi.fn((_event) => { });
2301
- await lockProvider.events.addListener(LOCK_EVENTS.RELEASED, handlerFn);
2253
+ await lockFactory.events.addListener(LOCK_EVENTS.RELEASED, handlerFn);
2302
2254
  await lock.acquire();
2303
2255
  await lock.release();
2304
2256
  expect(handlerFn).toHaveBeenCalledTimes(1);
@@ -2311,12 +2263,12 @@ export function lockProviderTestSuite(settings) {
2311
2263
  }),
2312
2264
  }));
2313
2265
  });
2314
- test("Should dispatch ReleasedLockEvent when key is unexpired and released by same lockId", async () => {
2266
+ test("Should dispatch ReleasedLockEvent when key is unexpired and released by same lock-id", async () => {
2315
2267
  const key = "a";
2316
2268
  const ttl = TimeSpan.fromMilliseconds(50);
2317
- const lock = lockProvider.create(key, { ttl });
2269
+ const lock = lockFactory.create(key, { ttl });
2318
2270
  const handlerFn = vi.fn((_event) => { });
2319
- await lockProvider.events.addListener(LOCK_EVENTS.RELEASED, handlerFn);
2271
+ await lockFactory.events.addListener(LOCK_EVENTS.RELEASED, handlerFn);
2320
2272
  await lock.acquire();
2321
2273
  await lock.release();
2322
2274
  expect(handlerFn).toHaveBeenCalledTimes(1);
@@ -2334,13 +2286,13 @@ export function lockProviderTestSuite(settings) {
2334
2286
  test("Should dispatch FailedReleaseLockEvent when key doesnt exists", async () => {
2335
2287
  const key = "a";
2336
2288
  const ttl = null;
2337
- const lock = lockProvider.create(key, {
2289
+ const lock = lockFactory.create(key, {
2338
2290
  ttl,
2339
2291
  });
2340
2292
  const handlerFn = vi.fn((_event) => { });
2341
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2293
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2342
2294
  try {
2343
- await lock.release();
2295
+ await lock.releaseOrFail();
2344
2296
  }
2345
2297
  catch {
2346
2298
  /* EMPTY */
@@ -2355,15 +2307,15 @@ export function lockProviderTestSuite(settings) {
2355
2307
  }),
2356
2308
  }));
2357
2309
  });
2358
- test("Should dispatch FailedReleaseLockEvent when key is unexpireable and released by different lockId", async () => {
2310
+ test("Should dispatch FailedReleaseLockEvent when key is unexpireable and released by different lock-id", async () => {
2359
2311
  const key = "a";
2360
2312
  const ttl = null;
2361
- await lockProvider.create(key, { ttl }).acquire();
2362
- const lock = lockProvider.create(key, { ttl });
2313
+ await lockFactory.create(key, { ttl }).acquire();
2314
+ const lock = lockFactory.create(key, { ttl });
2363
2315
  const handlerFn = vi.fn((_event) => { });
2364
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2316
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2365
2317
  try {
2366
- await lock.release();
2318
+ await lock.releaseOrFail();
2367
2319
  }
2368
2320
  catch {
2369
2321
  /* EMPTY */
@@ -2378,15 +2330,15 @@ export function lockProviderTestSuite(settings) {
2378
2330
  }),
2379
2331
  }));
2380
2332
  });
2381
- test("Should dispatch FailedReleaseLockEvent when key is unexpired and released by different lockId", async () => {
2333
+ test("Should dispatch FailedReleaseLockEvent when key is unexpired and released by different lock-id", async () => {
2382
2334
  const key = "a";
2383
2335
  const ttl = TimeSpan.fromMilliseconds(50);
2384
- await lockProvider.create(key, { ttl }).acquire();
2385
- const lock = lockProvider.create(key, { ttl });
2336
+ await lockFactory.create(key, { ttl }).acquire();
2337
+ const lock = lockFactory.create(key, { ttl });
2386
2338
  const handlerFn = vi.fn((_event) => { });
2387
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2339
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2388
2340
  try {
2389
- await lock.release();
2341
+ await lock.releaseOrFail();
2390
2342
  }
2391
2343
  catch {
2392
2344
  /* EMPTY */
@@ -2401,15 +2353,13 @@ export function lockProviderTestSuite(settings) {
2401
2353
  }),
2402
2354
  }));
2403
2355
  });
2404
- test("Should dispatch FailedReleaseLockEvent when key is expired and released by different lockId", {
2405
- retry: 10,
2406
- }, async () => {
2356
+ test("Should dispatch FailedReleaseLockEvent when key is expired and released by different lock-id", async () => {
2407
2357
  const key = "a";
2408
2358
  const ttl = TimeSpan.fromMilliseconds(50);
2409
- await lockProvider.create(key, { ttl }).acquire();
2410
- const lock = lockProvider.create(key, { ttl });
2359
+ await lockFactory.create(key, { ttl }).acquire();
2360
+ const lock = lockFactory.create(key, { ttl });
2411
2361
  const handlerFn = vi.fn((_event) => { });
2412
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2362
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2413
2363
  try {
2414
2364
  await lock.release();
2415
2365
  }
@@ -2427,14 +2377,12 @@ export function lockProviderTestSuite(settings) {
2427
2377
  }),
2428
2378
  }));
2429
2379
  });
2430
- test("Should dispatch FailedReleaseLockEvent when key is expired and released by same lockId", {
2431
- retry: 10,
2432
- }, async () => {
2380
+ test("Should dispatch FailedReleaseLockEvent when key is expired and released by same lock-id", async () => {
2433
2381
  const key = "a";
2434
2382
  const ttl = TimeSpan.fromMilliseconds(50);
2435
- const lock = lockProvider.create(key, { ttl });
2383
+ const lock = lockFactory.create(key, { ttl });
2436
2384
  const handlerFn = vi.fn((_event) => { });
2437
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2385
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_RELEASE, handlerFn);
2438
2386
  await lock.acquire();
2439
2387
  await delay(ttl);
2440
2388
  try {
@@ -2453,12 +2401,12 @@ export function lockProviderTestSuite(settings) {
2453
2401
  }),
2454
2402
  }));
2455
2403
  });
2456
- test("Should dispatch ReleasedLockEvent when key is unexpireable and released by same lockId", async () => {
2404
+ test("Should dispatch ReleasedLockEvent when key is unexpireable and released by same lock-id", async () => {
2457
2405
  const key = "a";
2458
2406
  const ttl = null;
2459
- const lock = lockProvider.create(key, { ttl });
2407
+ const lock = lockFactory.create(key, { ttl });
2460
2408
  const handlerFn = vi.fn((_event) => { });
2461
- await lockProvider.events.addListener(LOCK_EVENTS.RELEASED, handlerFn);
2409
+ await lockFactory.events.addListener(LOCK_EVENTS.RELEASED, handlerFn);
2462
2410
  await lock.acquire();
2463
2411
  await lock.releaseOrFail();
2464
2412
  expect(handlerFn).toHaveBeenCalledTimes(1);
@@ -2471,12 +2419,12 @@ export function lockProviderTestSuite(settings) {
2471
2419
  }),
2472
2420
  }));
2473
2421
  });
2474
- test("Should dispatch ReleasedLockEvent when key is unexpired and released by same lockId", async () => {
2422
+ test("Should dispatch ReleasedLockEvent when key is unexpired and released by same lock-id", async () => {
2475
2423
  const key = "a";
2476
2424
  const ttl = TimeSpan.fromMilliseconds(50);
2477
- const lock = lockProvider.create(key, { ttl });
2425
+ const lock = lockFactory.create(key, { ttl });
2478
2426
  const handlerFn = vi.fn((_event) => { });
2479
- await lockProvider.events.addListener(LOCK_EVENTS.RELEASED, handlerFn);
2427
+ await lockFactory.events.addListener(LOCK_EVENTS.RELEASED, handlerFn);
2480
2428
  await lock.acquire();
2481
2429
  await lock.releaseOrFail();
2482
2430
  expect(handlerFn).toHaveBeenCalledTimes(1);
@@ -2495,11 +2443,11 @@ export function lockProviderTestSuite(settings) {
2495
2443
  const key = "a";
2496
2444
  const ttl = null;
2497
2445
  const newTtl = TimeSpan.fromMinutes(1);
2498
- const lock = lockProvider.create(key, {
2446
+ const lock = lockFactory.create(key, {
2499
2447
  ttl,
2500
2448
  });
2501
2449
  const handlerFn = vi.fn((_event) => { });
2502
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2450
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2503
2451
  await lock.refresh(newTtl);
2504
2452
  expect(handlerFn).toHaveBeenCalledTimes(1);
2505
2453
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2511,15 +2459,15 @@ export function lockProviderTestSuite(settings) {
2511
2459
  }),
2512
2460
  }));
2513
2461
  });
2514
- test("Should dispatch FailedRefreshLockEvent when key is unexpireable and refreshed by different lockId", async () => {
2462
+ test("Should dispatch FailedRefreshLockEvent when key is unexpireable and refreshed by different lock-id", async () => {
2515
2463
  const key = "a";
2516
2464
  const ttl = null;
2517
- const lock1 = lockProvider.create(key, { ttl });
2465
+ const lock1 = lockFactory.create(key, { ttl });
2518
2466
  await lock1.acquire();
2519
2467
  const newTtl = TimeSpan.fromMinutes(1);
2520
- const lock2 = lockProvider.create(key, { ttl });
2468
+ const lock2 = lockFactory.create(key, { ttl });
2521
2469
  const handlerFn = vi.fn((_event) => { });
2522
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2470
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2523
2471
  await lock2.refresh(newTtl);
2524
2472
  expect(handlerFn).toHaveBeenCalledTimes(1);
2525
2473
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2531,15 +2479,15 @@ export function lockProviderTestSuite(settings) {
2531
2479
  }),
2532
2480
  }));
2533
2481
  });
2534
- test("Should dispatch FailedRefreshLockEvent when key is unexpired and refreshed by different lockId", async () => {
2482
+ test("Should dispatch FailedRefreshLockEvent when key is unexpired and refreshed by different lock-id", async () => {
2535
2483
  const key = "a";
2536
2484
  const ttl = TimeSpan.fromMilliseconds(50);
2537
- const lock1 = lockProvider.create(key, { ttl });
2485
+ const lock1 = lockFactory.create(key, { ttl });
2538
2486
  await lock1.acquire();
2539
2487
  const newTtl = TimeSpan.fromMinutes(1);
2540
- const lock2 = lockProvider.create(key, { ttl });
2488
+ const lock2 = lockFactory.create(key, { ttl });
2541
2489
  const handlerFn = vi.fn((_event) => { });
2542
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2490
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2543
2491
  await lock2.refresh(newTtl);
2544
2492
  expect(handlerFn).toHaveBeenCalledTimes(1);
2545
2493
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2551,18 +2499,16 @@ export function lockProviderTestSuite(settings) {
2551
2499
  }),
2552
2500
  }));
2553
2501
  });
2554
- test("Should dispatch FailedRefreshLockEvent when key is expired and refreshed by different lockId", {
2555
- retry: 10,
2556
- }, async () => {
2502
+ test("Should dispatch FailedRefreshLockEvent when key is expired and refreshed by different lock-id", async () => {
2557
2503
  const key = "a";
2558
2504
  const ttl = TimeSpan.fromMilliseconds(50);
2559
- const lock1 = lockProvider.create(key, { ttl });
2505
+ const lock1 = lockFactory.create(key, { ttl });
2560
2506
  await lock1.acquire();
2561
2507
  await delay(ttl);
2562
2508
  const newTtl = TimeSpan.fromMinutes(1);
2563
- const lock2 = lockProvider.create(key, { ttl });
2509
+ const lock2 = lockFactory.create(key, { ttl });
2564
2510
  const handlerFn = vi.fn((_event) => { });
2565
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2511
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2566
2512
  await lock2.refresh(newTtl);
2567
2513
  expect(handlerFn).toHaveBeenCalledTimes(1);
2568
2514
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2574,19 +2520,17 @@ export function lockProviderTestSuite(settings) {
2574
2520
  }),
2575
2521
  }));
2576
2522
  });
2577
- test("Should dispatch FailedRefreshLockEvent when key is expired and refreshed by same lockId", {
2578
- retry: 10,
2579
- }, async () => {
2523
+ test("Should dispatch FailedRefreshLockEvent when key is expired and refreshed by same lock-id", async () => {
2580
2524
  const key = "a";
2581
2525
  const ttl = TimeSpan.fromMilliseconds(50);
2582
- const lock = lockProvider.create(key, {
2526
+ const lock = lockFactory.create(key, {
2583
2527
  ttl,
2584
2528
  });
2585
2529
  await lock.acquire();
2586
2530
  await delay(ttl);
2587
2531
  const newTtl = TimeSpan.fromMinutes(1);
2588
2532
  const handlerFn = vi.fn((_event) => { });
2589
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2533
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2590
2534
  await lock.refresh(newTtl);
2591
2535
  expect(handlerFn).toHaveBeenCalledTimes(1);
2592
2536
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2598,14 +2542,14 @@ export function lockProviderTestSuite(settings) {
2598
2542
  }),
2599
2543
  }));
2600
2544
  });
2601
- test("Should dispatch FailedRefreshLockEvent when key is unexpireable and refreshed by same lockId", async () => {
2545
+ test("Should dispatch FailedRefreshLockEvent when key is unexpireable and refreshed by same lock-id", async () => {
2602
2546
  const key = "a";
2603
2547
  const ttl = null;
2604
- const lock = lockProvider.create(key, { ttl });
2548
+ const lock = lockFactory.create(key, { ttl });
2605
2549
  await lock.acquire();
2606
2550
  const newTtl = TimeSpan.fromMinutes(1);
2607
2551
  const handlerFn = vi.fn((_event) => { });
2608
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2552
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2609
2553
  await lock.refresh(newTtl);
2610
2554
  expect(handlerFn).toHaveBeenCalledTimes(1);
2611
2555
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2617,14 +2561,14 @@ export function lockProviderTestSuite(settings) {
2617
2561
  }),
2618
2562
  }));
2619
2563
  });
2620
- test("Should dispatch RefreshedLockEvent when key is unexpired and refreshed by same lockId", async () => {
2564
+ test("Should dispatch RefreshedLockEvent when key is unexpired and refreshed by same lock-id", async () => {
2621
2565
  const key = "a";
2622
2566
  const ttl = TimeSpan.fromMilliseconds(50);
2623
- const lock = lockProvider.create(key, { ttl });
2567
+ const lock = lockFactory.create(key, { ttl });
2624
2568
  await lock.acquire();
2625
2569
  const newTtl = TimeSpan.fromMinutes(1);
2626
2570
  const handlerFn = vi.fn((_event) => { });
2627
- await lockProvider.events.addListener(LOCK_EVENTS.REFRESHED, handlerFn);
2571
+ await lockFactory.events.addListener(LOCK_EVENTS.REFRESHED, handlerFn);
2628
2572
  await lock.refresh(newTtl);
2629
2573
  expect(handlerFn).toHaveBeenCalledTimes(1);
2630
2574
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2642,11 +2586,11 @@ export function lockProviderTestSuite(settings) {
2642
2586
  const key = "a";
2643
2587
  const ttl = null;
2644
2588
  const newTtl = TimeSpan.fromMinutes(1);
2645
- const lock = lockProvider.create(key, {
2589
+ const lock = lockFactory.create(key, {
2646
2590
  ttl,
2647
2591
  });
2648
2592
  const handlerFn = vi.fn((_event) => { });
2649
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2593
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2650
2594
  try {
2651
2595
  await lock.refreshOrFail(newTtl);
2652
2596
  }
@@ -2663,15 +2607,15 @@ export function lockProviderTestSuite(settings) {
2663
2607
  }),
2664
2608
  }));
2665
2609
  });
2666
- test("Should dispatch FailedRefreshLockEvent when key is unexpireable and refreshed by different lockId", async () => {
2610
+ test("Should dispatch FailedRefreshLockEvent when key is unexpireable and refreshed by different lock-id", async () => {
2667
2611
  const key = "a";
2668
2612
  const ttl = null;
2669
- const lock1 = lockProvider.create(key, { ttl });
2613
+ const lock1 = lockFactory.create(key, { ttl });
2670
2614
  await lock1.acquire();
2671
2615
  const newTtl = TimeSpan.fromMinutes(1);
2672
- const lock2 = lockProvider.create(key, { ttl });
2616
+ const lock2 = lockFactory.create(key, { ttl });
2673
2617
  const handlerFn = vi.fn((_event) => { });
2674
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2618
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2675
2619
  try {
2676
2620
  await lock2.refreshOrFail(newTtl);
2677
2621
  }
@@ -2688,15 +2632,15 @@ export function lockProviderTestSuite(settings) {
2688
2632
  }),
2689
2633
  }));
2690
2634
  });
2691
- test("Should dispatch FailedRefreshLockEvent when key is unexpired and refreshed by different lockId", async () => {
2635
+ test("Should dispatch FailedRefreshLockEvent when key is unexpired and refreshed by different lock-id", async () => {
2692
2636
  const key = "a";
2693
2637
  const ttl = TimeSpan.fromMilliseconds(50);
2694
- const lock1 = lockProvider.create(key, { ttl });
2638
+ const lock1 = lockFactory.create(key, { ttl });
2695
2639
  await lock1.acquire();
2696
2640
  const newTtl = TimeSpan.fromMinutes(1);
2697
- const lock2 = lockProvider.create(key, { ttl });
2641
+ const lock2 = lockFactory.create(key, { ttl });
2698
2642
  const handlerFn = vi.fn((_event) => { });
2699
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2643
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2700
2644
  try {
2701
2645
  await lock2.refreshOrFail(newTtl);
2702
2646
  }
@@ -2713,18 +2657,16 @@ export function lockProviderTestSuite(settings) {
2713
2657
  }),
2714
2658
  }));
2715
2659
  });
2716
- test("Should dispatch FailedRefreshLockEvent when key is expired and refreshed by different lockId", {
2717
- retry: 10,
2718
- }, async () => {
2660
+ test("Should dispatch FailedRefreshLockEvent when key is expired and refreshed by different lock-id", async () => {
2719
2661
  const key = "a";
2720
2662
  const ttl = TimeSpan.fromMilliseconds(50);
2721
- const lock1 = lockProvider.create(key, { ttl });
2663
+ const lock1 = lockFactory.create(key, { ttl });
2722
2664
  await lock1.acquire();
2723
2665
  await delay(ttl);
2724
2666
  const newTtl = TimeSpan.fromMinutes(1);
2725
- const lock2 = lockProvider.create(key, { ttl });
2667
+ const lock2 = lockFactory.create(key, { ttl });
2726
2668
  const handlerFn = vi.fn((_event) => { });
2727
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2669
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2728
2670
  try {
2729
2671
  await lock2.refreshOrFail(newTtl);
2730
2672
  }
@@ -2741,19 +2683,17 @@ export function lockProviderTestSuite(settings) {
2741
2683
  }),
2742
2684
  }));
2743
2685
  });
2744
- test("Should dispatch FailedRefreshLockEvent when key is expired and refreshed by same lockId", {
2745
- retry: 10,
2746
- }, async () => {
2686
+ test("Should dispatch FailedRefreshLockEvent when key is expired and refreshed by same lock-id", async () => {
2747
2687
  const key = "a";
2748
2688
  const ttl = TimeSpan.fromMilliseconds(50);
2749
- const lock = lockProvider.create(key, {
2689
+ const lock = lockFactory.create(key, {
2750
2690
  ttl,
2751
2691
  });
2752
2692
  await lock.acquire();
2753
2693
  await delay(ttl);
2754
2694
  const newTtl = TimeSpan.fromMinutes(1);
2755
2695
  const handlerFn = vi.fn((_event) => { });
2756
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2696
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2757
2697
  try {
2758
2698
  await lock.refreshOrFail(newTtl);
2759
2699
  }
@@ -2770,14 +2710,14 @@ export function lockProviderTestSuite(settings) {
2770
2710
  }),
2771
2711
  }));
2772
2712
  });
2773
- test("Should dispatch FailedRefreshLockEvent when key is unexpireable and refreshed by same lockId", async () => {
2713
+ test("Should dispatch FailedRefreshLockEvent when key is unexpireable and refreshed by same lock-id", async () => {
2774
2714
  const key = "a";
2775
2715
  const ttl = null;
2776
- const lock = lockProvider.create(key, { ttl });
2716
+ const lock = lockFactory.create(key, { ttl });
2777
2717
  await lock.acquire();
2778
2718
  const newTtl = TimeSpan.fromMinutes(1);
2779
2719
  const handlerFn = vi.fn((_event) => { });
2780
- await lockProvider.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2720
+ await lockFactory.events.addListener(LOCK_EVENTS.FAILED_REFRESH, handlerFn);
2781
2721
  try {
2782
2722
  await lock.refreshOrFail(newTtl);
2783
2723
  }
@@ -2794,14 +2734,14 @@ export function lockProviderTestSuite(settings) {
2794
2734
  }),
2795
2735
  }));
2796
2736
  });
2797
- test("Should dispatch RefreshedLockEvent when key is unexpired and refreshed by same lockId", async () => {
2737
+ test("Should dispatch RefreshedLockEvent when key is unexpired and refreshed by same lock-id", async () => {
2798
2738
  const key = "a";
2799
2739
  const ttl = TimeSpan.fromMilliseconds(50);
2800
- const lock = lockProvider.create(key, { ttl });
2740
+ const lock = lockFactory.create(key, { ttl });
2801
2741
  await lock.acquire();
2802
2742
  const newTtl = TimeSpan.fromMinutes(1);
2803
2743
  const handlerFn = vi.fn((_event) => { });
2804
- await lockProvider.events.addListener(LOCK_EVENTS.REFRESHED, handlerFn);
2744
+ await lockFactory.events.addListener(LOCK_EVENTS.REFRESHED, handlerFn);
2805
2745
  await lock.refreshOrFail(newTtl);
2806
2746
  expect(handlerFn).toHaveBeenCalledTimes(1);
2807
2747
  expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({
@@ -2819,7 +2759,7 @@ export function lockProviderTestSuite(settings) {
2819
2759
  test("Should return ILockExpiredState when is derserialized and key doesnt exists", async () => {
2820
2760
  const key = "a";
2821
2761
  const ttl = TimeSpan.fromMilliseconds(50);
2822
- const lock = lockProvider.create(key, {
2762
+ const lock = lockFactory.create(key, {
2823
2763
  ttl,
2824
2764
  });
2825
2765
  const deserializedLock = serde.deserialize(serde.serialize(lock));
@@ -2828,12 +2768,10 @@ export function lockProviderTestSuite(settings) {
2828
2768
  type: LOCK_STATE.EXPIRED,
2829
2769
  });
2830
2770
  });
2831
- test("Should return ILockExpiredState when is derserialized and key is expired", {
2832
- retry: 10,
2833
- }, async () => {
2771
+ test("Should return ILockExpiredState when is derserialized and key is expired", async () => {
2834
2772
  const key = "a";
2835
2773
  const ttl = TimeSpan.fromMilliseconds(50);
2836
- const lock = lockProvider.create(key, {
2774
+ const lock = lockFactory.create(key, {
2837
2775
  ttl,
2838
2776
  });
2839
2777
  await lock.acquire();
@@ -2847,12 +2785,12 @@ export function lockProviderTestSuite(settings) {
2847
2785
  test("Should return ILockExpiredState when is derserialized and all key is released with forceRelease method", async () => {
2848
2786
  const key = "a";
2849
2787
  const ttl1 = null;
2850
- const lock1 = lockProvider.create(key, {
2788
+ const lock1 = lockFactory.create(key, {
2851
2789
  ttl: ttl1,
2852
2790
  });
2853
2791
  await lock1.acquire();
2854
2792
  const ttl2 = null;
2855
- const lock2 = lockProvider.create(key, {
2793
+ const lock2 = lockFactory.create(key, {
2856
2794
  ttl: ttl2,
2857
2795
  });
2858
2796
  await lock2.acquire();
@@ -2866,12 +2804,12 @@ export function lockProviderTestSuite(settings) {
2866
2804
  test("Should return ILockExpiredState when is derserialized and all key is released with release method", async () => {
2867
2805
  const key = "a";
2868
2806
  const ttl1 = null;
2869
- const lock1 = lockProvider.create(key, {
2807
+ const lock1 = lockFactory.create(key, {
2870
2808
  ttl: ttl1,
2871
2809
  });
2872
2810
  await lock1.acquire();
2873
2811
  const ttl2 = null;
2874
- const lock2 = lockProvider.create(key, {
2812
+ const lock2 = lockFactory.create(key, {
2875
2813
  ttl: ttl2,
2876
2814
  });
2877
2815
  await lock2.acquire();
@@ -2886,7 +2824,7 @@ export function lockProviderTestSuite(settings) {
2886
2824
  test("Should return ILockAcquiredState when is derserialized and key is unexpireable", async () => {
2887
2825
  const key = "a";
2888
2826
  const ttl = null;
2889
- const lock = lockProvider.create(key, {
2827
+ const lock = lockFactory.create(key, {
2890
2828
  ttl,
2891
2829
  });
2892
2830
  await lock.acquire();
@@ -2898,29 +2836,30 @@ export function lockProviderTestSuite(settings) {
2898
2836
  });
2899
2837
  });
2900
2838
  test("Should return ILockAcquiredState when is derserialized and key is unexpired", async () => {
2839
+ expect.addEqualityTesters([
2840
+ createIsTimeSpanEqualityTester(timeSpanEqualityBuffer),
2841
+ ]);
2901
2842
  const key = "a";
2902
2843
  const ttl = TimeSpan.fromMilliseconds(50);
2903
- const lock = lockProvider.create(key, {
2844
+ const lock = lockFactory.create(key, {
2904
2845
  ttl,
2905
2846
  });
2906
2847
  await lock.acquire();
2907
2848
  const deserializedLock = serde.deserialize(serde.serialize(lock));
2908
2849
  const state = await deserializedLock.getState();
2909
- const lockAcquiredState = state;
2910
- expect(state.type).toBe(LOCK_STATE.ACQUIRED);
2911
- expect(lockAcquiredState.remainingTime?.toMilliseconds()).toBeLessThan((lockAcquiredState.remainingTime?.toMilliseconds() ?? 0) +
2912
- 10);
2913
- expect(lockAcquiredState.remainingTime?.toMilliseconds()).toBeGreaterThan((lockAcquiredState.remainingTime?.toMilliseconds() ?? 0) -
2914
- 10);
2850
+ expect(state).toEqual({
2851
+ type: LOCK_STATE.ACQUIRED,
2852
+ remainingTime: ttl,
2853
+ });
2915
2854
  });
2916
- test("Should return ILockUnavailableState when is derserialized and key is acquired by different owner", async () => {
2855
+ test("Should return ILockUnavailableState when is derserialized and key is acquired by different lock-id", async () => {
2917
2856
  const key = "a";
2918
2857
  const ttl = null;
2919
- const lock1 = lockProvider.create(key, {
2858
+ const lock1 = lockFactory.create(key, {
2920
2859
  ttl,
2921
2860
  });
2922
2861
  await lock1.acquire();
2923
- const lock2 = lockProvider.create(key, {
2862
+ const lock2 = lockFactory.create(key, {
2924
2863
  ttl,
2925
2864
  });
2926
2865
  const deserializedLock2 = serde.deserialize(serde.serialize(lock2));
@@ -2933,4 +2872,4 @@ export function lockProviderTestSuite(settings) {
2933
2872
  });
2934
2873
  });
2935
2874
  }
2936
- //# sourceMappingURL=lock-provider.test-suite.js.map
2875
+ //# sourceMappingURL=lock-factory.test-suite.js.map