@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
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The exported type names that hold or reach a value that service knows by identity. A package
3
+ * whose public API takes or gives a value of one of these types has service as a peer dependency.
4
+ * A plain dependency is not sufficient. Then the package and its caller use one copy of service.
5
+ *
6
+ * The roots are `Lifecycle` and `RequestStream`, the keys of the maps, and `TransportImpl` and
7
+ * `RequestHandler`, whose values write to the maps of their own copy. The list is each exported type
8
+ * that names a root, or names a type of the list, in its declaration. A type can be on the list
9
+ * although its own use crosses copies safely: for that type, a peer is the safe choice.
10
+ *
11
+ * `identity.test.ts` calculates this list from the sources and from the maps, thus the list stays
12
+ * current.
13
+ */
14
+ export declare const IDENTITY_TYPES: readonly ["Client", "GrpcClient", "HttpClient", "HttpTransport", "IterationContext", "JobContext", "Lifecycle", "MongoClient", "MountContext", "PgClient", "QueueDrain", "QueueDrainOptions", "RabbitClient", "RedisClient", "RedisSender", "RequestHandler", "RequestStream", "ServiceBuilder", "SubjectFactory", "TransportImpl", "TransportSubject", "UpgradeHandler", "WorkerLoop", "WorkerLoopOptions", "WsClient"];
15
+ /** A name of `IDENTITY_TYPES`. */
16
+ export type IdentityType = (typeof IDENTITY_TYPES)[number];
@@ -0,0 +1,44 @@
1
+ // src/identity.ts
2
+ /**
3
+ * The exported type names that hold or reach a value that service knows by identity. A package
4
+ * whose public API takes or gives a value of one of these types has service as a peer dependency.
5
+ * A plain dependency is not sufficient. Then the package and its caller use one copy of service.
6
+ *
7
+ * The roots are `Lifecycle` and `RequestStream`, the keys of the maps, and `TransportImpl` and
8
+ * `RequestHandler`, whose values write to the maps of their own copy. The list is each exported type
9
+ * that names a root, or names a type of the list, in its declaration. A type can be on the list
10
+ * although its own use crosses copies safely: for that type, a peer is the safe choice.
11
+ *
12
+ * `identity.test.ts` calculates this list from the sources and from the maps, thus the list stays
13
+ * current.
14
+ */
15
+ const IDENTITY_TYPES = [
16
+ "Client",
17
+ "GrpcClient",
18
+ "HttpClient",
19
+ "HttpTransport",
20
+ "IterationContext",
21
+ "JobContext",
22
+ "Lifecycle",
23
+ "MongoClient",
24
+ "MountContext",
25
+ "PgClient",
26
+ "QueueDrain",
27
+ "QueueDrainOptions",
28
+ "RabbitClient",
29
+ "RedisClient",
30
+ "RedisSender",
31
+ "RequestHandler",
32
+ "RequestStream",
33
+ "ServiceBuilder",
34
+ "SubjectFactory",
35
+ "TransportImpl",
36
+ "TransportSubject",
37
+ "UpgradeHandler",
38
+ "WorkerLoop",
39
+ "WorkerLoopOptions",
40
+ "WsClient"
41
+ ];
42
+ export { IDENTITY_TYPES };
43
+
44
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","names":[],"sources":["../src/identity.ts"],"sourcesContent":["// The types whose values service knows by identity (CLI-117). Service keeps state for some objects\n// in module-level `WeakMap`s: the late holds of the drains and the outside counts by lifecycle, the\n// owner of each request stream (`drains.ts`), and the mark of each HTTP answer (`http/answers.ts`).\n// Each copy of service has its own maps. Thus a value that one copy makes and another copy reads\n// loses that state with no error, for example a drain that does not wait for its late answers.\n\n/**\n * The exported type names that hold or reach a value that service knows by identity. A package\n * whose public API takes or gives a value of one of these types has service as a peer dependency.\n * A plain dependency is not sufficient. Then the package and its caller use one copy of service.\n *\n * The roots are `Lifecycle` and `RequestStream`, the keys of the maps, and `TransportImpl` and\n * `RequestHandler`, whose values write to the maps of their own copy. The list is each exported type\n * that names a root, or names a type of the list, in its declaration. A type can be on the list\n * although its own use crosses copies safely: for that type, a peer is the safe choice.\n *\n * `identity.test.ts` calculates this list from the sources and from the maps, thus the list stays\n * current.\n */\nexport const IDENTITY_TYPES = [\n \"Client\",\n \"GrpcClient\",\n \"HttpClient\",\n \"HttpTransport\",\n \"IterationContext\",\n \"JobContext\",\n \"Lifecycle\",\n \"MongoClient\",\n \"MountContext\",\n \"PgClient\",\n \"QueueDrain\",\n \"QueueDrainOptions\",\n \"RabbitClient\",\n \"RedisClient\",\n \"RedisSender\",\n \"RequestHandler\",\n \"RequestStream\",\n \"ServiceBuilder\",\n \"SubjectFactory\",\n \"TransportImpl\",\n \"TransportSubject\",\n \"UpgradeHandler\",\n \"WorkerLoop\",\n \"WorkerLoopOptions\",\n \"WsClient\",\n] as const;\n\n/** A name of `IDENTITY_TYPES`. */\nexport type IdentityType = (typeof IDENTITY_TYPES)[number];\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
package/build/index.d.ts CHANGED
@@ -1,414 +1,37 @@
1
- import { $ as ProcessTrigger, A as Step, B as recoverSpan, C as FORMAT, D as ProgressMarks, E as Phase, F as Timing, G as EmbeddedProcess, H as RoutePattern, I as asDebounce, J as HostStream, K as ExitSignal, L as asWindow, M as FailsBy, N as Poll, O as RepeatSignal, P as Span, Q as ProcessPort, R as failSpan, S as ExitCodes, T as MessageTrigger, U as RouteRequest, V as OperationOf, W as EXIT_SIGNALS, X as PROCESS_TRIGGERS, Y as MessageShape, Z as ProcessHost, _ as Check, a as LogFields, at as isMessageShape, b as Coupling, c as Logger, ct as processPortOf, d as atLeast, dt as mayReissue, et as UNCAUGHT_ORIGINS, f as consoleLogger, g as Recorder, h as MachineName, i as LogEntry, it as isExitSignal, j as Transport, k as ServiceDescription, l as TraceIds, lt as Idempotency, m as LifecycleEvent, n as ConsoleTarget, nt as embeddedProcess, o as LogFormat, ot as matchesMessage, p as logEvents, q as ExitTrigger, r as LOG_LEVELS, rt as isExitCode, s as LogLevel, st as nodeProcess, t as ConsoleLoggerOptions, tt as UncaughtOrigin, u as TraceIdsSource, ut as Operation, v as Controller, w as Gate, x as Dependency, y as CooperativeFloor, z as heartbeatDetection } from "./logger-B6drv9w0.js";
2
- import { a as WatchdogSpec, c as Profile, d as kubernetes, f as localDev, i as Watchdog, l as daemon, n as ServiceBuilder, o as watchdog, r as service, s as PodTiming, t as ControllerBuilder, u as ephemeral } from "./builder-zO48Vgoj.js";
3
- import { C as limitRule, D as retryAfterSeconds, E as overCapacity, O as unitsOf, S as idleSpan, T as longestRetryAfter, _ as WaitCause, a as LimitPolicy, b as decide, c as LimiterEviction, d as RefusalCause, f as Refused, g as TokenBucket, h as TakeStep, i as KeyState, l as LimiterSpec, m as StoreFailure, n as CapacityRefused, o as LimitRule, p as SlidingWindow, r as Decision, s as Limiter, t as Allowed, u as LimiterStoreSpec, v as WaitRefused, w as limiterProblems, x as freeAt, y as capacityOf } from "./policy-CBcK2XGg.js";
4
- import { C as symbolsOf, S as inequalities, _ as TimerMarks, a as O16, b as compression, c as Change, d as Evaluated, f as Inequality, g as TimerMark, h as Term, i as O10, l as Compressed, m as Side, n as O04, o as Binding, p as Rule, r as O09, s as Bound, t as DRAIN_RULES, u as Compression, v as Verdict, w as verdictOf, x as evaluate, y as compress } from "./rules-HyFCBStQ.js";
5
- import { a as realClock, i as platformClock, n as Clock, r as PlatformClockOptions, t as Cancel } from "./clock-DpVgpY4h.js";
1
+ import { FailsBy, Poll, Span, Timing, asDebounce, asWindow, failSpan, heartbeatDetection, recoverSpan } from "./timing.js";
2
+ import { Check, Controller, CooperativeFloor, Coupling, Dependency, ExitCodes, FORMAT, Gate, MessageTrigger, Phase, ProgressMarks, RepeatSignal, ServiceDescription, Step, Transport } from "./description.js";
3
+ import { Allowed, CapacityRefused, Decision, KeyState, LimitPolicy, LimitRule, Limiter, LimiterEviction, LimiterSpec, LimiterStoreSpec, RefusalCause, Refused, SlidingWindow, StoreFailure, TakeStep, TokenBucket, WaitCause, WaitRefused, capacityOf, decide, freeAt, idleSpan, limitRule, limiterProblems, longestRetryAfter, overCapacity, retryAfterSeconds, unitsOf } from "./limiter/policy.js";
4
+ import { Idempotency, Operation, mayReissue } from "./operation.js";
5
+ import { ControllerBuilder, ServiceBuilder, service } from "./builder.js";
6
+ import { Binding, Bound, Change, Compressed, Compression, Evaluated, Inequality, Rule, Side, Term, TimerMark, TimerMarks, Verdict, compress, compression, evaluate, inequalities, symbolsOf, verdictOf } from "./law.js";
7
+ import { DRAIN_RULE_IDS, STOPS, STOP_RULE, Stop, StopWay, lintStop } from "./stops.js";
8
+ import { DRAIN_RULES, O04, O09, O10, O16 } from "./rules.js";
9
+ import { BOUND_RULES, CLOSE_BOUND_RULE, Claim, DECLARATION_RULE, Epochs, Finding, LAW_STATISTIC, LIMITER_RULES, NAME_RULE, PLATFORM_MARKS, PROGRESS_RULE, SERVICE_RULES, Scenario, ScenarioValue, ScopedChange, Statistic, UNIT_BOUND_RULE, compressionOf, lint, serviceBindings } from "./lint.js";
10
+ import { IDENTITY_TYPES, IdentityType } from "./identity.js";
11
+ import { Cancel, Clock, PlatformClockOptions, platformClock, realClock } from "./clock.js";
6
12
  import { Heartbeat, HeartbeatOptions, detectionTime, heartbeat } from "./heartbeat.js";
