@ddd-ts-kit/redis 0.0.0-stage → 0.1.1

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 (282) hide show
  1. package/README.md +699 -2
  2. package/dist/cache/cache-codec.d.ts +6 -0
  3. package/dist/cache/cache-codec.d.ts.map +1 -0
  4. package/dist/cache/cache-codec.js +2 -0
  5. package/dist/cache/cache-codec.js.map +1 -0
  6. package/dist/cache/cache-operation.d.ts +3 -0
  7. package/dist/cache/cache-operation.d.ts.map +1 -0
  8. package/dist/cache/cache-operation.js +2 -0
  9. package/dist/cache/cache-operation.js.map +1 -0
  10. package/dist/cache/json-codec.d.ts +4 -0
  11. package/dist/cache/json-codec.d.ts.map +1 -0
  12. package/dist/cache/json-codec.js +9 -0
  13. package/dist/cache/json-codec.js.map +1 -0
  14. package/dist/cache/redis-cache.d.ts +65 -0
  15. package/dist/cache/redis-cache.d.ts.map +1 -0
  16. package/dist/cache/redis-cache.js +147 -0
  17. package/dist/cache/redis-cache.js.map +1 -0
  18. package/dist/connection/close-redis.d.ts +4 -0
  19. package/dist/connection/close-redis.d.ts.map +1 -0
  20. package/dist/connection/close-redis.js +20 -0
  21. package/dist/connection/close-redis.js.map +1 -0
  22. package/dist/connection/connect-redis.d.ts +10 -0
  23. package/dist/connection/connect-redis.d.ts.map +1 -0
  24. package/dist/connection/connect-redis.js +26 -0
  25. package/dist/connection/connect-redis.js.map +1 -0
  26. package/dist/connection/fail-fast.d.ts +9 -0
  27. package/dist/connection/fail-fast.d.ts.map +1 -0
  28. package/dist/connection/fail-fast.js +8 -0
  29. package/dist/connection/fail-fast.js.map +1 -0
  30. package/dist/connection/redis-connection-options.d.ts +7 -0
  31. package/dist/connection/redis-connection-options.d.ts.map +1 -0
  32. package/dist/connection/redis-connection-options.js +2 -0
  33. package/dist/connection/redis-connection-options.js.map +1 -0
  34. package/dist/connection/redis-health.d.ts +15 -0
  35. package/dist/connection/redis-health.d.ts.map +1 -0
  36. package/dist/connection/redis-health.js +31 -0
  37. package/dist/connection/redis-health.js.map +1 -0
  38. package/dist/connection/redis-source.d.ts +5 -0
  39. package/dist/connection/redis-source.d.ts.map +1 -0
  40. package/dist/connection/redis-source.js +2 -0
  41. package/dist/connection/redis-source.js.map +1 -0
  42. package/dist/event-bus.d.ts +22 -0
  43. package/dist/event-bus.d.ts.map +1 -0
  44. package/dist/event-bus.js +10 -0
  45. package/dist/event-bus.js.map +1 -0
  46. package/dist/index.d.ts +17 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +13 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/keys/namespaced.d.ts +3 -0
  51. package/dist/keys/namespaced.d.ts.map +1 -0
  52. package/dist/keys/namespaced.js +5 -0
  53. package/dist/keys/namespaced.js.map +1 -0
  54. package/dist/keys/prefix-pattern.d.ts +3 -0
  55. package/dist/keys/prefix-pattern.d.ts.map +1 -0
  56. package/dist/keys/prefix-pattern.js +5 -0
  57. package/dist/keys/prefix-pattern.js.map +1 -0
  58. package/dist/lock/redis-lock.d.ts +31 -0
  59. package/dist/lock/redis-lock.d.ts.map +1 -0
  60. package/dist/lock/redis-lock.js +66 -0
  61. package/dist/lock/redis-lock.js.map +1 -0
  62. package/dist/rate-limiter/redis-rate-limiter.d.ts +35 -0
  63. package/dist/rate-limiter/redis-rate-limiter.d.ts.map +1 -0
  64. package/dist/rate-limiter/redis-rate-limiter.js +77 -0
  65. package/dist/rate-limiter/redis-rate-limiter.js.map +1 -0
  66. package/dist/relay/redis-relay-signal.d.ts +36 -0
  67. package/dist/relay/redis-relay-signal.d.ts.map +1 -0
  68. package/dist/relay/redis-relay-signal.js +72 -0
  69. package/dist/relay/redis-relay-signal.js.map +1 -0
  70. package/dist/relay/relay-wake-up-middleware.d.ts +11 -0
  71. package/dist/relay/relay-wake-up-middleware.d.ts.map +1 -0
  72. package/dist/relay/relay-wake-up-middleware.js +16 -0
  73. package/dist/relay/relay-wake-up-middleware.js.map +1 -0
  74. package/dist/replies/list-of.d.ts +3 -0
  75. package/dist/replies/list-of.d.ts.map +1 -0
  76. package/dist/replies/list-of.js +8 -0
  77. package/dist/replies/list-of.js.map +1 -0
  78. package/dist/secrecy/conceal.d.ts +8 -0
  79. package/dist/secrecy/conceal.d.ts.map +1 -0
  80. package/dist/secrecy/conceal.js +12 -0
  81. package/dist/secrecy/conceal.js.map +1 -0
  82. package/dist/streams/bury.d.ts +13 -0
  83. package/dist/streams/bury.d.ts.map +1 -0
  84. package/dist/streams/bury.js +14 -0
  85. package/dist/streams/bury.js.map +1 -0
  86. package/dist/streams/claim-due.d.ts +18 -0
  87. package/dist/streams/claim-due.d.ts.map +1 -0
  88. package/dist/streams/claim-due.js +41 -0
  89. package/dist/streams/claim-due.js.map +1 -0
  90. package/dist/streams/codec/decode.d.ts +5 -0
  91. package/dist/streams/codec/decode.d.ts.map +1 -0
  92. package/dist/streams/codec/decode.js +40 -0
  93. package/dist/streams/codec/decode.js.map +1 -0
  94. package/dist/streams/codec/encode.d.ts +7 -0
  95. package/dist/streams/codec/encode.d.ts.map +1 -0
  96. package/dist/streams/codec/encode.js +20 -0
  97. package/dist/streams/codec/encode.js.map +1 -0
  98. package/dist/streams/codec/entries-by-stream.d.ts +4 -0
  99. package/dist/streams/codec/entries-by-stream.d.ts.map +1 -0
  100. package/dist/streams/codec/entries-by-stream.js +14 -0
  101. package/dist/streams/codec/entries-by-stream.js.map +1 -0
  102. package/dist/streams/codec/entries-of.d.ts +4 -0
  103. package/dist/streams/codec/entries-of.d.ts.map +1 -0
  104. package/dist/streams/codec/entries-of.js +16 -0
  105. package/dist/streams/codec/entries-of.js.map +1 -0
  106. package/dist/streams/codec/entry-fields.d.ts +13 -0
  107. package/dist/streams/codec/entry-fields.d.ts.map +1 -0
  108. package/dist/streams/codec/entry-fields.js +13 -0
  109. package/dist/streams/codec/entry-fields.js.map +1 -0
  110. package/dist/streams/codec/entry.d.ts +6 -0
  111. package/dist/streams/codec/entry.d.ts.map +1 -0
  112. package/dist/streams/codec/entry.js +2 -0
  113. package/dist/streams/codec/entry.js.map +1 -0
  114. package/dist/streams/codec/fields-with.d.ts +4 -0
  115. package/dist/streams/codec/fields-with.d.ts.map +1 -0
  116. package/dist/streams/codec/fields-with.js +6 -0
  117. package/dist/streams/codec/fields-with.js.map +1 -0
  118. package/dist/streams/codec/pending-entry.d.ts +7 -0
  119. package/dist/streams/codec/pending-entry.d.ts.map +1 -0
  120. package/dist/streams/codec/pending-entry.js +2 -0
  121. package/dist/streams/codec/pending-entry.js.map +1 -0
  122. package/dist/streams/codec/pending-of.d.ts +4 -0
  123. package/dist/streams/codec/pending-of.d.ts.map +1 -0
  124. package/dist/streams/codec/pending-of.js +11 -0
  125. package/dist/streams/codec/pending-of.js.map +1 -0
  126. package/dist/streams/codec/replay-fields.d.ts +4 -0
  127. package/dist/streams/codec/replay-fields.d.ts.map +1 -0
  128. package/dist/streams/codec/replay-fields.js +15 -0
  129. package/dist/streams/codec/replay-fields.js.map +1 -0
  130. package/dist/streams/consumption.d.ts +22 -0
  131. package/dist/streams/consumption.d.ts.map +1 -0
  132. package/dist/streams/consumption.js +46 -0
  133. package/dist/streams/consumption.js.map +1 -0
  134. package/dist/streams/delivery.d.ts +8 -0
  135. package/dist/streams/delivery.d.ts.map +1 -0
  136. package/dist/streams/delivery.js +2 -0
  137. package/dist/streams/delivery.js.map +1 -0
  138. package/dist/streams/errors/broker-unavailable-error.d.ts +8 -0
  139. package/dist/streams/errors/broker-unavailable-error.d.ts.map +1 -0
  140. package/dist/streams/errors/broker-unavailable-error.js +12 -0
  141. package/dist/streams/errors/broker-unavailable-error.js.map +1 -0
  142. package/dist/streams/errors/consumer-name-required-error.d.ts +5 -0
  143. package/dist/streams/errors/consumer-name-required-error.d.ts.map +1 -0
  144. package/dist/streams/errors/consumer-name-required-error.js +8 -0
  145. package/dist/streams/errors/consumer-name-required-error.js.map +1 -0
  146. package/dist/streams/errors/event-bus-closed-error.d.ts +5 -0
  147. package/dist/streams/errors/event-bus-closed-error.d.ts.map +1 -0
  148. package/dist/streams/errors/event-bus-closed-error.js +8 -0
  149. package/dist/streams/errors/event-bus-closed-error.js.map +1 -0
  150. package/dist/streams/errors/failure-code.d.ts +7 -0
  151. package/dist/streams/errors/failure-code.d.ts.map +1 -0
  152. package/dist/streams/errors/failure-code.js +28 -0
  153. package/dist/streams/errors/failure-code.js.map +1 -0
  154. package/dist/streams/errors/publish-not-confirmed-error.d.ts +9 -0
  155. package/dist/streams/errors/publish-not-confirmed-error.d.ts.map +1 -0
  156. package/dist/streams/errors/publish-not-confirmed-error.js +14 -0
  157. package/dist/streams/errors/publish-not-confirmed-error.js.map +1 -0
  158. package/dist/streams/group-reader.d.ts +57 -0
  159. package/dist/streams/group-reader.d.ts.map +1 -0
  160. package/dist/streams/group-reader.js +187 -0
  161. package/dist/streams/group-reader.js.map +1 -0
  162. package/dist/streams/messaging-system.d.ts +3 -0
  163. package/dist/streams/messaging-system.d.ts.map +1 -0
  164. package/dist/streams/messaging-system.js +3 -0
  165. package/dist/streams/messaging-system.js.map +1 -0
  166. package/dist/streams/options/deduplication-options.d.ts +5 -0
  167. package/dist/streams/options/deduplication-options.d.ts.map +1 -0
  168. package/dist/streams/options/deduplication-options.js +2 -0
  169. package/dist/streams/options/deduplication-options.js.map +1 -0
  170. package/dist/streams/options/default-prefix.d.ts +2 -0
  171. package/dist/streams/options/default-prefix.d.ts.map +1 -0
  172. package/dist/streams/options/default-prefix.js +2 -0
  173. package/dist/streams/options/default-prefix.js.map +1 -0
  174. package/dist/streams/options/reconnect-delay.d.ts +4 -0
  175. package/dist/streams/options/reconnect-delay.d.ts.map +1 -0
  176. package/dist/streams/options/reconnect-delay.js +5 -0
  177. package/dist/streams/options/reconnect-delay.js.map +1 -0
  178. package/dist/streams/options/reconnect-options.d.ts +9 -0
  179. package/dist/streams/options/reconnect-options.d.ts.map +1 -0
  180. package/dist/streams/options/reconnect-options.js +2 -0
  181. package/dist/streams/options/reconnect-options.js.map +1 -0
  182. package/dist/streams/options/redis-streams-delivery.d.ts +13 -0
  183. package/dist/streams/options/redis-streams-delivery.d.ts.map +1 -0
  184. package/dist/streams/options/redis-streams-delivery.js +2 -0
  185. package/dist/streams/options/redis-streams-delivery.js.map +1 -0
  186. package/dist/streams/options/redis-streams-event-bus-options.d.ts +48 -0
  187. package/dist/streams/options/redis-streams-event-bus-options.d.ts.map +1 -0
  188. package/dist/streams/options/redis-streams-event-bus-options.js +2 -0
  189. package/dist/streams/options/redis-streams-event-bus-options.js.map +1 -0
  190. package/dist/streams/options/redis-streams-failure.d.ts +19 -0
  191. package/dist/streams/options/redis-streams-failure.d.ts.map +1 -0
  192. package/dist/streams/options/redis-streams-failure.js +2 -0
  193. package/dist/streams/options/redis-streams-failure.js.map +1 -0
  194. package/dist/streams/options/retention-options.d.ts +10 -0
  195. package/dist/streams/options/retention-options.d.ts.map +1 -0
  196. package/dist/streams/options/retention-options.js +2 -0
  197. package/dist/streams/options/retention-options.js.map +1 -0
  198. package/dist/streams/options/retry-options.d.ts +7 -0
  199. package/dist/streams/options/retry-options.d.ts.map +1 -0
  200. package/dist/streams/options/retry-options.js +2 -0
  201. package/dist/streams/options/retry-options.js.map +1 -0
  202. package/dist/streams/options/settings-of.d.ts +4 -0
  203. package/dist/streams/options/settings-of.d.ts.map +1 -0
  204. package/dist/streams/options/settings-of.js +47 -0
  205. package/dist/streams/options/settings-of.js.map +1 -0
  206. package/dist/streams/options/settings.d.ts +28 -0
  207. package/dist/streams/options/settings.d.ts.map +1 -0
  208. package/dist/streams/options/settings.js +2 -0
  209. package/dist/streams/options/settings.js.map +1 -0
  210. package/dist/streams/publications.d.ts +22 -0
  211. package/dist/streams/publications.d.ts.map +1 -0
  212. package/dist/streams/publications.js +75 -0
  213. package/dist/streams/publications.js.map +1 -0
  214. package/dist/streams/redis-streams-event-bus.d.ts +55 -0
  215. package/dist/streams/redis-streams-event-bus.d.ts.map +1 -0
  216. package/dist/streams/redis-streams-event-bus.js +120 -0
  217. package/dist/streams/redis-streams-event-bus.js.map +1 -0
  218. package/dist/streams/replay.d.ts +13 -0
  219. package/dist/streams/replay.d.ts.map +1 -0
  220. package/dist/streams/replay.js +26 -0
  221. package/dist/streams/replay.js.map +1 -0
  222. package/dist/streams/server-link.d.ts +45 -0
  223. package/dist/streams/server-link.d.ts.map +1 -0
  224. package/dist/streams/server-link.js +129 -0
  225. package/dist/streams/server-link.js.map +1 -0
  226. package/dist/streams/settlement.d.ts +46 -0
  227. package/dist/streams/settlement.d.ts.map +1 -0
  228. package/dist/streams/settlement.js +139 -0
  229. package/dist/streams/settlement.js.map +1 -0
  230. package/dist/streams/topology/consumer-binding.d.ts +5 -0
  231. package/dist/streams/topology/consumer-binding.d.ts.map +1 -0
  232. package/dist/streams/topology/consumer-binding.js +2 -0
  233. package/dist/streams/topology/consumer-binding.js.map +1 -0
  234. package/dist/streams/topology/create-group.d.ts +4 -0
  235. package/dist/streams/topology/create-group.d.ts.map +1 -0
  236. package/dist/streams/topology/create-group.js +13 -0
  237. package/dist/streams/topology/create-group.js.map +1 -0
  238. package/dist/streams/topology/dead-stream-of.d.ts +3 -0
  239. package/dist/streams/topology/dead-stream-of.d.ts.map +1 -0
  240. package/dist/streams/topology/dead-stream-of.js +5 -0
  241. package/dist/streams/topology/dead-stream-of.js.map +1 -0
  242. package/dist/streams/topology/declare-topology.d.ts +5 -0
  243. package/dist/streams/topology/declare-topology.d.ts.map +1 -0
  244. package/dist/streams/topology/declare-topology.js +8 -0
  245. package/dist/streams/topology/declare-topology.js.map +1 -0
  246. package/dist/streams/topology/group-description.d.ts +7 -0
  247. package/dist/streams/topology/group-description.d.ts.map +1 -0
  248. package/dist/streams/topology/group-description.js +2 -0
  249. package/dist/streams/topology/group-description.js.map +1 -0
  250. package/dist/streams/topology/group-of.d.ts +5 -0
  251. package/dist/streams/topology/group-of.d.ts.map +1 -0
  252. package/dist/streams/topology/group-of.js +4 -0
  253. package/dist/streams/topology/group-of.js.map +1 -0
  254. package/dist/streams/topology/redis-streams-topology.d.ts +8 -0
  255. package/dist/streams/topology/redis-streams-topology.d.ts.map +1 -0
  256. package/dist/streams/topology/redis-streams-topology.js +2 -0
  257. package/dist/streams/topology/redis-streams-topology.js.map +1 -0
  258. package/dist/streams/topology/stream-description.d.ts +12 -0
  259. package/dist/streams/topology/stream-description.d.ts.map +1 -0
  260. package/dist/streams/topology/stream-description.js +2 -0
  261. package/dist/streams/topology/stream-description.js.map +1 -0
  262. package/dist/streams/topology/stream-names-of.d.ts +5 -0
  263. package/dist/streams/topology/stream-names-of.d.ts.map +1 -0
  264. package/dist/streams/topology/stream-names-of.js +11 -0
  265. package/dist/streams/topology/stream-names-of.js.map +1 -0
  266. package/dist/streams/topology/stream-names.d.ts +5 -0
  267. package/dist/streams/topology/stream-names.d.ts.map +1 -0
  268. package/dist/streams/topology/stream-names.js +2 -0
  269. package/dist/streams/topology/stream-names.js.map +1 -0
  270. package/dist/streams/topology/topology-of.d.ts +5 -0
  271. package/dist/streams/topology/topology-of.d.ts.map +1 -0
  272. package/dist/streams/topology/topology-of.js +21 -0
  273. package/dist/streams/topology/topology-of.js.map +1 -0
  274. package/dist/streams/topology/topology-settings.d.ts +7 -0
  275. package/dist/streams/topology/topology-settings.d.ts.map +1 -0
  276. package/dist/streams/topology/topology-settings.js +2 -0
  277. package/dist/streams/topology/topology-settings.js.map +1 -0
  278. package/dist/testing.d.ts +2 -0
  279. package/dist/testing.d.ts.map +1 -0
  280. package/dist/testing.js +2 -0
  281. package/dist/testing.js.map +1 -0
  282. package/package.json +51 -4
