@mark1russell7/service 0.8.19 → 0.8.20

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 (331) hide show
  1. package/build/backoff.d.ts +44 -2
  2. package/build/{builder-zO48Vgoj.d.ts → builder.d.ts} +14 -101
  3. package/build/builder.js +499 -0
  4. package/build/builder.js.map +1 -0
  5. package/build/{call-context-DDhcVvn5.d.ts → call-context.d.ts} +3 -4
  6. package/build/channel.d.ts +1 -1
  7. package/build/{core-BSzt4RI2.d.ts → client/core.d.ts} +32 -61
  8. package/build/{machine-BhVeHr_m.js → client/core.js} +4 -153
  9. package/build/client/core.js.map +1 -0
  10. package/build/{dial-ChwIcvd4.d.ts → client/dial.d.ts} +3 -4
  11. package/build/client/dial.js +52 -0
  12. package/build/client/dial.js.map +1 -0
  13. package/build/client/machine.js +29 -0
  14. package/build/client/machine.js.map +1 -0
  15. package/build/client/meets.d.ts +35 -0
  16. package/build/client/meets.js +78 -0
  17. package/build/client/meets.js.map +1 -0
  18. package/build/clock.d.ts +1 -1
  19. package/build/conformance.d.ts +122 -0
  20. package/build/conformance.js +470 -0
  21. package/build/conformance.js.map +1 -0
  22. package/build/contract.d.ts +28 -0
  23. package/build/contract.js +184 -0
  24. package/build/contract.js.map +1 -0
  25. package/build/description.d.ts +161 -0
  26. package/build/description.js +11 -0
  27. package/build/description.js.map +1 -0
  28. package/build/drains.js +35 -0
  29. package/build/drains.js.map +1 -0
  30. package/build/events.d.ts +25 -0
  31. package/build/fakes.d.ts +43 -0
  32. package/build/fakes.js +93 -0
  33. package/build/fakes.js.map +1 -0
  34. package/build/grpc/client.d.ts +153 -0
  35. package/build/grpc/client.js +474 -0
  36. package/build/grpc/client.js.map +1 -0
  37. package/build/grpc/connection.d.ts +97 -0
  38. package/build/grpc/connection.js +59 -0
  39. package/build/grpc/connection.js.map +1 -0
  40. package/build/grpc/machine.d.ts +12 -0
  41. package/build/grpc/machine.js +149 -0
  42. package/build/grpc/machine.js.map +1 -0
  43. package/build/grpc/meets.d.ts +14 -0
  44. package/build/grpc/meets.js +105 -0
  45. package/build/grpc/meets.js.map +1 -0
  46. package/build/grpc/starting.d.ts +33 -0
  47. package/build/grpc/starting.js +89 -0
  48. package/build/grpc/starting.js.map +1 -0
  49. package/build/grpc.d.ts +9 -303
  50. package/build/grpc.js +7 -854
  51. package/build/health.d.ts +93 -0
  52. package/build/health.js +223 -0
  53. package/build/health.js.map +1 -0
  54. package/build/heartbeat.d.ts +1 -1
  55. package/build/host/discovery.d.ts +61 -0
  56. package/build/host/discovery.js +113 -0
  57. package/build/host/discovery.js.map +1 -0
  58. package/build/host/env.d.ts +14 -0
  59. package/build/host/env.js +57 -0
  60. package/build/host/env.js.map +1 -0
  61. package/build/host/fakes.d.ts +82 -0
  62. package/build/host/fakes.js +239 -0
  63. package/build/host/fakes.js.map +1 -0
  64. package/build/host/group.d.ts +142 -0
  65. package/build/host/group.js +517 -0
  66. package/build/host/group.js.map +1 -0
  67. package/build/host/install.d.ts +96 -0
  68. package/build/host/install.js +330 -0
  69. package/build/host/install.js.map +1 -0
  70. package/build/host/lock.d.ts +78 -0
  71. package/build/host/lock.js +190 -0
  72. package/build/host/lock.js.map +1 -0
  73. package/build/host/logs.d.ts +26 -0
  74. package/build/host/logs.js +48 -0
  75. package/build/host/logs.js.map +1 -0
  76. package/build/host/node.d.ts +14 -0
  77. package/build/host/node.js +309 -0
  78. package/build/host/node.js.map +1 -0
  79. package/build/{ports-B1ayTL-j.d.ts → host/ports.d.ts} +15 -16
  80. package/build/host/ports.js +17 -0
  81. package/build/host/ports.js.map +1 -0
  82. package/build/host/probes.d.ts +51 -0
  83. package/build/host/probes.js +139 -0
  84. package/build/host/probes.js.map +1 -0
  85. package/build/host/processes.d.ts +32 -0
  86. package/build/host/processes.js +63 -0
  87. package/build/host/processes.js.map +1 -0
  88. package/build/host/render.d.ts +84 -0
  89. package/build/host/render.js +235 -0
  90. package/build/host/render.js.map +1 -0
  91. package/build/host/watch.d.ts +90 -0
  92. package/build/host/watch.js +165 -0
  93. package/build/host/watch.js.map +1 -0
  94. package/build/host.d.ts +13 -671
  95. package/build/host.js +12 -2126
  96. package/build/http/answers.js +29 -0
  97. package/build/http/answers.js.map +1 -0
  98. package/build/http/fake-server.js +61 -0
  99. package/build/http/fake-server.js.map +1 -0
  100. package/build/http/outcome.d.ts +115 -0
  101. package/build/http/outcome.js +325 -0
  102. package/build/http/outcome.js.map +1 -0
  103. package/build/http/probes.d.ts +83 -0
  104. package/build/http/probes.js +232 -0
  105. package/build/http/probes.js.map +1 -0
  106. package/build/http/transport.d.ts +165 -0
  107. package/build/http/transport.js +517 -0
  108. package/build/http/transport.js.map +1 -0
  109. package/build/http-client/client.d.ts +121 -0
  110. package/build/http-client/client.js +330 -0
  111. package/build/http-client/client.js.map +1 -0
  112. package/build/http-client/connection.d.ts +78 -0
  113. package/build/http-client/connection.js +54 -0
  114. package/build/http-client/connection.js.map +1 -0
  115. package/build/http-client/machine.d.ts +14 -0
  116. package/build/http-client/machine.js +109 -0
  117. package/build/http-client/machine.js.map +1 -0
  118. package/build/http-client/meets.d.ts +11 -0
  119. package/build/http-client/meets.js +74 -0
  120. package/build/http-client/meets.js.map +1 -0
  121. package/build/http-client/session.d.ts +87 -0
  122. package/build/http-client/session.js +99 -0
  123. package/build/http-client/session.js.map +1 -0
  124. package/build/http-client/starting.d.ts +25 -0
  125. package/build/http-client/starting.js +65 -0
  126. package/build/http-client/starting.js.map +1 -0
  127. package/build/http-client.d.ts +9 -330
  128. package/build/http-client.js +8 -707
  129. package/build/http.d.ts +5 -353
  130. package/build/http.js +3 -1086
  131. package/build/identity.d.ts +16 -0
  132. package/build/identity.js +44 -0
  133. package/build/identity.js.map +1 -0
  134. package/build/index.d.ts +35 -412
  135. package/build/index.js +24 -3277
  136. package/build/knobs.d.ts +1 -0
  137. package/build/{knobs-BJcz6m01.js → knobs.js} +2 -34
  138. package/build/knobs.js.map +1 -0
  139. package/build/latch.d.ts +29 -0
  140. package/build/latch.js +122 -0
  141. package/build/latch.js.map +1 -0
  142. package/build/{rules-HyFCBStQ.d.ts → law.d.ts} +19 -37
  143. package/build/law.js +149 -0
  144. package/build/law.js.map +1 -0
  145. package/build/lifecycle.d.ts +144 -0
  146. package/build/lifecycle.js +411 -0
  147. package/build/lifecycle.js.map +1 -0
  148. package/build/limiter/machine.d.ts +40 -0
  149. package/build/limiter/machine.js +279 -0
  150. package/build/limiter/machine.js.map +1 -0
  151. package/build/{policy-CBcK2XGg.d.ts → limiter/policy.d.ts} +28 -29
  152. package/build/{policy-UYALkqVq.js → limiter/policy.js} +10 -9
  153. package/build/limiter/policy.js.map +1 -0
  154. package/build/{limiter-BNKnwzeY.d.ts → limiter/quota.d.ts} +32 -74
  155. package/build/{limiter-DrM0PQV9.js → limiter/quota.js} +3 -418
  156. package/build/limiter/quota.js.map +1 -0
  157. package/build/{store-DFwFKrsB.d.ts → limiter/store.d.ts} +10 -11
  158. package/build/limiter/store.js +145 -0
  159. package/build/limiter/store.js.map +1 -0
  160. package/build/limiter.d.ts +4 -3
  161. package/build/limiter.js +4 -2
  162. package/build/lint.d.ts +152 -0
  163. package/build/lint.js +576 -0
  164. package/build/lint.js.map +1 -0
  165. package/build/logger.d.ts +71 -0
  166. package/build/logger.js +183 -0
  167. package/build/logger.js.map +1 -0
  168. package/build/machines.d.ts +41 -0
  169. package/build/machines.js +451 -0
  170. package/build/machines.js.map +1 -0
  171. package/build/metrics.d.ts +53 -0
  172. package/build/metrics.js +111 -0
  173. package/build/metrics.js.map +1 -0
  174. package/build/mongodb/client.d.ts +131 -0
  175. package/build/mongodb/client.js +388 -0
  176. package/build/mongodb/client.js.map +1 -0
  177. package/build/mongodb/connection.d.ts +112 -0
  178. package/build/mongodb/connection.js +12 -0
  179. package/build/mongodb/connection.js.map +1 -0
  180. package/build/mongodb/machine.d.ts +14 -0
  181. package/build/mongodb/machine.js +122 -0
  182. package/build/mongodb/machine.js.map +1 -0
  183. package/build/mongodb/meets.d.ts +15 -0
  184. package/build/mongodb/meets.js +103 -0
  185. package/build/mongodb/meets.js.map +1 -0
  186. package/build/mongodb/starting.d.ts +29 -0
  187. package/build/mongodb/starting.js +77 -0
  188. package/build/mongodb/starting.js.map +1 -0
  189. package/build/mongodb.d.ts +8 -296
  190. package/build/mongodb.js +7 -682
  191. package/build/operation.d.ts +27 -0
  192. package/build/{operation-DF73RZOI.js → operation.js} +2 -2
  193. package/build/operation.js.map +1 -0
  194. package/build/otel.d.ts +2 -2
  195. package/build/pg/client.d.ts +96 -0
  196. package/build/pg/client.js +277 -0
  197. package/build/pg/client.js.map +1 -0
  198. package/build/pg/connection.d.ts +75 -0
  199. package/build/pg/connection.js +11 -0
  200. package/build/pg/connection.js.map +1 -0
  201. package/build/pg/machine.d.ts +13 -0
  202. package/build/pg/machine.js +111 -0
  203. package/build/pg/machine.js.map +1 -0
  204. package/build/pg/meets.d.ts +14 -0
  205. package/build/pg/meets.js +83 -0
  206. package/build/pg/meets.js.map +1 -0
  207. package/build/pg/starting.d.ts +26 -0
  208. package/build/pg/starting.js +62 -0
  209. package/build/pg/starting.js.map +1 -0
  210. package/build/pg.d.ts +8 -219
  211. package/build/pg.js +7 -525
  212. package/build/poller.d.ts +9 -0
  213. package/build/poller.js +152 -0
  214. package/build/poller.js.map +1 -0
  215. package/build/process.d.ts +114 -0
  216. package/build/process.js +170 -0
  217. package/build/process.js.map +1 -0
  218. package/build/profiles.d.ts +68 -0
  219. package/build/profiles.js +120 -0
  220. package/build/profiles.js.map +1 -0
  221. package/build/{queue-DXdw1vLO.d.ts → queue.d.ts} +16 -29
  222. package/build/queue.js +279 -0
  223. package/build/queue.js.map +1 -0
  224. package/build/rabbitmq/client.d.ts +144 -0
  225. package/build/rabbitmq/client.js +426 -0
  226. package/build/rabbitmq/client.js.map +1 -0
  227. package/build/rabbitmq/connection.d.ts +91 -0
  228. package/build/rabbitmq/connection.js +15 -0
  229. package/build/rabbitmq/connection.js.map +1 -0
  230. package/build/rabbitmq/machine.d.ts +13 -0
  231. package/build/rabbitmq/machine.js +159 -0
  232. package/build/rabbitmq/machine.js.map +1 -0
  233. package/build/rabbitmq/meets.d.ts +12 -0
  234. package/build/rabbitmq/meets.js +96 -0
  235. package/build/rabbitmq/meets.js.map +1 -0
  236. package/build/rabbitmq/starting.d.ts +27 -0
  237. package/build/rabbitmq/starting.js +67 -0
  238. package/build/rabbitmq/starting.js.map +1 -0
  239. package/build/rabbitmq.d.ts +8 -283
  240. package/build/rabbitmq.js +7 -742
  241. package/build/redis/client.d.ts +86 -0
  242. package/build/redis/client.js +285 -0
  243. package/build/redis/client.js.map +1 -0
  244. package/build/redis/connection.d.ts +57 -0
  245. package/build/redis/connection.js +11 -0
  246. package/build/redis/connection.js.map +1 -0
  247. package/build/redis/limiter.d.ts +43 -0
  248. package/build/redis/limiter.js +164 -0
  249. package/build/redis/limiter.js.map +1 -0
  250. package/build/redis/machine.d.ts +12 -0
  251. package/build/redis/machine.js +144 -0
  252. package/build/redis/machine.js.map +1 -0
  253. package/build/redis/meets.d.ts +11 -0
  254. package/build/redis/meets.js +75 -0
  255. package/build/redis/meets.js.map +1 -0
  256. package/build/redis/operations.d.ts +5 -0
  257. package/build/redis/operations.js +114 -0
  258. package/build/redis/operations.js.map +1 -0
  259. package/build/redis.d.ts +10 -207
  260. package/build/redis.js +9 -771
  261. package/build/requests.d.ts +66 -0
  262. package/build/requests.js +279 -0
  263. package/build/requests.js.map +1 -0
  264. package/build/retrier.d.ts +62 -0
  265. package/build/{retrier-Dnjhvxol.js → retrier.js} +2 -2
  266. package/build/retrier.js.map +1 -0
  267. package/build/routes.d.ts +35 -0
  268. package/build/routes.js +77 -0
  269. package/build/routes.js.map +1 -0
  270. package/build/rules.d.ts +19 -2
  271. package/build/stops.d.ts +51 -0
  272. package/build/stops.js +86 -0
  273. package/build/stops.js.map +1 -0
  274. package/build/testing.d.ts +8 -270
  275. package/build/testing.js +4 -1027
  276. package/build/testing.js.map +1 -1
  277. package/build/timing.d.ts +63 -0
  278. package/build/{timing-DZl36uXs.js → timing.js} +2 -2
  279. package/build/timing.js.map +1 -0
  280. package/build/units.d.ts +17 -0
  281. package/build/units.js +236 -0
  282. package/build/units.js.map +1 -0
  283. package/build/watchdog.d.ts +34 -0
  284. package/build/watchdog.js +53 -0
  285. package/build/watchdog.js.map +1 -0
  286. package/build/websocket/client.d.ts +136 -0
  287. package/build/websocket/client.js +422 -0
  288. package/build/websocket/client.js.map +1 -0
  289. package/build/websocket/connection.d.ts +83 -0
  290. package/build/websocket/connection.js +57 -0
  291. package/build/websocket/connection.js.map +1 -0
  292. package/build/websocket/machine.d.ts +12 -0
  293. package/build/websocket/machine.js +155 -0
  294. package/build/websocket/machine.js.map +1 -0
  295. package/build/websocket/meets.d.ts +14 -0
  296. package/build/websocket/meets.js +92 -0
  297. package/build/websocket/meets.js.map +1 -0
  298. package/build/websocket/starting.d.ts +25 -0
  299. package/build/websocket/starting.js +69 -0
  300. package/build/websocket/starting.js.map +1 -0
  301. package/build/websocket.d.ts +9 -264
  302. package/build/websocket.js +8 -774
  303. package/build/worker.d.ts +92 -0
  304. package/build/worker.js +153 -0
  305. package/build/worker.js.map +1 -0
  306. package/package.json +4 -3
  307. package/build/backoff-QTRGfkEK.d.ts +0 -45
  308. package/build/clock-DpVgpY4h.d.ts +0 -2
  309. package/build/grpc.js.map +0 -1
  310. package/build/host.js.map +0 -1
  311. package/build/http-client.js.map +0 -1
  312. package/build/http.js.map +0 -1
  313. package/build/index.js.map +0 -1
  314. package/build/knobs-BJcz6m01.js.map +0 -1
  315. package/build/lifecycle-D0J-zwZF.d.ts +0 -374
  316. package/build/limiter-DrM0PQV9.js.map +0 -1
  317. package/build/logger-B6drv9w0.d.ts +0 -488
  318. package/build/machine-BhVeHr_m.js.map +0 -1
  319. package/build/mongodb.js.map +0 -1
  320. package/build/operation-DF73RZOI.js.map +0 -1
  321. package/build/pg.js.map +0 -1
  322. package/build/policy-UYALkqVq.js.map +0 -1
  323. package/build/process-7R9M29wN.js +0 -437
  324. package/build/process-7R9M29wN.js.map +0 -1
  325. package/build/rabbitmq.js.map +0 -1
  326. package/build/redis.js.map +0 -1
  327. package/build/requests-DD2ALv0_.js +0 -583
  328. package/build/requests-DD2ALv0_.js.map +0 -1
  329. package/build/retrier-Dnjhvxol.js.map +0 -1
  330. package/build/timing-DZl36uXs.js.map +0 -1
  331. package/build/websocket.js.map +0 -1