7
- import { a as backoffDelay, i as backoffBand, n as DelayBand, o as backoffProblems, r as Jitter, t as Backoff } from "./backoff-QTRGfkEK.js";
8
- import { A as takeQuotas, C as RollingWindow, D as quotaProblems, E as memoryQuotaStore, F as limiterStateOf, M as SLIDING_WINDOW_MACHINE, N as TOKEN_BUCKET_MACHINE, O as quotaRule, P as limiterMachine, S as QuotasVerdict, T as keyedQuota, _ as QuotaStore, a as QuotaAnswer, b as QuotaWaitRefused, c as QuotaEvent, d as QuotaRecord, f as QuotaRefused, g as QuotaStep, h as QuotaState, i as QuotaAllowed, j as LimiterState, k as quotaStep, l as QuotaPart, m as QuotaSpec, n as KeyedQuota, o as QuotaCapacityRefused, p as QuotaRule, r as MemoryQuotaStore, s as QuotaChange, t as CalendarWindow, u as QuotaReading, v as QuotaTakeStep, w as TakeQuotasOptions, x as QuotaWindow, y as QuotaVerdict } from "./limiter-BNKnwzeY.js";
9
- import { A as DurationHistogram, C as HealthVerdict, D as CheckFn, E as StartOptions, F as Outcome, I as Result, M as Episode, N as HealthMetrics, O as CheckMetrics, P as redact, S as Health, T as ProbeKind, _ as RequestFn, a as PhaseContext, b as RequestWork, c as STAGES, d as TransportImpl, f as UncaughtOptions, g as RequestEvent, h as RequestEnd, i as LifecycleState, j as EPISODES_KEPT, k as DURATION_FRACTIONS, l as ShutdownOptions, m as stageRank, n as HealthServer, o as PhaseWork, p as cooperativeAbortAt, r as Lifecycle, s as RunOptions, t as DependencyHandle, u as Stage, v as RequestOptions, w as ProbeAnswer, x as CheckVerdict, y as RequestStream } from "./lifecycle-D0J-zwZF.js";
10
- import { a as TakeRequest, i as MemoryStore, n as LimiterStore, o as keyedLimiter, r as LocalLimiter, s as memoryStore, t as KeyedLimiter } from "./store-DFwFKrsB.js";
11
- import { n as IncomingHeaders, t as CallContext } from "./call-context-DDhcVvn5.js";
12
- import { a as JobSource, c as QueueKnobs, d as queueDrain, f as redeliverOnce, i as JobSettle, l as RedeliveryPolicy, n as JobContext, o as QueueDrain, p as UnitRequest, r as JobFailure, s as QueueDrainOptions, t as JobAction, u as RequeueCause } from "./queue-DXdw1vLO.js";
13
- import { Extent, Quantity } from "@mark1russell7/quantity";
13
+ import { Backoff, DelayBand, Jitter, backoffBand, backoffDelay, backoffProblems } from "./backoff.js";
14
+ import { Retrier, RetrierOptions, RetryOptions, retrier, retry, retryAfterDelay } from "./retrier.js";
15
+ import "./limiter.js";
16
+ import { Outcome, Result } from "./latch.js";
17
+ import { CheckFn } from "./poller.js";
18
+ import { CheckVerdict, Health, HealthVerdict, ProbeAnswer, ProbeKind, StartOptions } from "./health.js";
19
+ import { CheckMetrics, DURATION_FRACTIONS, DurationHistogram, EPISODES_KEPT, Episode, HealthMetrics, redact } from "./metrics.js";
20
+ import { LifecycleEvent, MachineName, Recorder } from "./events.js";
21
+ import { ConsoleLoggerOptions, ConsoleTarget, LOG_LEVELS, LogEntry, LogFields, LogFormat, LogLevel, Logger, TraceIds, TraceIdsSource, atLeast, consoleLogger, logEvents } from "./logger.js";
22
+ import { CallContext, IncomingHeaders } from "./call-context.js";
23
+ import { DependencyHandle, HealthServer, Lifecycle, LifecycleState, PhaseContext, PhaseWork, RunOptions, STAGES, ShutdownOptions, Stage, TransportImpl, UncaughtOptions, cooperativeAbortAt, stageRank } from "./lifecycle.js";
24
+ import { EXIT_SIGNALS, EmbeddedProcess, ExitSignal, ExitTrigger, HostStream, MessageShape, PROCESS_TRIGGERS, ProcessHost, ProcessPort, ProcessTrigger, UNCAUGHT_ORIGINS, UncaughtOrigin, embeddedProcess, isExitCode, isExitSignal, isMessageShape, matchesMessage, nodeProcess, processPortOf } from "./process.js";
25
+ import { PodTiming, Profile, daemon, ephemeral, kubernetes, localDev } from "./profiles.js";
26
+ import { RequestEnd, RequestEvent, RequestFn, RequestOptions, RequestStream, RequestWork } from "./requests.js";
27
+ import { OperationOf, RoutePattern, RouteRequest } from "./routes.js";
28
+ import { KeyedLimiter, LimiterStore, LocalLimiter, MemoryStore, TakeRequest, keyedLimiter, memoryStore } from "./limiter/store.js";
29
+ import { LimiterState, SLIDING_WINDOW_MACHINE, TOKEN_BUCKET_MACHINE, limiterMachine, limiterStateOf } from "./limiter/machine.js";
30
+ import { CalendarWindow, KeyedQuota, MemoryQuotaStore, QuotaAllowed, QuotaAnswer, QuotaCapacityRefused, QuotaChange, QuotaEvent, QuotaPart, QuotaReading, QuotaRecord, QuotaRefused, QuotaRule, QuotaSpec, QuotaState, QuotaStep, QuotaStore, QuotaTakeStep, QuotaVerdict, QuotaWaitRefused, QuotaWindow, QuotasVerdict, RollingWindow, TakeQuotasOptions, keyedQuota, memoryQuotaStore, quotaProblems, quotaRule, quotaStep, takeQuotas } from "./limiter/quota.js";
31
+ import { Watchdog, WatchdogSpec, watchdog } from "./watchdog.js";
32
+ import { UnitRequest } from "./units.js";
33
+ import { IterationContext, WorkerKnobs, WorkerLoop, WorkerLoopOptions, workerLoop } from "./worker.js";
34
+ import { JobAction, JobContext, JobFailure, JobSettle, JobSource, QueueDrain, QueueDrainOptions, QueueKnobs, RedeliveryPolicy, RequeueCause, queueDrain, redeliverOnce } from "./queue.js";
35
+ import { EXIT_MACHINE, GATE_MACHINE, LATCH_MACHINE, MACHINES, POLLER_MACHINE, WATCHDOG_MACHINE, WINDOW_MACHINE, capKnob, drainMachine } from "./machines.js";
14
36
  import { replay } from "@mark1russell7/algebra/replay";