@@ -0,0 +1,6 @@
1
+ /** How a value becomes the text the server stores, and back. */
2
+ export interface CacheCodec {
3
+ encode(value: unknown): string;
4
+ decode(text: string): unknown;
5
+ }
6
+ //# sourceMappingURL=cache-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-codec.d.ts","sourceRoot":"","sources":["../../src/cache/cache-codec.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IAE/B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cache-codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-codec.js","sourceRoot":"","sources":["../../src/cache/cache-codec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ /** The `operation` label of `cache_errors_total`. */
2
+ export type CacheOperation = 'get' | 'set' | 'delete';
3
+ //# sourceMappingURL=cache-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-operation.d.ts","sourceRoot":"","sources":["../../src/cache/cache-operation.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cache-operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-operation.js","sourceRoot":"","sources":["../../src/cache/cache-operation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { CacheCodec } from './cache-codec.js';
2
+ /** The default: what goes in must be JSON, and a `Date` comes back as a string. */
3
+ export declare const jsonCodec: CacheCodec;
4
+ //# sourceMappingURL=json-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-codec.d.ts","sourceRoot":"","sources":["../../src/cache/json-codec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,mFAAmF;AACnF,eAAO,MAAM,SAAS,EAAE,UAOvB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** The default: what goes in must be JSON, and a `Date` comes back as a string. */
2
+ export const jsonCodec = {
3
+ encode: (value) => JSON.stringify(value),
4
+ decode: (text) => {
5
+ const value = JSON.parse(text);
6
+ return value;
7
+ },
8
+ };
9
+ //# sourceMappingURL=json-codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-codec.js","sourceRoot":"","sources":["../../src/cache/json-codec.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,MAAM,CAAC,MAAM,SAAS,GAAe;IACnC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;IACxC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QACf,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAExC,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { inspect } from 'node:util';
2
+ import type { Redis } from 'ioredis';
3
+ import { type Cache, type CacheEntryOptions, type CacheKey, type Lock, type Metrics } from '@ddd-ts-kit/kernel';
4
+ import type { CacheCodec } from './cache-codec.js';
5
+ export interface RedisCacheOptions {
6
+ /** Prefix of every key, typically the bounded context: two contexts never read each other's entries. */
7
+ readonly namespace?: string;
8
+ readonly codec?: CacheCodec;
9
+ /**
10
+ * What a failing server costs. `miss` (default): a read answers `undefined`, a write is
11
+ * dropped, and the application runs without its cache. `throw`: the failure reaches the caller.
12
+ */
13
+ readonly onError?: 'miss' | 'throw';
14
+ /** Counts the failures as `cache_errors_total`, by operation and namespace. */
15
+ readonly metrics?: Metrics;
16
+ /** Lets `getOrLoad` compute a missing value in one process only: see there. */
17
+ readonly lock?: Lock;
18
+ }
19
+ export interface LoadOptions extends CacheEntryOptions {
20
+ /** How long one process may take to compute the value before another one tries. Default 10000. */
21
+ readonly lockTtlMs?: number;
22
+ /** How long the others wait for that value before computing it themselves. Default 2000. */
23
+ readonly waitMs?: number;
24
+ }
25
+ /**
26
+ * The kernel `Cache` on the Redis protocol. A value that can be computed again, never the
27
+ * source of truth: by default a server that is away costs a miss, not a failure.
28
+ */
29
+ export declare class RedisCache implements Cache {
30
+ private readonly client;
31
+ private readonly namespace;
32
+ private readonly codec;
33
+ private readonly failing;
34
+ private readonly errors;
35
+ private readonly lock;
36
+ private readonly loading;
37
+ constructor(client: Redis, options?: RedisCacheOptions);
38
+ get<T>(key: CacheKey<T>): Promise<T | undefined>;
39
+ set<T>(key: CacheKey<T>, value: T, options?: CacheEntryOptions): Promise<void>;
40
+ delete(key: CacheKey<unknown>): Promise<void>;
41
+ /**
42
+ * Deletes every entry of the namespace whose name starts with the prefix, and says how
43
+ * many. Walks the keys with `SCAN`, never `KEYS`: the server keeps answering meanwhile, and
44
+ * an entry written during the walk may be missed.
45
+ */
46
+ deleteByPrefix(prefix: string): Promise<number>;
47
+ /**
48
+ * Reads the entry, or computes it once and stores it. Concurrent callers of one process
49
+ * share a single computation. With a `lock`, the processes share it too: one computes, the
50
+ * others wait for its value up to `waitMs`, then compute it themselves rather than fail.
51
+ * `cached` of `@ddd-ts-kit/aspects` already shares the call inside a process; this is for
52
+ * the value that is expensive enough to protect across instances.
53
+ */
54
+ getOrLoad<T>(key: CacheKey<T>, load: () => Promise<T>, options?: LoadOptions): Promise<T>;
55
+ /** What a serialisation shows: a name, never the client, whose options carry the password. */
56
+ toJSON(): string;
57
+ /** What `console.log` and `util.inspect` show: the same. */
58
+ [inspect.custom](): string;
59
+ private keyOf;
60
+ private guarded;
61
+ private deleteMatching;
62
+ private loadOnce;
63
+ private lockFor;
64
+ }
65
+ //# sourceMappingURL=redis-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-cache.d.ts","sourceRoot":"","sources":["../../src/cache/redis-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAEL,KAAK,KAAK,EACV,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EAEb,KAAK,IAAI,EACT,KAAK,OAAO,EACb,MAAM,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,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAavF;IAEK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAElD;IAED;;;;OAIG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAIpD;IAED;;;;;;OAMG;IACG,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CAclG;IAED,8FAA8F;IAC9F,MAAM,IAAI,MAAM,CAEf;IAED,4DAA4D;IAC5D,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAEzB;IAED,OAAO,CAAC,KAAK;YAIC,OAAO;YAcP,cAAc;YAkBd,QAAQ;YAoBR,OAAO;CAUtB"}
@@ -0,0 +1,147 @@
1
+ import { inspect } from 'node:util';
2
+ import { NoopMetrics, } from '@ddd-ts-kit/kernel';
3
+ import { namespaced } from '../keys/namespaced.js';
4
+ import { prefixPattern } from '../keys/prefix-pattern.js';
5
+ import { conceal } from '../secrecy/conceal.js';
6
+ import { jsonCodec } from './json-codec.js';
7
+ const SCAN_BATCH = 200;
8
+ const DESCRIPTION = 'RedisCache [client concealed]';
9
+ /**
10
+ * The kernel `Cache` on the Redis protocol. A value that can be computed again, never the
11
+ * source of truth: by default a server that is away costs a miss, not a failure.
12
+ */
13
+ export class RedisCache {
14
+ client;
15
+ namespace;
16
+ codec;
17
+ failing;
18
+ errors;
19
+ lock;
20
+ loading = new Map();
21
+ constructor(client, options = {}) {
22
+ this.client = client;
23
+ this.namespace = options.namespace;
24
+ this.codec = options.codec ?? jsonCodec;
25
+ this.failing = options.onError === 'throw';
26
+ this.errors = (options.metrics ?? new NoopMetrics()).counter('cache_errors_total');
27
+ this.lock = options.lock;
28
+ conceal(this);
29
+ }
30
+ async get(key) {
31
+ const text = await this.guarded('get', () => this.client.get(this.keyOf(key.name)));
32
+ if (text === undefined || text === null) {
33
+ return undefined;
34
+ }
35
+ return this.guarded('get', async () => {
36
+ // eslint-disable-next-line ddd-ts-kit/clean-no-escape-hatch -- the server holds text: the link between a key and the type of its value is only known to the CacheKey that wrote it
37
+ return this.codec.decode(text);
38
+ });
39
+ }
40
+ async set(key, value, options = {}) {
41
+ const name = this.keyOf(key.name);
42
+ const { ttlMs } = options;
43
+ await this.guarded('set', async () => {
44
+ if (ttlMs === undefined) {
45
+ await this.client.set(name, this.codec.encode(value));
46
+ }
47
+ else if (ttlMs <= 0) {
48
+ await this.client.del(name);
49
+ }
50
+ else {
51
+ await this.client.set(name, this.codec.encode(value), 'PX', Math.ceil(ttlMs));
52
+ }
53
+ });
54
+ }
55
+ async delete(key) {
56
+ await this.guarded('delete', () => this.client.del(this.keyOf(key.name)));
57
+ }
58
+ /**
59
+ * Deletes every entry of the namespace whose name starts with the prefix, and says how
60
+ * many. Walks the keys with `SCAN`, never `KEYS`: the server keeps answering meanwhile, and
61
+ * an entry written during the walk may be missed.
62
+ */
63
+ async deleteByPrefix(prefix) {
64
+ const deleted = await this.guarded('delete', () => this.deleteMatching(prefixPattern(this.keyOf(prefix))));
65
+ return deleted ?? 0;
66
+ }
67
+ /**
68
+ * Reads the entry, or computes it once and stores it. Concurrent callers of one process
69
+ * share a single computation. With a `lock`, the processes share it too: one computes, the
70
+ * others wait for its value up to `waitMs`, then compute it themselves rather than fail.
71
+ * `cached` of `@ddd-ts-kit/aspects` already shares the call inside a process; this is for
72
+ * the value that is expensive enough to protect across instances.
73
+ */
74
+ async getOrLoad(key, load, options = {}) {
75
+ const hit = await this.get(key);
76
+ if (hit !== undefined) {
77
+ return hit;
78
+ }
79
+ const pending = this.loading.get(key.name) ?? this.loadOnce(key, load, options).finally(() => this.loading.delete(key.name));
80
+ this.loading.set(key.name, pending);
81
+ // eslint-disable-next-line ddd-ts-kit/clean-no-escape-hatch -- computations of every type share one map: the one stored under this name was started with this key
82
+ return pending;
83
+ }
84
+ /** What a serialisation shows: a name, never the client, whose options carry the password. */
85
+ toJSON() {
86
+ return DESCRIPTION;
87
+ }
88
+ /** What `console.log` and `util.inspect` show: the same. */
89
+ [inspect.custom]() {
90
+ return DESCRIPTION;
91
+ }
92
+ keyOf(name) {
93
+ return namespaced(this.namespace, name);
94
+ }
95
+ async guarded(operation, work) {
96
+ try {
97
+ return await work();
98
+ }
99
+ catch (error) {
100
+ this.errors.increment({ operation, ...(this.namespace === undefined ? {} : { context: this.namespace }) });
101
+ if (this.failing) {
102
+ throw error;
103
+ }
104
+ return undefined;
105
+ }
106
+ }
107
+ async deleteMatching(pattern) {
108
+ let cursor = '0';
109
+ let deleted = 0;
110
+ do {
111
+ const [next, keys] = await this.client.scan(cursor, 'MATCH', pattern, 'COUNT', SCAN_BATCH);
112
+ // One key per command: a cluster refuses a DEL whose keys live in different slots.
113
+ for (const key of keys) {
114
+ deleted += await this.client.del(key);
115
+ }
116
+ cursor = next;
117
+ } while (cursor !== '0');
118
+ return deleted;
119
+ }
120
+ async loadOnce(key, load, options) {
121
+ const handle = await this.lockFor(key.name, options);
122
+ try {
123
+ const filled = this.lock === undefined ? undefined : await this.get(key);
124
+ if (filled !== undefined) {
125
+ return filled;
126
+ }
127
+ const value = await load();
128
+ await this.set(key, value, options.ttlMs === undefined ? {} : { ttlMs: options.ttlMs });
129
+ return value;
130
+ }
131
+ finally {
132
+ await handle?.release().catch(() => undefined);
133
+ }
134
+ }
135
+ async lockFor(name, options) {
136
+ try {
137
+ return await this.lock?.acquire(`cache:${this.keyOf(name)}`, {
138
+ ttlMs: options.lockTtlMs ?? 10_000,
139
+ waitMs: options.waitMs ?? 2_000,
140
+ });
141
+ }
142
+ catch {
143
+ return undefined;
144
+ }
145
+ }
146
+ }
147
+ //# sourceMappingURL=redis-cache.js.map
@@ -0,0 +1 @@
1
+ {"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EAAE,OAAoB;QACtF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAErD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAEzE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,MAAM,CAAC;YAChB,CAAC;YAED,MAAM,KAAK,GAAG,MAAM,IAAI,EAAE,CAAC;YAE3B,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;YAExF,OAAO,KAAK,CAAC;QACf,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,OAAoB;QACtD,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE;gBAC3D,KAAK,EAAE,OAAO,CAAC,SAAS,IAAI,MAAM;gBAClC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK;aAChC,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import type { Redis } from 'ioredis';
2
+ /** `QUIT` when the connection is up, a plain disconnection otherwise. Resolves once the socket is closed. */
3
+ export declare function closeRedis(client: Redis): Promise<void>;
4
+ //# sourceMappingURL=close-redis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"close-redis.d.ts","sourceRoot":"","sources":["../../src/connection/close-redis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,6GAA6G;AAC7G,wBAAsB,UAAU,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAe7D"}
@@ -0,0 +1,20 @@
1
+ /** `QUIT` when the connection is up, a plain disconnection otherwise. Resolves once the socket is closed. */
2
+ export async function closeRedis(client) {
3
+ if (client.status === 'end') {
4
+ return;
5
+ }
6
+ // Between two attempts there is no socket whose closing could be awaited.
7
+ const closing = client.status === 'reconnecting' ? Promise.resolve() : ended(client);
8
+ // A connection that is not ready would queue the QUIT until it is, and may never be.
9
+ if (client.status === 'ready') {
10
+ await client.quit().catch(() => undefined);
11
+ }
12
+ client.disconnect();
13
+ await closing;
14
+ }
15
+ function ended(client) {
16
+ return new Promise((resolve) => {
17
+ client.once('end', resolve);
18
+ });
19
+ }
20
+ //# sourceMappingURL=close-redis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"close-redis.js","sourceRoot":"","sources":["../../src/connection/close-redis.ts"],"names":[],"mappings":"AAEA,6GAA6G;AAC7G,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAa;IAC5C,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;QAC5B,OAAO;IACT,CAAC;IAED,0EAA0E;IAC1E,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,KAAK,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAErF,qFAAqF;IACrF,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC9B,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,UAAU,EAAE,CAAC;IACpB,MAAM,OAAO,CAAC;AAChB,CAAC;AAED,SAAS,KAAK,CAAC,MAAa;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Redis } from 'ioredis';
2
+ import type { RedisSource } from './redis-source.js';
3
+ export interface RedisConnection {
4
+ readonly client: Redis;
5
+ /** Closes the connection when `connectRedis` opened it; a client that was handed over stays open. */
6
+ close(): Promise<void>;
7
+ }
8
+ /** One connection for every adapter of this package: Redis, Dragonfly and Valkey speak the same protocol. */
9
+ export declare function connectRedis(source: RedisSource): RedisConnection;
10
+ //# sourceMappingURL=connect-redis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-redis.d.ts","sourceRoot":"","sources":["../../src/connection/connect-redis.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAEvB,qGAAqG;IACrG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAID,6GAA6G;AAC7G,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAQjE"}
@@ -0,0 +1,26 @@
1
+ import { inspect } from 'node:util';
2
+ import { Redis } from 'ioredis';
3
+ import { closeRedis } from './close-redis.js';
4
+ import { FAIL_FAST } from './fail-fast.js';
5
+ const DESCRIPTION = 'RedisConnection [client concealed]';
6
+ /** One connection for every adapter of this package: Redis, Dragonfly and Valkey speak the same protocol. */
7
+ export function connectRedis(source) {
8
+ if (source instanceof Redis) {
9
+ return handedOut(source, async () => undefined);
10
+ }
11
+ const client = typeof source === 'string' ? new Redis(source, FAIL_FAST) : new Redis({ ...FAIL_FAST, ...source });
12
+ return handedOut(client, () => closeRedis(client));
13
+ }
14
+ /**
15
+ * The client of ioredis shows its options, password included, to whoever inspects it, and
16
+ * that cannot be changed from here. It is reached by name; a log, a spread or a serialisation
17
+ * of the connection does not lead to it.
18
+ */
19
+ function handedOut(client, close) {
20
+ return Object.defineProperties({ client, close }, {
21
+ client: { enumerable: false },
22
+ toJSON: { value: () => DESCRIPTION },
23
+ [inspect.custom]: { value: () => DESCRIPTION },
24
+ });
25
+ }
26
+ //# sourceMappingURL=connect-redis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-redis.js","sourceRoot":"","sources":["../../src/connection/connect-redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAU3C,MAAM,WAAW,GAAG,oCAAoC,CAAC;AAEzD,6GAA6G;AAC7G,MAAM,UAAU,YAAY,CAAC,MAAmB;IAC9C,IAAI,MAAM,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,EAAE,GAAG,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAElH,OAAO,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,MAAa,EAAE,KAA0B;IAC1D,OAAO,MAAM,CAAC,gBAAgB,CAC5B,EAAE,MAAM,EAAE,KAAK,EAAE,EACjB;QACE,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC7B,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE;QACpC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE;KAC/C,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { RedisConnectionOptions } from './redis-connection-options.js';
2
+ /**
3
+ * What a connection opened here adds to the defaults of ioredis, unless the options say
4
+ * otherwise: a command fails after 2 seconds and after one reconnection, instead of waiting
5
+ * for twenty. An adapter of this package then answers its `onError` policy while the server
6
+ * is away, and the application keeps serving.
7
+ */
8
+ export declare const FAIL_FAST: RedisConnectionOptions;
9
+ //# sourceMappingURL=fail-fast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fail-fast.d.ts","sourceRoot":"","sources":["../../src/connection/fail-fast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,sBAA0F,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * What a connection opened here adds to the defaults of ioredis, unless the options say
3
+ * otherwise: a command fails after 2 seconds and after one reconnection, instead of waiting
4
+ * for twenty. An adapter of this package then answers its `onError` policy while the server
5
+ * is away, and the application keeps serving.
6
+ */
7
+ export const FAIL_FAST = Object.freeze({ commandTimeout: 2_000, maxRetriesPerRequest: 1 });
8
+ //# sourceMappingURL=fail-fast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fail-fast.js","sourceRoot":"","sources":["../../src/connection/fail-fast.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAA2B,MAAM,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { RedisOptions } from 'ioredis';
2
+ /**
3
+ * The options of ioredis, without the reply mapping ioredis 6 added: the adapters of this
4
+ * package read the replies in their classic shape.
5
+ */
6
+ export type RedisConnectionOptions = Omit<RedisOptions, 'replyMapping'>;
7
+ //# sourceMappingURL=redis-connection-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-connection-options.d.ts","sourceRoot":"","sources":["../../src/connection/redis-connection-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=redis-connection-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-connection-options.js","sourceRoot":"","sources":["../../src/connection/redis-connection-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import type { Redis } from 'ioredis';
2
+ export type RedisHealth = {
3
+ readonly status: 'up';
4
+ readonly latencyMs: number;
5
+ } | {
6
+ readonly status: 'down';
7
+ readonly reason: 'timeout' | 'unreachable';
8
+ };
9
+ export interface RedisHealthOptions {
10
+ /** Default 1000. */
11
+ readonly timeoutMs?: number;
12
+ }
13
+ /** For a readiness probe: one `PING`, an answer within the timeout, and never an exception. */
14
+ export declare function redisHealth(client: Redis, options?: RedisHealthOptions): Promise<RedisHealth>;
15
+ //# sourceMappingURL=redis-health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-health.d.ts","sourceRoot":"","sources":["../../src/connection/redis-health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,aAAa,CAAA;CAAE,CAAC;AAE5E,MAAM,WAAW,kBAAkB;IACjC,oBAAoB;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,+FAA+F;AAC/F,wBAAsB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CAkBvG"}
@@ -0,0 +1,31 @@
1
+ /** For a readiness probe: one `PING`, an answer within the timeout, and never an exception. */
2
+ export async function redisHealth(client, options = {}) {
3
+ const started = performance.now();
4
+ const timer = new AbortController();
5
+ try {
6
+ const answered = await Promise.race([
7
+ client.ping().then(() => true),
8
+ expiry(options.timeoutMs ?? 1_000, timer.signal),
9
+ ]);
10
+ return answered
11
+ ? { status: 'up', latencyMs: Math.round(performance.now() - started) }
12
+ : { status: 'down', reason: 'timeout' };
13
+ }
14
+ catch {
15
+ return { status: 'down', reason: 'unreachable' };
16
+ }
17
+ finally {
18
+ timer.abort();
19
+ }
20
+ }
21
+ function expiry(ms, cancelled) {
22
+ return new Promise((resolve) => {
23
+ const timeout = setTimeout(() => {
24
+ resolve(false);
25
+ }, ms);
26
+ cancelled.addEventListener('abort', () => {
27
+ clearTimeout(timeout);
28
+ });
29
+ });
30
+ }
31
+ //# sourceMappingURL=redis-health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-health.js","sourceRoot":"","sources":["../../src/connection/redis-health.ts"],"names":[],"mappings":"AAWA,+F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 @@
1
+ import type { Redis } from 'ioredis';
2
+ import type { RedisConnectionOptions } from './redis-connection-options.js';
3
+ /** A client the application already owns, a connection URL, or the options of ioredis. */
4
+ export type RedisSource = Redis | RedisConnectionOptions | string;
5
+ //# sourceMappingURL=redis-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-source.d.ts","sourceRoot":"","sources":["../../src/connection/redis-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,0FAA0F;AAC1F,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,sBAAsB,GAAG,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=redis-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-source.js","sourceRoot":"","sources":["../../src/connection/redis-source.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ export { RedisStreamsEventBus } from './streams/redis-streams-event-bus.js';
2
+ export { DEFAULT_PREFIX } from './streams/options/default-prefix.js';
3
+ export type { DeduplicationOptions } from './streams/options/deduplication-options.js';
4
+ export type { ReconnectOptions } from './streams/options/reconnect-options.js';
5
+ export type { RedisStreamsDelivery } from './streams/options/redis-streams-delivery.js';
6
+ export type { RedisStreamsEventBusOptions } from './streams/options/redis-streams-event-bus-options.js';
7
+ export type { RedisStreamsFailure } from './streams/options/redis-streams-failure.js';
8
+ export type { RetentionOptions } from './streams/options/retention-options.js';
9
+ export type { RetryOptions } from './streams/options/retry-options.js';
10
+ export { streamNamesOf } from './streams/topology/stream-names-of.js';
11
+ export type { ConsumerBinding } from './streams/topology/consumer-binding.js';
12
+ export type { GroupDescription } from './streams/topology/group-description.js';
13
+ export type { RedisStreamsTopology } from './streams/topology/redis-streams-topology.js';
14
+ export type { StreamDescription } from './streams/topology/stream-description.js';
15
+ export type { StreamNames } from './streams/topology/stream-names.js';
16
+ export { ATTEMPT_FIELD, CONSUMER_FIELD, CORRELATION_FIELD, DEAD_REASON_FIELD, ENTRY_ID_FIELD, ENVELOPE_FIELD, ERROR_CODE_FIELD, EVENT_ID_FIELD, EVENT_TYPE_FIELD, EVENT_VERSION_FIELD, REPLAY_FOR_FIELD, TRACEPARENT_FIELD, } from './streams/codec/entry-fields.js';
17
+ export { ATTEMPTS_EXHAUSTED, POISON_ENTRY } from './streams/settlement.js';
18
+ export { BrokerUnavailableError } from './streams/errors/broker-unavailable-error.js';
19
+ export { ConsumerNameRequiredError } from './streams/errors/consumer-name-required-error.js';
20
+ export { EventBusClosedError } from './streams/errors/event-bus-closed-error.js';
21
+ export { PublishNotConfirmedError } from './streams/errors/publish-not-confirmed-error.js';
22
+ //# sourceMappingURL=event-bus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../src/event-bus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AACvF,YAAY,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,YAAY,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACxF,YAAY,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAC;AACxG,YAAY,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,YAAY,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAC9E,YAAY,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAChF,YAAY,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AACzF,YAAY,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAClF,YAAY,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EACL,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { RedisStreamsEventBus } from './streams/redis-streams-event-bus.js';
2
+ export { DEFAULT_PREFIX } from './streams/options/default-prefix.js';
3
+ export { streamNamesOf } from './streams/topology/stream-names-of.js';
4
+ export { ATTEMPT_FIELD, CONSUMER_FIELD, CORRELATION_FIELD, DEAD_REASON_FIELD, ENTRY_ID_FIELD, ENVELOPE_FIELD, ERROR_CODE_FIELD, EVENT_ID_FIELD, EVENT_TYPE_FIELD, EVENT_VERSION_FIELD, REPLAY_FOR_FIELD, TRACEPARENT_FIELD, } from './streams/codec/entry-fields.js';
5
+ export { ATTEMPTS_EXHAUSTED, POISON_ENTRY } from './streams/settlement.js';
6
+ export { BrokerUnavailableError } from './streams/errors/broker-unavailable-error.js';
7
+ export { ConsumerNameRequiredError } from './streams/errors/consumer-name-required-error.js';
8
+ export { EventBusClosedError } from './streams/errors/event-bus-closed-error.js';
9
+ export { PublishNotConfirmedError } from './streams/errors/publish-not-confirmed-error.js';
10
+ //# sourceMappingURL=event-bus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../src/event-bus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAQrE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAMtE,OAAO,EACL,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC"}
@@ -0,0 +1,17 @@
1
+ export { RedisCache, type LoadOptions, type RedisCacheOptions } from './cache/redis-cache.js';
2
+ export type { CacheCodec } from './cache/cache-codec.js';
3
+ export type { CacheOperation } from './cache/cache-operation.js';
4
+ export { jsonCodec } from './cache/json-codec.js';
5
+ export { closeRedis } from './connection/close-redis.js';
6
+ export { connectRedis, type RedisConnection } from './connection/connect-redis.js';
7
+ export { FAIL_FAST } from './connection/fail-fast.js';
8
+ export type { RedisConnectionOptions } from './connection/redis-connection-options.js';
9
+ export { redisHealth, type RedisHealth, type RedisHealthOptions } from './connection/redis-health.js';
10
+ export type { RedisSource } from './connection/redis-source.js';
11
+ export { RedisLock, type RedisLockOptions } from './lock/redis-lock.js';
12
+ export { RedisRateLimiter, type RedisRateLimiterOptions } from './rate-limiter/redis-rate-limiter.js';
13
+ export { RedisRelaySignal, type RedisRelaySignalOptions } from './relay/redis-relay-signal.js';
14
+ export { relayWakeUpMiddleware } from './relay/relay-wake-up-middleware.js';
15
+ export { InMemoryLock, Lock, type AcquireOptions, type LockHandle, type WaitingOptions } from '@ddd-ts-kit/kernel';
16
+ export { InMemoryRateLimiter, RateLimiter, type RateLimit, type RateLimitDecision } from '@ddd-ts-kit/kernel';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,YAAY,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACtG,YAAY,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ export { RedisCache } from './cache/redis-cache.js';
2
+ export { jsonCodec } from './cache/json-codec.js';
3
+ export { closeRedis } from './connection/close-redis.js';
4
+ export { connectRedis } from './connection/connect-redis.js';
5
+ export { FAIL_FAST } from './connection/fail-fast.js';
6
+ export { redisHealth } from './connection/redis-health.js';
7
+ export { RedisLock } from './lock/redis-lock.js';
8
+ export { RedisRateLimiter } from './rate-limiter/redis-rate-limiter.js';
9
+ export { RedisRelaySignal } from './relay/redis-relay-signal.js';
10
+ export { relayWakeUpMiddleware } from './relay/relay-wake-up-middleware.js';
11
+ export { InMemoryLock, Lock } from '@ddd-ts-kit/kernel';
12
+ export { InMemoryRateLimiter, RateLimiter } from '@ddd-ts-kit/kernel';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4C,MAAM,wBAAwB,CAAC;AAG9F,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAwB,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,WAAW,EAA6C,MAAM,8BAA8B,CAAC;AAEtG,OAAO,EAAE,SAAS,EAAyB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAgC,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAgC,MAAM,+BAA+B,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,IAAI,EAA6D,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAA0C,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** `namespace:name`, or the name alone: one namespace per bounded context keeps their keys apart. */
2
+ export declare function namespaced(namespace: string | undefined, name: string): string;
3
+ //# sourceMappingURL=namespaced.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespaced.d.ts","sourceRoot":"","sources":["../../src/keys/namespaced.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9E"}
@@ -0,0 +1,5 @@
1
+ /** `namespace:name`, or the name alone: one namespace per bounded context keeps their keys apart. */
2
+ export function namespaced(namespace, name) {
3
+ return namespace === undefined ? name : `${namespace}:${name}`;
4
+ }
5
+ //# sourceMappingURL=namespaced.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespaced.js","sourceRoot":"","sources":["../../src/keys/namespaced.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,MAAM,UAAU,UAAU,CAAC,SAA6B,EAAE,IAAY;IACpE,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC;AACjE,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The glob pattern matching every key that starts with the prefix, whatever it contains. */
2
+ export declare function prefixPattern(prefix: string): string;
3
+ //# sourceMappingURL=prefix-pattern.d.ts.map