package/build/redis.d.ts CHANGED
@@ -1,207 +1,10 @@
1
- import { C as MANIFESTATIONS, D as firstDetector, E as Situation, O as unwatched, S as Detector, T as Meeting, _ as Sent, a as ClientKnobs, c as ClientSpec, d as Factory, g as SendOptions, i as ClientJoin, l as ClientStep, n as CheckOptions, o as ClientOptions, p as RetryKnobs, r as Client, s as ClientSocket, t as Attempt, u as DialFn, w as Manifestation, y as retryBackoff } from "./core-BSzt4RI2.js";
2
- import { ut as Operation, z as heartbeatDetection } from "./logger-B6drv9w0.js";
3
- import { n as Clock } from "./clock-DpVgpY4h.js";
4
- import { n as LimiterStore } from "./store-DFwFKrsB.js";
5
- import { Extent, Quantity } from "@mark1russell7/quantity";
6
- import { Machine } from "@mark1russell7/algebra";
7
- /**
8
- * A Redis connection is the part of an ioredis client that the wrapper uses. An ioredis 6 client has
9
- * each part. A fake for tests has them too. Thus the package depends on no type of ioredis.
10
- */
11
- interface RedisConnection {
12
- /** This text is the state of the client: wait, connecting, connect, ready, close, reconnecting or end. */
13
- readonly status: string;
14
- /** This socket is the socket of the current connection, when there is one. */
15
- readonly stream?: RedisSocket | undefined;
16
- connect(): Promise<void>;
17
- /** This method sends one command, and gives the reply. */
18
- call(command: string, ...args: Array<string | number>): Promise<unknown>;
19
- quit(): Promise<unknown>;
20
- /** This method closes the connection at once. With `true`, the client then connects again. */
21
- disconnect(reconnect?: boolean): void;
22
- on(event: string, listener: (...args: unknown[]) => void): unknown;
23
- off(event: string, listener: (...args: unknown[]) => void): unknown;
24
- }
25
- /** A Redis socket is the socket of a client in the core: the join of the prober and the bounded close read it. */
26
- type RedisSocket = ClientSocket;
27
- /**
28
- * These are the options that the wrapper gives ioredis. Each one comes from the declaration. The
29
- * wrapper sets each option that has an effect on a timer or on a send again, thus no default of
30
- * ioredis decides one.
31
- */
32
- interface RedisConnectionOptions {
33
- readonly host: string;
34
- readonly port: number;
35
- readonly db?: number | undefined;
36
- readonly username?: string | undefined;
37
- readonly password?: string | undefined;
38
- /** The wrapper connects in its own step of the startup. */
39
- readonly lazyConnect: true;
40
- readonly connectTimeout: number;
41
- readonly commandTimeout: number;
42
- /** This time destroys a socket that gives no data while a command waits. Undefined is no bound. */
43
- readonly socketTimeout: number | undefined;
44
- /** This time is the idle time of TCP keepalive. False is no keepalive. */
45
- readonly keepAlive: number | false;
46
- /** A command while the client is not ready fails at once: it did not reach the server. */
47
- readonly enableOfflineQueue: false;
48
- /** The client does not send again a command that can have reached the server. */
49
- readonly autoResendUnfulfilledCommands: false;
50
- readonly maxRetriesPerRequest: null;
51
- readonly enableReadyCheck: true;
52
- readonly connectionName: string;
53
- /** This function gives the delay before the next try to connect, or null to stop. */
54
- readonly retryStrategy: (times: number) => number | null;
55
- }
56
- /** A connection factory makes the connection of the client from its options. */
57
- type ConnectionFactory = Factory<RedisConnectionOptions, RedisConnection>;
58
- /**
59
- * This factory makes an ioredis client. It loads ioredis only when a client connects, thus a
60
- * service that does not use Redis does not need ioredis.
61
- */
62
- export declare const ioredis: ConnectionFactory;
63
- /**
64
- * These are the knobs of the client, each a time, by the names of the ordering law where the law
65
- * has them. The runtime has no defaults, thus each knob is necessary, and a bound that nobody gives
66
- * is "infinite", not zero. The knobs that each client has come from the core.
67
- */
68
- interface RedisKnobs extends ClientKnobs, RetryKnobs {
69
- /** This time bounds a try to connect, until the TCP connection exists (`connectTimeout`). */
70
- readonly connect_bound: Quantity;
71
- /** This time bounds each command, the handshake commands too (`commandTimeout`). */
72
- readonly request_timeout: Quantity;
73
- /** This time destroys a socket that gives no data while a command waits (`socketTimeout`). */
74
- readonly driver_writeoff_time: Extent;
75
- /** This time is the interval of the in-band watchdog: a PING on the connection of the application. */
76
- readonly heartbeat_interval: Extent;
77
- /** This time bounds each PING of the watchdog. */
78
- readonly heartbeat_timeout: Quantity;
79
- /** This time is how long the client tries to connect again before it stops. The watchdog then starts it again. */
80
- readonly client_retry_window: Extent;
81
- /** This time is the first delay before a new try to connect. The delay doubles after each try. */
82
- readonly retry_base: Quantity;
83
- /** This time is the most that one delay can be, before its jitter. */
84
- readonly retry_cap: Quantity;
85
- /** This time bounds the close of the client at the shutdown: a QUIT, then a disconnect. */
86
- readonly close_bound: Quantity;
87
- /** This time is the age at which the client replaces its connection. The client supports only "infinite". */
88
- readonly max_connection_age: Extent;
89
- }
90
- /** A Redis client spec is the declaration of one Redis client: where it connects, and its knobs. */
91
- interface RedisClientSpec extends ClientSpec<RedisKnobs> {
92
- readonly db?: number | undefined;
93
- readonly username?: string | undefined;
94
- /** This count is the number of PINGs in sequence without an answer that make the watchdog connect again. */
95
- readonly heartbeatMisses: number;
96
- }
97
- /** These options make a client. Without them, it uses ioredis, the real clock and `Math.random`. */
98
- interface RedisClientOptions extends ClientOptions<ConnectionFactory> {
99
- readonly random?: (() => number) | undefined;
100
- /**
101
- * This function waits one turn of the event loop. The watchdog waits it before it counts a miss,
102
- * thus a reply that is in the socket is read first. Without it, the client uses `setImmediate`.
103
- */
104
- readonly turn?: (() => Promise<void>) | undefined;
105
- }
106
- /**
107
- * A join is one generation of the connection, at its `ready` (D1, D2). The prober joins its kernel
108
- * records to the server's view of the connection through it. A join holds the server's id of the
109
- * connection, and the local address and port of the socket.
110
- */
111
- interface Join extends ClientJoin {
112
- /** This number is the reply of CLIENT ID, or null when the server gave none. */
113
- readonly clientId: number | null;
114
- }
115
- /** A Redis client is a dependency of a service: its declaration, its handle, its checks and its commands. */
116
- interface RedisClient extends Client<ClientStep, Join> {
117
- /** This text is the state of the connection, as ioredis names it, or "none" before the connect. */
118
- readonly status: string;
119
- /**
120
- * This method sends a command, and gives its outcome in three values. The client sends again
121
- * only an idempotent operation, one time at most, after an outcome that is not certain. The
122
- * second try stays in the bound of the request. The client does not send again an operation that
123
- * the table does not name.
124
- */
125
- send<T = unknown>(command: string, args?: ReadonlyArray<string | number>, options?: SendOptions): Promise<Sent<T>>;
126
- }
127
- /** This function gives the problems of a spec: the knobs that the client cannot use. */
128
- export declare const specProblems: (name: string, spec: RedisClientSpec) => string[];
129
- /** This dial function opens a TCP connection, sends an inline PING, and waits for +PONG. */
130
- export declare const tcpDial: DialFn;
131
- /**
132
- * This function makes a Redis client. It is a dependency of a service, with ioredis under it:
133
- * - It sets each timer of ioredis from the declaration, and it does not let ioredis send a command
134
- * again (R5 §8).
135
- * - It tells the outcome of a command in three values, and it settles each command in flight as
136
- * indeterminate when its connection closes (C8, C10).
137
- * - It records the server's id of each connection at `ready` (D1).
138
- * - A watchdog sends a PING in the band of the connection, and it connects again after the misses
139
- * of the declaration. It also starts a client that stopped (principle 19).
140
- *
141
- * The outcomes, the second try, the commands in flight, the bounded close and the checks come
142
- * from the core of the clients. This entry gives what ioredis does in its own way.
143
- */
144
- export declare const redisClient: (name: string, spec: RedisClientSpec, options?: RedisClientOptions) => RedisClient;
145
- /**
146
- * This function gives the manifestations that a Redis client can meet, and the detectors of each, from
147
- * its knobs. A reset or a FIN arrives on the next segment. A black hole and a host that is gone give
148
- * no answer at all. A frozen process and a stalled server keep a kernel that acknowledges each
149
- * segment. Thus TCP keepalive does not fire on them, and only the client's own timers find them.
150
- */
151
- export declare const meetings: (name: string, knobs: RedisKnobs, heartbeat: Extent) => Meeting[];
152
- /**
153
- * This script decides one take in one atomic step of Redis. It does the arithmetic of `decide`, and
154
- * it reads `TIME` of the server, the one clock of all replicas. A test can give the time in its place.
155
- * - KEYS[1] is the state of the key. KEYS[2] is the index of the limiter, a sorted set of its keys
156
- * by the time at which each key is free.
157
- * - ARGV is the type of the rule, its two numbers, the cap of keys and the key. Then it has the
158
- * time or "", and the units of the take. The store refuses a take over the capacity before the script, thus the units
159
- * are at most the capacity.
160
- * - The state of a bucket is its full time. The state of a window is the time of each take in it.
161
- * - The state expires at its free time (PX), and the index lets the cap count only busy keys.
162
- * - The reply is `{1, remaining}`, or `{0, retryAfter, cause}` with the time as text. Redis gives
163
- * each Lua number as a whole number, thus the fraction of a millisecond goes as text.
164
- */
165
- export declare const LIMITER_SCRIPT = "\nlocal kind = ARGV[1]\nlocal a = tonumber(ARGV[2])\nlocal b = tonumber(ARGV[3])\nlocal cap = tonumber(ARGV[4])\nlocal member = ARGV[5]\nlocal units = tonumber(ARGV[7])\nlocal now\nif ARGV[6] == '' then\n local t = redis.call('TIME')\n now = tonumber(t[1]) * 1000 + tonumber(t[2]) / 1000\nelse\n now = tonumber(ARGV[6])\nend\nlocal TOL = 1e-6\nlocal function num(x) return string.format('%.6f', x) end\nlocal raw = redis.call('GET', KEYS[1])\nlocal full = nil\nlocal stamps = nil\nif raw then\n if kind == 'token-bucket' then\n full = tonumber(raw)\n else\n stamps = {}\n for x in string.gmatch(raw, '[^,]+') do stamps[#stamps + 1] = tonumber(x) end\n end\nend\nlocal function freeAt()\n if kind == 'token-bucket' then return full end\n if #stamps == 0 then return -math.huge end\n return stamps[#stamps] + b\nend\nif raw and freeAt() <= now then\n redis.call('DEL', KEYS[1])\n redis.call('ZREM', KEYS[2], member)\n raw = nil\n full = nil\n stamps = nil\nend\nif not raw then\n if redis.call('ZCARD', KEYS[2]) >= cap then\n redis.call('ZREMRANGEBYSCORE', KEYS[2], '-inf', num(now))\n if redis.call('ZCARD', KEYS[2]) >= cap then\n local first = redis.call('ZRANGE', KEYS[2], 0, 0, 'WITHSCORES')\n return {0, num(tonumber(first[2]) - now), 'cap'}\n end\n end\nend\nlocal remaining\nlocal state\nif kind == 'token-bucket' then\n local span = a * b\n local base = now\n if full and full > now then base = full end\n local nxt = base + a * units\n if nxt - now > span + TOL then\n return {0, num(nxt - span - now), 'limit'}\n end\n remaining = math.floor((span - (nxt - now)) / a + TOL)\n if remaining < 0 then remaining = 0 end\n full = nxt\n state = num(full)\nelse\n local live = {}\n for _, stamp in ipairs(stamps or {}) do\n if stamp + b > now + TOL then live[#live + 1] = stamp end\n end\n if #live + units > a then\n return {0, num(live[#live + units - a] + b - now), 'limit'}\n end\n for _ = 1, units do live[#live + 1] = now end\n remaining = a - #live\n stamps = live\n local parts = {}\n for i, stamp in ipairs(live) do parts[i] = num(stamp) end\n state = table.concat(parts, ',')\nend\nlocal free = freeAt()\nlocal ttl = math.ceil(free - now)\nif ttl < 1 then ttl = 1 end\nredis.call('SET', KEYS[1], state, 'PX', ttl)\nredis.call('ZADD', KEYS[2], num(free), member)\nif redis.call('PTTL', KEYS[2]) < ttl then redis.call('PEXPIRE', KEYS[2], ttl) end\nreturn {1, remaining}\n";
166
- /** These options make a store of a limiter in Redis. */
167
- interface RedisLimiterOptions {
168
- /** This text starts the name of each key of the store in Redis, for example `limit:`. It has no braces. */
169
- readonly prefix: string;
170
- /**
171
- * This clock replaces `TIME` of the server, for a test that compares the store with `decide`. Without
172
- * it, the script reads `TIME`, thus each replica gets the one clock of the store.
173
- */
174
- readonly clock?: Clock | undefined;
175
- }
176
- /** A Redis client part is the part of a Redis client that the store uses: `send`. */
177
- type RedisSender = Pick<RedisClient, "send">;
178
- /**
179
- * This function makes a store that the replicas share, in Redis 7. Each take is one `EVAL` of
180
- * `LIMITER_SCRIPT`, with all of its units. The client does not send it again, because a second take
181
- * counts two times.
182
- * - The names of the keys have the limiter in braces, a hash tag. Thus the state and the index of a
183
- * limiter are in one slot of a Redis Cluster.
184
- * - Each state expires at the time that the key is free, thus the eviction is exact, as in the memory
185
- * store. The index of the limiter bounds the count of busy keys to `maxKeys`.
186
- * - A reply of an error, an outcome that is not certain, or a reply of another shape rejects the
187
- * take of the store. `keyedLimiter` then applies the `onStoreFailure` of the spec.
188
- * - `TIME` is the wall clock of the Redis host, not a monotonic clock. Thus a step of that clock
189
- * moves the counts of each key. The replicas still share one clock.
190
- */
191
- export declare const redisLimiterStore: (client: RedisSender, options: RedisLimiterOptions) => LimiterStore;
192
- /**
193
- * The Redis client as a `mark1russell7.machine/1` document. Its states are the states of ioredis.
194
- * The wrapper adds its own events: the join at each `ready`, and the misses of its watchdog. It also
195
- * adds a command that it sends again, and the bound of its close. A test records the transitions of the
196
- * client and replays them against this document.
197
- *
198
- * The state `ready` hides states that the client cannot see (D4). In a black hole, ioredis stays
199
- * `ready` while the kernel retransmits, until `driver_writeoff_time` or the watchdog ends that
200
- * hidden interval. A timer of this document bounds each hidden interval.
201
- */
202
- export declare const REDIS_CLIENT_MACHINE: Machine;
203
- /** These are the operations of the client: the idempotency of each command that the table names. */
204
- export declare const REDIS_OPERATIONS: Readonly<Record<string, Operation>>;
205
- /** This function gives the name of a command as the table writes it: upper case, and CLIENT ID with its subcommand. */
206
- export declare const commandName: (command: string, args: readonly unknown[]) => string;
207
- export { type Attempt, type CheckOptions, type Client, type ClientJoin, type ClientKnobs, type ClientOptions, type ClientSocket, type ClientSpec, type ClientStep, type ConnectionFactory, type Detector, type DialFn, type Factory, type Join, MANIFESTATIONS, type Manifestation, type Meeting, type RedisClient, type RedisClientOptions, type RedisClientSpec, type RedisConnection, type RedisConnectionOptions, type RedisKnobs, type RedisLimiterOptions, type RedisSender, type RedisSocket, type Sent, type Situation, firstDetector, heartbeatDetection, retryBackoff, unwatched };
1
+ import { Attempt, CheckOptions, Client, ClientJoin, ClientKnobs, ClientOptions, ClientSocket, ClientSpec, ClientStep, DialFn, Factory, Sent, retryBackoff } from "./client/core.js";
2
+ import { Detector, MANIFESTATIONS, Manifestation, Meeting, Situation, firstDetector, unwatched } from "./client/meets.js";
3
+ import { Join, RedisClient, RedisClientOptions, RedisClientSpec, RedisKnobs, redisClient, specProblems, tcpDial } from "./redis/client.js";
4
+ import { heartbeatDetection } from "./timing.js";
5
+ import { ConnectionFactory, RedisConnection, RedisConnectionOptions, RedisSocket, ioredis } from "./redis/connection.js";
6
+ import { meetings } from "./redis/meets.js";
7
+ import { LIMITER_SCRIPT, RedisLimiterOptions, RedisSender, redisLimiterStore } from "./redis/limiter.js";
8
+ import { REDIS_CLIENT_MACHINE } from "./redis/machine.js";
9
+ import { REDIS_OPERATIONS, commandName } from "./redis/operations.js";
10
+ export { type Attempt, type CheckOptions, type Client, type ClientJoin, type ClientKnobs, type ClientOptions, type ClientSocket, type ClientSpec, type ClientStep, type ConnectionFactory, type Detector, type DialFn, type Factory, type Join, LIMITER_SCRIPT, MANIFESTATIONS, type Manifestation, type Meeting, REDIS_CLIENT_MACHINE, REDIS_OPERATIONS, type RedisClient, type RedisClientOptions, type RedisClientSpec, type RedisConnection, type RedisConnectionOptions, type RedisKnobs, type RedisLimiterOptions, type RedisSender, type RedisSocket, type Sent, type Situation, commandName, firstDetector, heartbeatDetection, ioredis, meetings, redisClient, redisLimiterStore, retryBackoff, specProblems, tcpDial, unwatched };