15
- import { Machine } from "@mark1russell7/algebra";
16
- /**
17
- * This module applies the ordering law to a declaration. The declaration binds the symbols of the
18
- * service, from its primitives: the polls of its checks, the windows of its policies, its drain.
19
- * The scenario binds the symbols of the platform (preStop, grace, the probes of the kubelet,
20
- * propagation) and of each dependency (its failover time, the idle close of its server). Thus the
21
- * service gives the inequalities, and the scenario gives the values.
22
- *
23
- * A rule about a client applies one time for each dependency. A rule about a server (`@server`)
24
- * also applies one time for each server transport of the service. A rule about a consumer applies
25
- * one time for each consumer and each worker. A rule about a limiter applies one time for each limiter.
26
- */
27
- /** A statistic of a measured distribution. The law binds p99 (`LAW_STATISTIC`). */
28
- type Statistic = "p50" | "p90" | "p99" | "p999" | "max";
29
- /** The law binds this statistic of a distribution. */
30
- export declare const LAW_STATISTIC: Statistic;
31
- /**
32
- * A claim is a value of the scenario that names its epoch: the component and the version that give
33
- * it, for example "node@22" (E2). A default is true only for a version: the keep-alive of Node is
34
- * 5 s, but 65 s on main. A claim gives a set value, or a measured distribution by its statistics.
35
- */
36
- type Claim = {
37
- readonly epoch: string;
38
- readonly value: Extent;
39
- } | {
40
- readonly epoch: string;
41
- readonly distribution: Readonly<Partial<Record<Statistic, Quantity>>>;
42
- };
43
- /**
44
- * A value of the scenario is an amount, or a claim. An amount names no epoch, thus the finding of
45
- * each rule that reads it gives null for its epoch.
46
- */
47
- type ScenarioValue = Extent | Claim;
48
- /** A scenario gives the values of the platform and of each dependency, by the `symbol@hop` of the law. */
49
- interface Scenario {
50
- /** These are the values of the platform: prestop_sleep@pod, termination_grace@pod, probe_period@pod, propagation_bound@cluster. */
51
- readonly platform: Readonly<Record<string, ScenarioValue>>;
52
- /**
53
- * These are the probe windows of the kubelet, period × failure threshold. They add to the
54
- * windows of the declaration. A probe reads the cached verdict, thus detection is the latch,
55
- * then the probe.
56
- */
57
- readonly probes: {
58
- readonly readiness: Quantity;
59
- readonly liveness: Quantity;
60
- };
61
- /** These are the values of each dependency, by its name: failover_time@dependency, server_idle_close@server. */
62
- readonly dependencies?: Readonly<Record<string, Readonly<Record<string, ScenarioValue>>>> | undefined;
63
- /**
64
- * These are the values of each transport, by its name and by the `symbol@hop` of the law. For a
65
- * consumer or a worker, they are the values of its source: lease_duration@broker. For a server,
66
- * they are the values of its clients: request_timeout@client.
67
- */
68
- readonly transports?: Readonly<Record<string, Readonly<Record<string, ScenarioValue>>>> | undefined;
69
- /**
70
- * These are the values of the callers of each limiter, by its name and by the `symbol@hop` of the
71
- * law: client_retry_window@caller, retry_delay@caller. A symbol without a hop binds at `caller`.
72
- */
73
- readonly limiters?: Readonly<Record<string, Readonly<Record<string, ScenarioValue>>>> | undefined;
74
- }
75
- /** The epochs of a scope map each symbol that the scenario binds to the epoch of its value, or null when the value names none. */
76
- type Epochs = Readonly<Record<string, string | null>>;
77
- /** A finding is the verdict of one rule for one scope: the service, or the client of a dependency. When a value of the scenario names an epoch, the finding gives the epoch of each value that the rule reads. */
78
- interface Finding {
79
- readonly rule: string;
80
- readonly scope: string;
81
- readonly verdict: Verdict;
82
- readonly statement: string;
83
- readonly window?: string | undefined;
84
- readonly evaluated: readonly Evaluated[];
85
- /** These are the symbols that have no bound. A "depends" verdict waits for them. */
86
- readonly unbound: readonly string[];
87
- /** These are the epochs of the symbols of the rule that the scenario binds (E2). Thus a finding is true for these versions. */
88
- readonly epochs?: Epochs | undefined;
89
- }
90
- /** These are the identifiers of the rules that each declaration gets. */
91
- export declare const SERVICE_RULES: readonly string[];
92
- /**
93
- * These are the two rules of the law for a keyed limiter, as data. The caller of `lint()` gives
94
- * them, as it gives each other rule. Each one applies one time for each limiter.
95
- * - O29: the longest `Retry-After` of a limiter is at most the retry window of its caller. Its
96
- * second inequality applies the same bound to a new key at the cap of keys.
97
- * Otherwise the caller stops before the limit lets its call in, and a refusal becomes a failure.
98
- * - O30: the least delay of a caller before it sends a refused call again is at least the longest
99
- * `Retry-After` of the policy. Otherwise a caller that does not read the header sends again too
100
- * early, and the limiter refuses each early call again.
101
- *
102
- * The identifiers O29 and O30 are provisional. The private corpus of the law (R3, track B) has 28
103
- * rules, O01 to O28. It does not have these two rules yet, thus they take the next two identifiers.
104
- */
105
- export declare const LIMITER_RULES: readonly Rule[];
106
- /** This function gives what the declaration tells about the service, as symbols of the law, and the source of each. */
107
- export declare const serviceBindings: (svc: ServiceDescription, scenario: Scenario) => {
108
- readonly bind: Record<string, Bound>;
109
- readonly from: Record<string, string>;
110
- readonly epochs: Epochs;
111
- };
112
- /** This identifier is the rule of the findings about a field that the declaration does not give. */
113
- export declare const DECLARATION_RULE = "declaration";
114
- /** This identifier is the rule of the findings for two parts that have one name in the scopes of a rule. */
115
- export declare const NAME_RULE = "unique-names";
116
- /** This identifier is the rule of the findings about the stall time of a progress check (`Check.marks`). */
117
- export declare const PROGRESS_RULE = "progress";
118
- /** This identifier is the rule of the findings about the bound of a unit against the cap of the `drain` phase. */
119
- export declare const UNIT_BOUND_RULE = "unit-bound";
120
- /** This identifier is the rule of the findings about the close bound against the cap of the `close transports` phase. */
121
- export declare const CLOSE_BOUND_RULE = "close-bound";
122
- /**
123
- * These are the rules of the bounds of a loop. Each one applies one time for each consumer and
124
- * each worker (S6 A10, A11). `lint()` gives them, as it gives `PROGRESS_RULE`.
125
- * - unit-bound: `unit_processing_time` is less than the cap of the `drain` phase. Otherwise the
126
- * drain can cut a unit that ends in its bound. A unit without a bound violates the rule.
127
- * - close-bound: `close_bound` is less than the cap of the `close transports` phase. Otherwise the
128
- * phase can end before the loop closes.
129
- *
130
- * The corpus of the law (R3) does not have these rules, thus they have identifiers of the service,
131
- * not O-numbers. The symbols `drain_phase_cap@process` and `close_phase_cap@process` are the caps of
132
- * one phase. `process_drain_time@process` is the sum of the caps of all the phases. A phase that the
133
- * declaration does not give binds no symbol, thus its finding is `depends`.
134
- */
135
- export declare const BOUND_RULES: readonly Rule[];
136
- /**
137
- * These are the marks of the timers of the platform (E10). Kubernetes takes the probe period, the
138
- * preStop sleep and the termination grace in whole seconds, thus each is stepped by 1 s. The
139
- * cluster sets the propagation of the endpoints, thus a compression of the service cannot scale it.
140
- */
141
- export declare const PLATFORM_MARKS: TimerMarks;
142
- /** A change of a compression of a service: a rule and a scope whose verdict the compression changes. */
143
- interface ScopedChange extends Change {
144
- readonly scope: string;
145
- }
146
- /**
147
- * This function tells which findings of `lint` a compression by k changes (E10). It scales the
148
- * bindings of each scope by the marks. Thus a harness that runs the service k times faster learns
149
- * the orderings that its run breaks. The unmarked symbols are the symbols of the rules with no mark.
150
- * It reads the rules that `lint` applies with their bindings: the service rules and `BOUND_RULES`.
151
- */
152
- export declare const compressionOf: (svc: ServiceDescription, scenario: Scenario, rules: readonly Rule[], k: number, marks: TimerMarks) => {
153
- readonly changed: readonly ScopedChange[];
154
- readonly unmarked: readonly string[];
155
- };
156
- /**
157
- * This function applies each service rule to a declaration and a scenario. A rule applies one time
158
- * for the service, for each client, for each consumer and worker, or for each limiter. It also
159
- * gives a finding for each necessary field that the description does not give (`DECLARATION_RULE`).
160
- * It gives a finding for each name that two parts share in the scopes of a rule (`NAME_RULE`). Each progress check
161
- * that names its loops also gets its findings (`PROGRESS_RULE`). The findings of the bounds of each
162
- * consumer and each worker come last (`BOUND_RULES`).
163
- */
164
- export declare const lint: (svc: ServiceDescription, scenario: Scenario, rules: readonly Rule[]) => Finding[];
165
- /**
166
- * This module keeps apart the four ways that a pod stops (B11). Each way runs a different part of
167
- * the shutdown, thus a different set of the rules of the drain guards it.
168
- */
169
- /** A way that a pod stops: a deletion, a liveness restart, a crash, or a stop for lack of memory (OOM). */
170
- type StopWay = "deletion" | "liveness-restart" | "crash" | "oom";
171
- /** What a way of stopping runs, and the rules of the drain that guard it. */
172
- interface Stop {
173
- readonly way: StopWay;
174
- /** This is the signal that the process gets first, or null when the process exits by itself. */
175
- readonly signal: "SIGTERM" | "SIGKILL" | null;
176
- /** This flag tells if the kubelet runs the preStop hook. */
177
- readonly preStop: boolean;
178
- /** This flag tells if the process runs its shutdown phases. */
179
- readonly drain: boolean;
180
- /**
181
- * This is how the pod leaves its endpoints: by its deletion, when its readiness fails, or when
182
- * the kubelet finds that the container exited.
183
- */
184
- readonly leaves: "deletion" | "readiness" | "exit";
185
- /** These are the identifiers of the rules of the drain that guard this way. */
186
- readonly rules: readonly string[];
187
- }
188
- /**
189
- * These are the identifiers of the rules of the drain, from the data of the entry `./rules`. Each
190
- * way that a pod stops applies only its own rules of this set.
191
- */
192
- export declare const DRAIN_RULE_IDS: readonly string[];
193
- /**
194
- * These are the four ways that a pod stops.
195
- * - A deletion runs the preStop hook, then SIGTERM. The endpoints drop the pod at its deletion,
196
- * thus the preStop sleep and the hold must cover the propagation (O04).
197
- * - A liveness restart also runs the preStop hook and SIGTERM, with the grace. The pod stays in its
198
- * endpoints until its readiness fails, thus readiness must fail first (O09).
199
- * - A crash and an OOM stop run no hook and no drain. The kubelet finds the exit at its relist, and
200
- * no rule bounds that time. A client that can reissue a request is the only guard.
201
- */
202
- export declare const STOPS: Readonly<Record<StopWay, Stop>>;
203
- /** The identifier of the finding of a way of stopping that runs no drain. */
204
- export declare const STOP_RULE = "stop";
205
- /**
206
- * This function applies the rules to a declaration for one way of stopping. A rule of the drain
207
- * applies only when it guards that way. The other rules apply as `lint()` applies them. A way with
208
- * no drain also gets a finding of `STOP_RULE` that depends. No rule bounds the time until the
209
- * kubelet finds the exit, and the work in flight is lost. Such a way starts no phase, thus it gets no
210
- * finding of `BOUND_RULES`.
211
- */
212
- export declare const lintStop: (svc: ServiceDescription, scenario: Scenario, rules: readonly Rule[], way: StopWay) => Finding[];
213
- /**
214
- * The exported type names that hold or reach a value that service knows by identity. A package
215
- * whose public API takes or gives a value of one of these types has service as a peer dependency.
216
- * A plain dependency is not sufficient. Then the package and its caller use one copy of service.
217
- *
218
- * The roots are `Lifecycle` and `RequestStream`, the keys of the maps, and `TransportImpl` and
219
- * `RequestHandler`, whose values write to the maps of their own copy. The list is each exported type
220
- * that names a root, or names a type of the list, in its declaration. A type can be on the list
221
- * although its own use crosses copies safely: for that type, a peer is the safe choice.
222
- *
223
- * `identity.test.ts` calculates this list from the sources and from the maps, thus the list stays
224
- * current.
225
- */
226
- export declare const IDENTITY_TYPES: readonly ["Client", "GrpcClient", "HttpClient", "HttpTransport", "IterationContext", "JobContext", "Lifecycle", "MongoClient", "MountContext", "PgClient", "QueueDrain", "QueueDrainOptions", "RabbitClient", "RedisClient", "RedisSender", "RequestHandler", "RequestStream", "ServiceBuilder", "SubjectFactory", "TransportImpl", "TransportSubject", "UpgradeHandler", "WorkerLoop", "WorkerLoopOptions", "WsClient"];
227
- /** A name of `IDENTITY_TYPES`. */
228
- type IdentityType = (typeof IDENTITY_TYPES)[number];
229
- /** These options make a retrier: a backoff policy, the clock of its timers, and the signal that cancels it. */
230
- interface RetrierOptions extends Backoff {
231
- /** This clock starts each retry. The default is the real clock. A test gives a fake clock. */
232
- readonly clock?: Clock | undefined;
233
- /** This function gives a number in [0, 1) for the jitter of each delay. The default is `Math.random`. */
234
- readonly random?: (() => number) | undefined;
235
- /**
236
- * This signal cancels the retrier when it aborts, for example the `signal` of the lifecycle, which
237
- * aborts in the drain. After the abort, `schedule` starts nothing.
238
- */
239
- readonly signal?: AbortSignal | undefined;
240
- }
241
- /** A retrier starts a function again after the backoff of each try, on its clock. */
242
- interface Retrier {
243
- /** This count is the number of tries since the last reset. */
244
- readonly attempts: number;
245
- /** This flag tells if a retry waits for its timer. */
246
- readonly pending: boolean;
247
- /**
248
- * This method counts one more try, and starts `run` after the backoff delay of that try. It gives
249
- * the delay in milliseconds. A retry that waits stops, thus one retry at most waits. After the
250
- * abort of the signal, it starts nothing and gives null. The function catches its own errors.
251
- */
252
- schedule(run: () => void): number | null;
253
- /** This method sets the count of tries to 0, for example after a start that succeeded. A retry that waits stays. */
254
- reset(): void;
255
- /** This method stops the retry that waits. The count of tries stays. */
256
- cancel(): void;
257
- }
258
- /**
259
- * This function makes a retrier over `backoffDelay`. The first try waits `base`, and each try after
260
- * it waits `factor` times more, to the `cap`, with the jitter of the policy. It refuses a policy
261
- * with a problem of `backoffProblems`.
262
- */
263
- export declare const retrier: (options: RetrierOptions) => Retrier;
264
- /** These options make one call with retries: the most tries, the errors to retry, and the policy of a retrier. */
265
- interface RetryOptions extends RetrierOptions {
266
- /** This number is the most tries of the call, the first try included. It is 1 or more. */
267
- readonly tries: number;
268
- /** This function tells if a try starts again after this error. The default retries each error. */
269
- readonly retryable?: ((error: unknown) => boolean) | undefined;
270
- /**
271
- * This function gives the delay in milliseconds before the next try, in place of the backoff. An example
272
- * is the `Retry-After` header of an HTTP 429. Null, undefined, NaN, an infinite or a negative number keeps
273
- * the backoff delay. The retry puts no cap on this delay, so the caller caps it, for example at 60 s.
274
- */
275
- readonly delayOf?: ((error: unknown, attempt: number) => number | null | undefined) | undefined;
276
- }
277
- /**
278
- * This function gives the wait of a `Retry-After` header (RFC 9110) in milliseconds: a count of seconds,
279
- * or an HTTP date after `now`. It gives null for a header with no valid value. A date before `now` gives 0.
280
- */
281
- export declare const retryAfterDelay: (header: string | null | undefined, now: number) => number | null;
282
- /**
283
- * This function starts `run`, and starts it again after an error, to the count of `tries`. The delay
284
- * before try n + 1 is `delayOf(error, n)`, else the `backoffDelay` of try n, on the clock. The call gives
285
- * the value of the first try that succeeds. After the last try, an error that is not retryable, or the
286
- * abort of the signal, it throws the last error. It refuses a policy with a problem of `backoffProblems`.
287
- */
288
- export declare const retry: <T>(run: (attempt: number) => Promise<T>, options: RetryOptions) => Promise<T>;
289
- /**
290
- * These are the knobs of a worker loop, by the names of the ordering law where the law has them.
291
- * The loop has no defaults, thus each knob is necessary. A bound that nobody gives is "infinite".
292
- */
293
- interface WorkerKnobs {
294
- /**
295
- * This time is the sleep of a lane, from the end of one iteration to the start of the next. A
296
- * time without a bound starts the next iteration only at `wake()`.
297
- */
298
- readonly worker_sleep: Extent;
299
- /**
300
- * This time is the most that one iteration can take. At it, the loop aborts the signal of the
301
- * iteration, and a throw after it is a failure. The law reads it as `unit_processing_time@consumer` (O20).
302
- */
303
- readonly unit_processing_time: Extent;
304
- /** This time is the delay after the first failure in sequence. The delay is two times longer after each failure, with a jitter up to this time. */
305
- readonly retry_base: Quantity;
306
- /** This time is the most that one delay can be, before its jitter. */
307
- readonly retry_cap: Quantity;
308
- /** This time bounds the close: the end of the iterations after their abort, and then the teardown. */
309
- readonly close_bound: Quantity;
310
- /** This count (the unit `count`) is the number of lanes. Each lane does its iterations one at a time. */
311
- readonly concurrency: Quantity;
312
- /** The other knobs go to the declaration, for example `lease_duration@broker`. The loop does not read them. */
313
- readonly [knob: string]: Extent;
314
- }
315
- /** An iteration context is what the loop gives each iteration. */
316
- interface IterationContext<S> {
317
- /** This signal aborts at the cooperative abort of the drain, at the bound of the iteration, and at the close. */
318
- readonly signal: AbortSignal;
319
- /** This signal aborts when the intake stops. A long iteration can end at it in its own way. */
320
- readonly intake: AbortSignal;
321
- /** This value is the state that the setup gave, or undefined without a setup. */
322
- readonly state: S;
323
- /** This number is the lane of the iteration, from 0. */
324
- readonly lane: number;
325
- /** This count is the number of failures in sequence of the lane before this iteration. */
326
- readonly failures: number;
327
- /** This lifecycle is the lifecycle that the loop got at its start. */
328
- readonly life: Lifecycle;
329
- }
330
- /** These options make a worker loop. Each function can give a promise. */
331
- interface WorkerLoopOptions<S> {
332
- /** This function makes the state of the loop at its start, for example a connection. Its signal is the signal of the service. */
333
- readonly setup?: ((signal: AbortSignal) => S | PromiseLike<S>) | undefined;
334
- /**
335
- * This function does one iteration. When it gives `"more"`, the next iteration of its lane starts
336
- * after a zero sleep on the clock. A throw is a failure, and the lane then waits its backoff.
337
- */
338
- readonly iteration: (context: IterationContext<S>) => unknown;
339
- /** This function releases the state at the close. It occurs each time that the setup started, with undefined after a failed setup. */
340
- readonly teardown?: ((state: S | undefined) => void | PromiseLike<void>) | undefined;
341
- /** This clock is the clock of the lifecycle. The sleeps, the backoffs and the bounds use it. The default is `realClock`. */
342
- readonly clock?: Clock | undefined;
343
- /** This function gives the random numbers of the jitter, from 0 up to 1. The default is `Math.random`. */
344
- readonly random?: (() => number) | undefined;
345
- /**
346
- * This route puts each iteration through `life.request`: the service then admits it, counts it,
347
- * drains it and can cut it. The unit of a route function is the number of the lane.
348
- */
349
- readonly request?: UnitRequest<number> | undefined;
350
- /** This function receives each failure, with the count of failures in sequence of its lane. A refusal of the service is a failure too. */
351
- readonly onError?: ((error: unknown, failures: number) => void) | undefined;
352
- }
353
- /** A worker loop is a transport of the lifecycle whose work is a loop of iterations (S6 A10). */
354
- interface WorkerLoop extends TransportImpl {
355
- /** These knobs go to the declaration of the worker: `svc.worker(name, loop.knobs, loop)`. */
356
- readonly knobs: WorkerKnobs;
357
- /**
358
- * This method ends the sleep of each lane at once, for example when new work is ready. It does
359
- * not end a backoff. It gives false after the intake stops.
360
- */
361
- wake(): boolean;
362
- /** This method gives the problems of a declaration: each phase that the loop needs and that it does not give. `lint()` compares the bounds with the caps. */
363
- problems(description: ServiceDescription): string[];
364
- }
365
- /**
366
- * This function makes a worker loop as a transport (S6 A10). It has a setup, an iteration and a
367
- * teardown, and each lane does its iterations one at a time.
368
- * - The start does the setup. A failed setup gets its teardown, and the start throws.
369
- * - The first iteration of each lane comes after the startup ends. Each sleep and each backoff is on the clock.
370
- * - `stopIntake` starts no new iteration, and it ends each sleep and each backoff.
371
- * - `drain` waits for each iteration in flight until the deadline, and gives it the cooperative
372
- * abort. A throw after that abort is not a failure.
373
- * - `close` aborts each iteration, waits for its end, and does the teardown, all in `close_bound`.
374
- */
375
- export declare const workerLoop: <S = undefined>(knobs: WorkerKnobs, options: WorkerLoopOptions<S>) => WorkerLoop;
376
- /**
377
- * The startup gate opens one time. The lifecycle moves it from `closed` to `starting` while its
378
- * components start. Then one warm-up sweep of each check opens it. A component that does not start
379
- * fails it for good.
380
- */
381
- export declare const GATE_MACHINE: Machine;
382
- /** A debounce latch counts the polls of its check in sequence. A readiness latch starts tripped. */
383
- export declare const LATCH_MACHINE: Machine;
384
- /**
385
- * A window latch measures time on the monotonic clock from the first failure of a sequence, and
386
- * from the first pass after a trip.
387
- */
388
- export declare const WINDOW_MACHINE: Machine;
389
- /**
390
- * A poller starts one check on a jittered loop with a fixed delay. A call that outlives its timeout
391
- * stays pending (`hung`), and the poller does not start the check again until the call settles.
392
- */
393
- export declare const POLLER_MACHINE: Machine;
394
- /**
395
- * The exit manager is the only part that ends the process. The first exit request starts the
396
- * shutdown. A later request has no effect, but a repeat signal exits at once when the declaration
397
- * says `onRepeatSignal: "exit"`. The exit code is the code of the exit request, else 1 after an
398
- * error, else 0.
399
- */
400
- export declare const EXIT_MACHINE: Machine;
401
- /** A watchdog measures how late its own tick comes, and a late tick shows a blocked event loop. */
402
- export declare const WATCHDOG_MACHINE: Machine;
403
- /** This function gives the name of a knob for the cap of a phase: `drain` gives `drain_cap`. */
404
- export declare const capKnob: (phase: string) => string;
405
- /**
406
- * This function gives the drain of a declaration as a machine. It has one state for each declared
407
- * phase, in its sequence, and each state has a timer at its cap. The drain also has the cooperative abort: the
408
- * cap of the drain less the cooperative window. With the floor `half`, it is half that cap at the
409
- * least. With the floor `none`, it is 0 at the least.
410
- */
411
- export declare const drainMachine: (description: ServiceDescription) => Machine;
412
- /** These are the static machines of the runtime, by the name that their events carry. */
413
- export declare const MACHINES: Readonly<Record<Exclude<MachineName, "drain" | "client">, Machine>>;
414
- export { type Allowed, type Backoff, type Binding, type Bound, type CalendarWindow, type CallContext, type Cancel, type CapacityRefused, type Change, type Check, type CheckFn, type CheckMetrics, type CheckVerdict, type Claim, type Clock, type Compressed, type Compression, type ConsoleLoggerOptions, type ConsoleTarget, type Controller, type ControllerBuilder, type CooperativeFloor, type Coupling, DRAIN_RULES, DURATION_FRACTIONS, type Decision, type DelayBand, type Dependency, type DependencyHandle, type DurationHistogram, EPISODES_KEPT, EXIT_SIGNALS, type EmbeddedProcess, type Episode, type Epochs, type Evaluated, type ExitCodes, type ExitSignal, type ExitTrigger, FORMAT, type FailsBy, type Finding, type Gate, type Health, type HealthMetrics, type HealthServer, type HealthVerdict, type Heartbeat, type HeartbeatOptions, type HostStream, type Idempotency, type IdentityType, type IncomingHeaders, type Inequality, type IterationContext, type Jitter, type JobAction, type JobContext, type JobFailure, type JobSettle, type JobSource, type KeyState, type KeyedLimiter, type KeyedQuota, LOG_LEVELS, type Lifecycle, type LifecycleEvent, type LifecycleState, type LimitPolicy, type LimitRule, type Limiter, type LimiterEviction, type LimiterSpec, type LimiterState, type LimiterStore, type LimiterStoreSpec, type LocalLimiter, type LogEntry, type LogFields, type LogFormat, type LogLevel, type Logger, type MachineName, type MemoryQuotaStore, type MemoryStore, type MessageShape, type MessageTrigger, O04, O09, O10, O16, type Operation, type OperationOf, type Outcome, PROCESS_TRIGGERS, type Phase, type PhaseContext, type PhaseWork, type PlatformClockOptions, type PodTiming, type Poll, type ProbeAnswer, type ProbeKind, type ProcessHost, type ProcessPort, type ProcessTrigger, type Profile, type ProgressMarks, type QueueDrain, type QueueDrainOptions, type QueueKnobs, type QuotaAllowed, type QuotaAnswer, type QuotaCapacityRefused, type QuotaChange, type QuotaEvent, type QuotaPart, type QuotaReading, type QuotaRecord, type QuotaRefused, type QuotaRule, type QuotaSpec, type QuotaState, type QuotaStep, type QuotaStore, type QuotaTakeStep, type QuotaVerdict, type QuotaWaitRefused, type QuotaWindow, type QuotasVerdict, type Recorder, type RedeliveryPolicy, type RefusalCause, type Refused, type RepeatSignal, type RequestEnd, type RequestEvent, type RequestFn, type RequestOptions, type RequestStream, type RequestWork, type RequeueCause, type Result, type Retrier, type RetrierOptions, type RetryOptions, type RollingWindow, type RoutePattern, type RouteRequest, type Rule, type RunOptions, SLIDING_WINDOW_MACHINE, STAGES, type Scenario, type ScenarioValue, type ScopedChange, type ServiceBuilder, type ServiceDescription, type ShutdownOptions, type Side, type SlidingWindow, type Span, type Stage, type StartOptions, type Statistic, type Step, type Stop, type StopWay, type StoreFailure, TOKEN_BUCKET_MACHINE, type TakeQuotasOptions, type TakeRequest, type TakeStep, type Term, type TimerMark, type TimerMarks, type Timing, type TokenBucket, type TraceIds, type TraceIdsSource, type Transport, type TransportImpl, UNCAUGHT_ORIGINS, type UncaughtOptions, type UncaughtOrigin, type UnitRequest, type Verdict, type WaitCause, type WaitRefused, type Watchdog, type WatchdogSpec, type WorkerKnobs, type WorkerLoop, type WorkerLoopOptions, asDebounce, asWindow, atLeast, backoffBand, backoffDelay, backoffProblems, capacityOf, compress, compression, consoleLogger, cooperativeAbortAt, daemon, decide, detectionTime, embeddedProcess, ephemeral, evaluate, failSpan, freeAt, heartbeat, heartbeatDetection, idleSpan, inequalities, isExitCode, isExitSignal, isMessageShape, keyedLimiter, keyedQuota, kubernetes, limitRule, limiterMachine, limiterProblems, limiterStateOf, localDev, logEvents, longestRetryAfter, matchesMessage, mayReissue, memoryQuotaStore, memoryStore, nodeProcess, overCapacity, platformClock, processPortOf, queueDrain, quotaProblems, quotaRule, quotaStep, realClock, recoverSpan, redact, redeliverOnce, replay, retryAfterSeconds, service, stageRank, symbolsOf, takeQuotas, unitsOf, verdictOf, watchdog };
37
+ export { type Allowed, BOUND_RULES, type Backoff, type Binding, type Bound, CLOSE_BOUND_RULE, type CalendarWindow, type CallContext, type Cancel, type CapacityRefused, type Change, type Check, type CheckFn, type CheckMetrics, type CheckVerdict, type Claim, type Clock, type Compressed, type Compression, type ConsoleLoggerOptions, type ConsoleTarget, type Controller, type ControllerBuilder, type CooperativeFloor, type Coupling, DECLARATION_RULE, DRAIN_RULES, DRAIN_RULE_IDS, DURATION_FRACTIONS, type Decision, type DelayBand, type Dependency, type DependencyHandle, type DurationHistogram, EPISODES_KEPT, EXIT_MACHINE, EXIT_SIGNALS, type EmbeddedProcess, type Episode, type Epochs, type Evaluated, type ExitCodes, type ExitSignal, type ExitTrigger, FORMAT, type FailsBy, type Finding, GATE_MACHINE, type Gate, type Health, type HealthMetrics, type HealthServer, type HealthVerdict, type Heartbeat, type HeartbeatOptions, type HostStream, IDENTITY_TYPES, type Idempotency, type IdentityType, type IncomingHeaders, type Inequality, type IterationContext, type Jitter, type JobAction, type JobContext, type JobFailure, type JobSettle, type JobSource, type KeyState, type KeyedLimiter, type KeyedQuota, LATCH_MACHINE, LAW_STATISTIC, LIMITER_RULES, LOG_LEVELS, type Lifecycle, type LifecycleEvent, type LifecycleState, type LimitPolicy, type LimitRule, type Limiter, type LimiterEviction, type LimiterSpec, type LimiterState, type LimiterStore, type LimiterStoreSpec, type LocalLimiter, type LogEntry, type LogFields, type LogFormat, type LogLevel, type Logger, MACHINES, type MachineName, type MemoryQuotaStore, type MemoryStore, type MessageShape, type MessageTrigger, NAME_RULE, O04, O09, O10, O16, type Operation, type OperationOf, type Outcome, PLATFORM_MARKS, POLLER_MACHINE, PROCESS_TRIGGERS, PROGRESS_RULE, type Phase, type PhaseContext, type PhaseWork, type PlatformClockOptions, type PodTiming, type Poll, type ProbeAnswer, type ProbeKind, type ProcessHost, type ProcessPort, type ProcessTrigger, type Profile, type ProgressMarks, type QueueDrain, type QueueDrainOptions, type QueueKnobs, type QuotaAllowed, type QuotaAnswer, type QuotaCapacityRefused, type QuotaChange, type QuotaEvent, type QuotaPart, type QuotaReading, type QuotaRecord, type QuotaRefused, type QuotaRule, type QuotaSpec, type QuotaState, type QuotaStep, type QuotaStore, type QuotaTakeStep, type QuotaVerdict, type QuotaWaitRefused, type QuotaWindow, type QuotasVerdict, type Recorder, type RedeliveryPolicy, type RefusalCause, type Refused, type RepeatSignal, type RequestEnd, type RequestEvent, type RequestFn, type RequestOptions, type RequestStream, type RequestWork, type RequeueCause, type Result, type Retrier, type RetrierOptions, type RetryOptions, type RollingWindow, type RoutePattern, type RouteRequest, type Rule, type RunOptions, SERVICE_RULES, SLIDING_WINDOW_MACHINE, STAGES, STOPS, STOP_RULE, type Scenario, type ScenarioValue, type ScopedChange, type ServiceBuilder, type ServiceDescription, type ShutdownOptions, type Side, type SlidingWindow, type Span, type Stage, type StartOptions, type Statistic, type Step, type Stop, type StopWay, type StoreFailure, TOKEN_BUCKET_MACHINE, type TakeQuotasOptions, type TakeRequest, type TakeStep, type Term, type TimerMark, type TimerMarks, type Timing, type TokenBucket, type TraceIds, type TraceIdsSource, type Transport, type TransportImpl, UNCAUGHT_ORIGINS, UNIT_BOUND_RULE, type UncaughtOptions, type UncaughtOrigin, type UnitRequest, type Verdict, WATCHDOG_MACHINE, WINDOW_MACHINE, type WaitCause, type WaitRefused, type Watchdog, type WatchdogSpec, type WorkerKnobs, type WorkerLoop, type WorkerLoopOptions, asDebounce, asWindow, atLeast, backoffBand, backoffDelay, backoffProblems, capKnob, capacityOf, compress, compression, compressionOf, consoleLogger, cooperativeAbortAt, daemon, decide, detectionTime, drainMachine, embeddedProcess, ephemeral, evaluate, failSpan, freeAt, heartbeat, heartbeatDetection, idleSpan, inequalities, isExitCode, isExitSignal, isMessageShape, keyedLimiter, keyedQuota, kubernetes, limitRule, limiterMachine, limiterProblems, limiterStateOf, lint, lintStop, localDev, logEvents, longestRetryAfter, matchesMessage, mayReissue, memoryQuotaStore, memoryStore, nodeProcess, overCapacity, platformClock, processPortOf, queueDrain, quotaProblems, quotaRule, quotaStep, realClock, recoverSpan, redact, redeliverOnce, replay, retrier, retry, retryAfterDelay, retryAfterSeconds, service, serviceBindings, stageRank, symbolsOf, takeQuotas, unitsOf, verdictOf, watchdog, workerLoop };