@mark1russell7/service 0.8.19 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (335) hide show
  1. package/README.md +6 -2
  2. package/build/backoff.d.ts +44 -2
  3. package/build/{builder-zO48Vgoj.d.ts → builder.d.ts} +14 -101
  4. package/build/builder.js +499 -0
  5. package/build/builder.js.map +1 -0
  6. package/build/{call-context-DDhcVvn5.d.ts → call-context.d.ts} +3 -4
  7. package/build/channel.d.ts +1 -1
  8. package/build/channel.js.map +1 -1
  9. package/build/{core-BSzt4RI2.d.ts → client/core.d.ts} +32 -61
  10. package/build/{machine-BhVeHr_m.js → client/core.js} +4 -153
  11. package/build/client/core.js.map +1 -0
  12. package/build/{dial-ChwIcvd4.d.ts → client/dial.d.ts} +3 -4
  13. package/build/client/dial.js +52 -0
  14. package/build/client/dial.js.map +1 -0
  15. package/build/client/machine.js +29 -0
  16. package/build/client/machine.js.map +1 -0
  17. package/build/client/meets.d.ts +35 -0
  18. package/build/client/meets.js +78 -0
  19. package/build/client/meets.js.map +1 -0
  20. package/build/clock.d.ts +2 -2
  21. package/build/clock.js +1 -1
  22. package/build/conformance.d.ts +122 -0
  23. package/build/conformance.js +469 -0
  24. package/build/conformance.js.map +1 -0
  25. package/build/contract.d.ts +28 -0
  26. package/build/contract.js +184 -0
  27. package/build/contract.js.map +1 -0
  28. package/build/description.d.ts +161 -0
  29. package/build/description.js +11 -0
  30. package/build/description.js.map +1 -0
  31. package/build/drains.js +35 -0
  32. package/build/drains.js.map +1 -0
  33. package/build/events.d.ts +25 -0
  34. package/build/fakes.d.ts +43 -0
  35. package/build/fakes.js +93 -0
  36. package/build/fakes.js.map +1 -0
  37. package/build/grpc/client.d.ts +153 -0
  38. package/build/grpc/client.js +474 -0
  39. package/build/grpc/client.js.map +1 -0
  40. package/build/grpc/connection.d.ts +97 -0
  41. package/build/grpc/connection.js +59 -0
  42. package/build/grpc/connection.js.map +1 -0
  43. package/build/grpc/machine.d.ts +12 -0
  44. package/build/grpc/machine.js +149 -0
  45. package/build/grpc/machine.js.map +1 -0
  46. package/build/grpc/meets.d.ts +14 -0
  47. package/build/grpc/meets.js +105 -0
  48. package/build/grpc/meets.js.map +1 -0
  49. package/build/grpc/starting.d.ts +33 -0
  50. package/build/grpc/starting.js +89 -0
  51. package/build/grpc/starting.js.map +1 -0
  52. package/build/grpc.d.ts +9 -303
  53. package/build/grpc.js +7 -854
  54. package/build/health.d.ts +93 -0
  55. package/build/health.js +225 -0
  56. package/build/health.js.map +1 -0
  57. package/build/heartbeat.d.ts +6 -2
  58. package/build/heartbeat.js.map +1 -1
  59. package/build/host/discovery.d.ts +61 -0
  60. package/build/host/discovery.js +113 -0
  61. package/build/host/discovery.js.map +1 -0
  62. package/build/host/env.d.ts +14 -0
  63. package/build/host/env.js +57 -0
  64. package/build/host/env.js.map +1 -0
  65. package/build/host/fakes.d.ts +82 -0
  66. package/build/host/fakes.js +239 -0
  67. package/build/host/fakes.js.map +1 -0
  68. package/build/host/group.d.ts +142 -0
  69. package/build/host/group.js +524 -0
  70. package/build/host/group.js.map +1 -0
  71. package/build/host/install.d.ts +96 -0
  72. package/build/host/install.js +330 -0
  73. package/build/host/install.js.map +1 -0
  74. package/build/host/lock.d.ts +78 -0
  75. package/build/host/lock.js +190 -0
  76. package/build/host/lock.js.map +1 -0
  77. package/build/host/logs.d.ts +26 -0
  78. package/build/host/logs.js +48 -0
  79. package/build/host/logs.js.map +1 -0
  80. package/build/host/node.d.ts +14 -0
  81. package/build/host/node.js +309 -0
  82. package/build/host/node.js.map +1 -0
  83. package/build/{ports-B1ayTL-j.d.ts → host/ports.d.ts} +15 -16
  84. package/build/host/ports.js +17 -0
  85. package/build/host/ports.js.map +1 -0
  86. package/build/host/probes.d.ts +51 -0
  87. package/build/host/probes.js +139 -0
  88. package/build/host/probes.js.map +1 -0
  89. package/build/host/processes.d.ts +32 -0
  90. package/build/host/processes.js +63 -0
  91. package/build/host/processes.js.map +1 -0
  92. package/build/host/render.d.ts +84 -0
  93. package/build/host/render.js +235 -0
  94. package/build/host/render.js.map +1 -0
  95. package/build/host/watch.d.ts +90 -0
  96. package/build/host/watch.js +165 -0
  97. package/build/host/watch.js.map +1 -0
  98. package/build/host.d.ts +13 -671
  99. package/build/host.js +12 -2126
  100. package/build/http/answers.js +29 -0
  101. package/build/http/answers.js.map +1 -0
  102. package/build/http/fake-server.js +61 -0
  103. package/build/http/fake-server.js.map +1 -0
  104. package/build/http/outcome.d.ts +115 -0
  105. package/build/http/outcome.js +325 -0
  106. package/build/http/outcome.js.map +1 -0
  107. package/build/http/probes.d.ts +83 -0
  108. package/build/http/probes.js +232 -0
  109. package/build/http/probes.js.map +1 -0
  110. package/build/http/transport.d.ts +165 -0
  111. package/build/http/transport.js +518 -0
  112. package/build/http/transport.js.map +1 -0
  113. package/build/http-client/client.d.ts +121 -0
  114. package/build/http-client/client.js +330 -0
  115. package/build/http-client/client.js.map +1 -0
  116. package/build/http-client/connection.d.ts +78 -0
  117. package/build/http-client/connection.js +54 -0
  118. package/build/http-client/connection.js.map +1 -0
  119. package/build/http-client/machine.d.ts +14 -0
  120. package/build/http-client/machine.js +109 -0
  121. package/build/http-client/machine.js.map +1 -0
  122. package/build/http-client/meets.d.ts +11 -0
  123. package/build/http-client/meets.js +74 -0
  124. package/build/http-client/meets.js.map +1 -0
  125. package/build/http-client/session.d.ts +87 -0
  126. package/build/http-client/session.js +99 -0
  127. package/build/http-client/session.js.map +1 -0
  128. package/build/http-client/starting.d.ts +25 -0
  129. package/build/http-client/starting.js +65 -0
  130. package/build/http-client/starting.js.map +1 -0
  131. package/build/http-client.d.ts +9 -330
  132. package/build/http-client.js +8 -707
  133. package/build/http.d.ts +5 -353
  134. package/build/http.js +3 -1086
  135. package/build/identity.d.ts +16 -0
  136. package/build/identity.js +44 -0
  137. package/build/identity.js.map +1 -0
  138. package/build/index.d.ts +35 -412
  139. package/build/index.js +25 -3278
  140. package/build/knobs.d.ts +1 -0
  141. package/build/{knobs-BJcz6m01.js → knobs.js} +2 -34
  142. package/build/knobs.js.map +1 -0
  143. package/build/latch.d.ts +29 -0
  144. package/build/latch.js +122 -0
  145. package/build/latch.js.map +1 -0
  146. package/build/{rules-HyFCBStQ.d.ts → law.d.ts} +19 -37
  147. package/build/law.js +149 -0
  148. package/build/law.js.map +1 -0
  149. package/build/lifecycle.d.ts +144 -0
  150. package/build/lifecycle.js +411 -0
  151. package/build/lifecycle.js.map +1 -0
  152. package/build/limiter/machine.d.ts +40 -0
  153. package/build/limiter/machine.js +279 -0
  154. package/build/limiter/machine.js.map +1 -0
  155. package/build/{policy-CBcK2XGg.d.ts → limiter/policy.d.ts} +28 -29
  156. package/build/{policy-UYALkqVq.js → limiter/policy.js} +10 -9
  157. package/build/limiter/policy.js.map +1 -0
  158. package/build/{limiter-BNKnwzeY.d.ts → limiter/quota.d.ts} +32 -74
  159. package/build/{limiter-DrM0PQV9.js → limiter/quota.js} +3 -418
  160. package/build/limiter/quota.js.map +1 -0
  161. package/build/{store-DFwFKrsB.d.ts → limiter/store.d.ts} +10 -11
  162. package/build/limiter/store.js +145 -0
  163. package/build/limiter/store.js.map +1 -0
  164. package/build/limiter.d.ts +4 -3
  165. package/build/limiter.js +4 -2
  166. package/build/lint.d.ts +152 -0
  167. package/build/lint.js +576 -0
  168. package/build/lint.js.map +1 -0
  169. package/build/logger.d.ts +71 -0
  170. package/build/logger.js +183 -0
  171. package/build/logger.js.map +1 -0
  172. package/build/machines.d.ts +41 -0
  173. package/build/machines.js +451 -0
  174. package/build/machines.js.map +1 -0
  175. package/build/metrics.d.ts +53 -0
  176. package/build/metrics.js +111 -0
  177. package/build/metrics.js.map +1 -0
  178. package/build/mongodb/client.d.ts +131 -0
  179. package/build/mongodb/client.js +388 -0
  180. package/build/mongodb/client.js.map +1 -0
  181. package/build/mongodb/connection.d.ts +112 -0
  182. package/build/mongodb/connection.js +12 -0
  183. package/build/mongodb/connection.js.map +1 -0
  184. package/build/mongodb/machine.d.ts +14 -0
  185. package/build/mongodb/machine.js +122 -0
  186. package/build/mongodb/machine.js.map +1 -0
  187. package/build/mongodb/meets.d.ts +15 -0
  188. package/build/mongodb/meets.js +103 -0
  189. package/build/mongodb/meets.js.map +1 -0
  190. package/build/mongodb/starting.d.ts +29 -0
  191. package/build/mongodb/starting.js +77 -0
  192. package/build/mongodb/starting.js.map +1 -0
  193. package/build/mongodb.d.ts +8 -296
  194. package/build/mongodb.js +7 -682
  195. package/build/operation.d.ts +27 -0
  196. package/build/{operation-DF73RZOI.js → operation.js} +2 -2
  197. package/build/operation.js.map +1 -0
  198. package/build/otel.d.ts +2 -2
  199. package/build/pg/client.d.ts +96 -0
  200. package/build/pg/client.js +277 -0
  201. package/build/pg/client.js.map +1 -0
  202. package/build/pg/connection.d.ts +75 -0
  203. package/build/pg/connection.js +11 -0
  204. package/build/pg/connection.js.map +1 -0
  205. package/build/pg/machine.d.ts +13 -0
  206. package/build/pg/machine.js +111 -0
  207. package/build/pg/machine.js.map +1 -0
  208. package/build/pg/meets.d.ts +14 -0
  209. package/build/pg/meets.js +83 -0
  210. package/build/pg/meets.js.map +1 -0
  211. package/build/pg/starting.d.ts +26 -0
  212. package/build/pg/starting.js +62 -0
  213. package/build/pg/starting.js.map +1 -0
  214. package/build/pg.d.ts +8 -219
  215. package/build/pg.js +7 -525
  216. package/build/poller.d.ts +9 -0
  217. package/build/poller.js +154 -0
  218. package/build/poller.js.map +1 -0
  219. package/build/process.d.ts +114 -0
  220. package/build/process.js +170 -0
  221. package/build/process.js.map +1 -0
  222. package/build/profiles.d.ts +68 -0
  223. package/build/profiles.js +120 -0
  224. package/build/profiles.js.map +1 -0
  225. package/build/{queue-DXdw1vLO.d.ts → queue.d.ts} +16 -29
  226. package/build/queue.js +279 -0
  227. package/build/queue.js.map +1 -0
  228. package/build/rabbitmq/client.d.ts +144 -0
  229. package/build/rabbitmq/client.js +426 -0
  230. package/build/rabbitmq/client.js.map +1 -0
  231. package/build/rabbitmq/connection.d.ts +91 -0
  232. package/build/rabbitmq/connection.js +15 -0
  233. package/build/rabbitmq/connection.js.map +1 -0
  234. package/build/rabbitmq/machine.d.ts +13 -0
  235. package/build/rabbitmq/machine.js +159 -0
  236. package/build/rabbitmq/machine.js.map +1 -0
  237. package/build/rabbitmq/meets.d.ts +12 -0
  238. package/build/rabbitmq/meets.js +96 -0
  239. package/build/rabbitmq/meets.js.map +1 -0
  240. package/build/rabbitmq/starting.d.ts +27 -0
  241. package/build/rabbitmq/starting.js +67 -0
  242. package/build/rabbitmq/starting.js.map +1 -0
  243. package/build/rabbitmq.d.ts +8 -283
  244. package/build/rabbitmq.js +7 -742
  245. package/build/redis/client.d.ts +86 -0
  246. package/build/redis/client.js +285 -0
  247. package/build/redis/client.js.map +1 -0
  248. package/build/redis/connection.d.ts +57 -0
  249. package/build/redis/connection.js +11 -0
  250. package/build/redis/connection.js.map +1 -0
  251. package/build/redis/limiter.d.ts +43 -0
  252. package/build/redis/limiter.js +164 -0
  253. package/build/redis/limiter.js.map +1 -0
  254. package/build/redis/machine.d.ts +12 -0
  255. package/build/redis/machine.js +144 -0
  256. package/build/redis/machine.js.map +1 -0
  257. package/build/redis/meets.d.ts +11 -0
  258. package/build/redis/meets.js +75 -0
  259. package/build/redis/meets.js.map +1 -0
  260. package/build/redis/operations.d.ts +5 -0
  261. package/build/redis/operations.js +114 -0
  262. package/build/redis/operations.js.map +1 -0
  263. package/build/redis.d.ts +10 -207
  264. package/build/redis.js +9 -771
  265. package/build/requests.d.ts +66 -0
  266. package/build/requests.js +279 -0
  267. package/build/requests.js.map +1 -0
  268. package/build/retrier.d.ts +62 -0
  269. package/build/{retrier-Dnjhvxol.js → retrier.js} +2 -2
  270. package/build/retrier.js.map +1 -0
  271. package/build/routes.d.ts +35 -0
  272. package/build/routes.js +77 -0
  273. package/build/routes.js.map +1 -0
  274. package/build/rules.d.ts +19 -2
  275. package/build/stops.d.ts +51 -0
  276. package/build/stops.js +86 -0
  277. package/build/stops.js.map +1 -0
  278. package/build/testing.d.ts +8 -270
  279. package/build/testing.js +4 -1027
  280. package/build/testing.js.map +1 -1
  281. package/build/timing.d.ts +63 -0
  282. package/build/{timing-DZl36uXs.js → timing.js} +2 -2
  283. package/build/timing.js.map +1 -0
  284. package/build/units.d.ts +17 -0
  285. package/build/units.js +236 -0
  286. package/build/units.js.map +1 -0
  287. package/build/watchdog.d.ts +38 -0
  288. package/build/watchdog.js +57 -0
  289. package/build/watchdog.js.map +1 -0
  290. package/build/websocket/client.d.ts +136 -0
  291. package/build/websocket/client.js +422 -0
  292. package/build/websocket/client.js.map +1 -0
  293. package/build/websocket/connection.d.ts +83 -0
  294. package/build/websocket/connection.js +57 -0
  295. package/build/websocket/connection.js.map +1 -0
  296. package/build/websocket/machine.d.ts +12 -0
  297. package/build/websocket/machine.js +155 -0
  298. package/build/websocket/machine.js.map +1 -0
  299. package/build/websocket/meets.d.ts +14 -0
  300. package/build/websocket/meets.js +92 -0
  301. package/build/websocket/meets.js.map +1 -0
  302. package/build/websocket/starting.d.ts +25 -0
  303. package/build/websocket/starting.js +69 -0
  304. package/build/websocket/starting.js.map +1 -0
  305. package/build/websocket.d.ts +9 -264
  306. package/build/websocket.js +8 -774
  307. package/build/worker.d.ts +92 -0
  308. package/build/worker.js +153 -0
  309. package/build/worker.js.map +1 -0
  310. package/package.json +5 -4
  311. package/build/backoff-QTRGfkEK.d.ts +0 -45
  312. package/build/clock-DpVgpY4h.d.ts +0 -2
  313. package/build/grpc.js.map +0 -1
  314. package/build/host.js.map +0 -1
  315. package/build/http-client.js.map +0 -1
  316. package/build/http.js.map +0 -1
  317. package/build/index.js.map +0 -1
  318. package/build/knobs-BJcz6m01.js.map +0 -1
  319. package/build/lifecycle-D0J-zwZF.d.ts +0 -374
  320. package/build/limiter-DrM0PQV9.js.map +0 -1
  321. package/build/logger-B6drv9w0.d.ts +0 -488
  322. package/build/machine-BhVeHr_m.js.map +0 -1
  323. package/build/mongodb.js.map +0 -1
  324. package/build/operation-DF73RZOI.js.map +0 -1
  325. package/build/pg.js.map +0 -1
  326. package/build/policy-UYALkqVq.js.map +0 -1
  327. package/build/process-7R9M29wN.js +0 -437
  328. package/build/process-7R9M29wN.js.map +0 -1
  329. package/build/rabbitmq.js.map +0 -1
  330. package/build/redis.js.map +0 -1
  331. package/build/requests-DD2ALv0_.js +0 -583
  332. package/build/requests-DD2ALv0_.js.map +0 -1
  333. package/build/retrier-Dnjhvxol.js.map +0 -1
  334. package/build/timing-DZl36uXs.js.map +0 -1
  335. package/build/websocket.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","names":[],"sources":["../../src/http-client/connection.ts"],"sourcesContent":["import type { ClientSocket, Factory } from \"../client/core.ts\";\n\n/** An HTTP socket is the socket of a client in the core: the join of the prober and the bounded close read it. */\nexport type HttpSocket = ClientSocket;\n\n/** An HTTP response is a whole response: its status, its headers, and its whole body. */\nexport interface HttpResponse {\n readonly status: number;\n /** These are the headers of the response, by their names in lower case, as Node gives them. */\n readonly headers: Readonly<Record<string, string | readonly string[] | undefined>>;\n readonly body: Buffer;\n}\n\n/** An agent request is one request that the wrapper gives the agent. */\nexport interface AgentRequest {\n readonly host: string;\n readonly port: number;\n readonly method: string;\n readonly path: string;\n readonly headers: Readonly<Record<string, string>>;\n readonly body?: Uint8Array | undefined;\n}\n\n/**\n * These are the events of one request that the wrapper reads. The agent gives each one at most one\n * time. `connect` comes only for a new connection. A request on a free socket left the client when it got that socket.\n */\nexport interface AgentEvents {\n /** The agent gave the request a socket. `reused` is true for a socket from the free list (`req.reusedSocket`). */\n socket(socket: HttpSocket, reused: boolean): void;\n /** The new socket of the request connected. The request then leaves the client. */\n connect(): void;\n}\n\n/** An agent exchange is one request in the agent: the promise of its whole response, and the abort that destroys its socket. */\nexport interface AgentExchange {\n /** This promise resolves with the whole response, or rejects with the error of the request, the socket or the body. */\n readonly response: Promise<HttpResponse>;\n /** This method destroys the request and its socket. A request that waits for a socket leaves the queue of the agent. */\n abort(error: Error): void;\n}\n\n/**\n * An agent is the part of an `http.Agent` of Node that the wrapper uses, with `http.request` on it.\n * A fake for tests has each part too. Thus the wrapper does not load node:http until it connects.\n */\nexport interface HttpAgent {\n /** This method sends one request on the agent. */\n request(request: AgentRequest, events: AgentEvents): AgentExchange;\n /** This method gives each socket of the agent that is open: the busy ones and the free ones. */\n sockets(): readonly HttpSocket[];\n /** This method destroys each socket of the agent. A request on a socket then fails. */\n destroy(): void;\n}\n\n/**\n * These are the options that the wrapper gives `new http.Agent`. Each one comes from the declaration.\n * The wrapper sets each option that has an effect on a timer, thus no default of Node decides one.\n */\nexport interface HttpAgentOptions {\n readonly keepAlive: true;\n /**\n * This time is the free socket timer (`timeout`). The agent closes a free socket at the smaller of\n * this time and the hint of the server less `agentKeepAliveTimeoutBuffer`. 0 is no timer, and then the hint does not apply.\n */\n readonly timeout: number;\n /** This time is subtracted from the hint of the server (`Keep-Alive: timeout=…`). A hint at or below it gives no reuse. */\n readonly agentKeepAliveTimeoutBuffer: number;\n /** This time is the idle time of TCP keepalive. The agent always turns keepalive on, and Node truncates the time to whole seconds. */\n readonly keepAliveMsecs: number;\n /** This count is the most sockets for one origin. A request waits in the agent for a socket above it. */\n readonly maxSockets: number;\n /** This count is the most free sockets for one origin. */\n readonly maxFreeSockets: number;\n /** The agent gives the socket that was free last, as the global agent does. */\n readonly scheduling: \"lifo\";\n}\n\n/** An agent factory makes the agent of the client from its options. */\nexport type AgentFactory = Factory<HttpAgentOptions, HttpAgent>;\n\n/** These are the parts of `node:http` that the factory uses. The specifier is a value, thus the entry loads node:http only at the connect. */\ninterface NodeHttp {\n readonly Agent: new (options: HttpAgentOptions) => NodeAgent;\n request(options: object): NodeRequest;\n}\n\ninterface NodeAgent {\n readonly sockets: Readonly<Record<string, readonly HttpSocket[] | undefined>>;\n readonly freeSockets: Readonly<Record<string, readonly HttpSocket[] | undefined>>;\n destroy(): void;\n}\n\ninterface NodeSocket extends HttpSocket {\n readonly connecting: boolean;\n once(event: \"connect\", listener: () => void): unknown;\n}\n\ninterface NodeIncoming {\n readonly statusCode?: number | undefined;\n readonly headers: Readonly<Record<string, string | string[] | undefined>>;\n readonly complete: boolean;\n on(event: \"data\", listener: (chunk: Buffer) => void): unknown;\n on(event: \"end\" | \"close\", listener: () => void): unknown;\n on(event: \"error\", listener: (error: Error) => void): unknown;\n}\n\ninterface NodeRequest {\n readonly reusedSocket: boolean;\n on(event: \"socket\", listener: (socket: NodeSocket) => void): unknown;\n on(event: \"response\", listener: (response: NodeIncoming) => void): unknown;\n on(event: \"error\", listener: (error: Error) => void): unknown;\n end(body?: Uint8Array): void;\n destroy(error?: Error): void;\n}\n\n/**\n * This factory makes an `http.Agent` of Node. It loads node:http only when a client connects.\n * Each request goes through `http.request` with the agent. The response settles at the end of its body.\n * A body that ends before it is complete rejects the response.\n */\nexport const nodeAgent: AgentFactory = async (options) => {\n const specifier = \"node:http\";\n const http = (await import(specifier)) as NodeHttp;\n const agent = new http.Agent(options);\n const all = (lists: Readonly<Record<string, readonly HttpSocket[] | undefined>>): HttpSocket[] => Object.values(lists).flatMap((list) => list ?? []);\n return {\n request(request, events) {\n const req = http.request({ host: request.host, port: request.port, method: request.method, path: request.path, headers: request.headers, agent });\n const response = new Promise<HttpResponse>((resolve, reject) => {\n req.on(\"socket\", (socket) => {\n events.socket(socket, req.reusedSocket);\n if (socket.connecting) socket.once(\"connect\", () => events.connect());\n else if (!req.reusedSocket) events.connect();\n });\n req.on(\"response\", (incoming) => {\n const chunks: Buffer[] = [];\n incoming.on(\"data\", (chunk) => chunks.push(chunk));\n incoming.on(\"error\", reject);\n incoming.on(\"end\", () => resolve({ status: incoming.statusCode ?? 0, headers: incoming.headers, body: Buffer.concat(chunks) }));\n incoming.on(\"close\", () => {\n if (!incoming.complete) reject(new Error(\"the connection closed before the end of the body\"));\n });\n });\n req.on(\"error\", reject);\n });\n req.end(request.body);\n return { response, abort: (error) => req.destroy(error) };\n },\n sockets: () => [...all(agent.sockets), ...all(agent.freeSockets)],\n destroy: () => agent.destroy(),\n };\n};\n"],"mappings":";;;;;;AAyHA,MAAa,YAA0B,OAAO,YAAY;CAExD,MAAM,OAAQ,MAAM,OAAO;CAC3B,MAAM,QAAQ,IAAI,KAAK,MAAM,OAAO;CACpC,MAAM,OAAO,UAAqF,OAAO,OAAO,KAAK,CAAC,CAAC,SAAS,SAAS,QAAQ,CAAC,CAAC;CACnJ,OAAO;EACL,QAAQ,SAAS,QAAQ;GACvB,MAAM,MAAM,KAAK,QAAQ;IAAE,MAAM,QAAQ;IAAM,MAAM,QAAQ;IAAM,QAAQ,QAAQ;IAAQ,MAAM,QAAQ;IAAM,SAAS,QAAQ;IAAS;GAAM,CAAC;GAChJ,MAAM,WAAW,IAAI,SAAuB,SAAS,WAAW;IAC9D,IAAI,GAAG,WAAW,WAAW;KAC3B,OAAO,OAAO,QAAQ,IAAI,YAAY;KACtC,IAAI,OAAO,YAAY,OAAO,KAAK,iBAAiB,OAAO,QAAQ,CAAC;UAC/D,IAAI,CAAC,IAAI,cAAc,OAAO,QAAQ;IAC7C,CAAC;IACD,IAAI,GAAG,aAAa,aAAa;KAC/B,MAAM,SAAmB,CAAC;KAC1B,SAAS,GAAG,SAAS,UAAU,OAAO,KAAK,KAAK,CAAC;KACjD,SAAS,GAAG,SAAS,MAAM;KAC3B,SAAS,GAAG,aAAa,QAAQ;MAAE,QAAQ,SAAS,cAAc;MAAG,SAAS,SAAS;MAAS,MAAM,OAAO,OAAO,MAAM;KAAE,CAAC,CAAC;KAC9H,SAAS,GAAG,eAAe;MACzB,IAAI,CAAC,SAAS,UAAU,uBAAO,IAAI,MAAM,kDAAkD,CAAC;KAC9F,CAAC;IACH,CAAC;IACD,IAAI,GAAG,SAAS,MAAM;GACxB,CAAC;GACD,IAAI,IAAI,QAAQ,IAAI;GACpB,OAAO;IAAE;IAAU,QAAQ,UAAU,IAAI,QAAQ,KAAK;GAAE;EAC1D;EACA,eAAe,CAAC,GAAG,IAAI,MAAM,OAAO,GAAG,GAAG,IAAI,MAAM,WAAW,CAAC;EAChE,eAAe,MAAM,QAAQ;CAC/B;AACF"}
@@ -0,0 +1,14 @@
1
+ import { Machine } from "@mark1russell7/algebra";
2
+ /**
3
+ * The HTTP client of the service as a `mark1russell7.machine/1` document. It is the agent as the
4
+ * wrapper sees it, not one socket: the document `node-http-agent` of `@mark1russell7/machines`
5
+ * gives each socket of the agent. The state is the outcome of the last connect of a socket:
6
+ * - `ready`: the last connect succeeded.
7
+ * - `failing`: the last connect failed, or did not end in connect_bound. The agent does not connect
8
+ * again by itself. The next request tries again.
9
+ *
10
+ * A free socket that the agent closes does not change the state. A request on a reused socket that
11
+ * fails records `reuse.failed`, and the state stays. A test records the transitions of the client
12
+ * and replays them against this document.
13
+ */
14
+ export declare const HTTP_CLIENT_MACHINE: Machine;
@@ -0,0 +1,109 @@
1
+ import { clientKnob, closeTimer, transition } from "../client/machine.js";
2
+ // src/http-client/machine.ts
3
+ /** The states where the agent exists and serves. */
4
+ const SERVING = [
5
+ "connecting",
6
+ "ready",
7
+ "failing"
8
+ ];
9
+ const OPEN = [...SERVING, "closing"];
10
+ /**
11
+ * The HTTP client of the service as a `mark1russell7.machine/1` document. It is the agent as the
12
+ * wrapper sees it, not one socket: the document `node-http-agent` of `@mark1russell7/machines`
13
+ * gives each socket of the agent. The state is the outcome of the last connect of a socket:
14
+ * - `ready`: the last connect succeeded.
15
+ * - `failing`: the last connect failed, or did not end in connect_bound. The agent does not connect
16
+ * again by itself. The next request tries again.
17
+ *
18
+ * A free socket that the agent closes does not change the state. A request on a reused socket that
19
+ * fails records `reuse.failed`, and the state stays. A test records the transitions of the client
20
+ * and replays them against this document.
21
+ */
22
+ const HTTP_CLIENT_MACHINE = {
23
+ format: "mark1russell7.machine/1",
24
+ id: "service.machine.http-client",
25
+ title: "The HTTP client of the service, over an http.Agent of Node",
26
+ layer: "driver",
27
+ version: "0.1.0",
28
+ sources: [{
29
+ ref: "packages/service/src/http-client (the client implements this document)",
30
+ rung: "implemented"
31
+ }],
32
+ states: {
33
+ none: {
34
+ initial: true,
35
+ note: "the client exists, and its agent does not"
36
+ },
37
+ connecting: { note: "the check request of the startup opens the first socket" },
38
+ ready: { note: "the last connect succeeded. A dead free socket stays hidden until the free socket timer or a request meets it" },
39
+ failing: { note: "the last connect failed. A request that waits for a socket of a full pool does not change the state" },
40
+ closing: { note: "the client waits for its calls in flight in close_bound, then destroys each socket of the agent" },
41
+ end: {
42
+ final: true,
43
+ note: "the service closed the client"
44
+ }
45
+ },
46
+ events: {
47
+ "status.connecting": { kind: "local" },
48
+ join: {
49
+ kind: "rx",
50
+ note: "a new socket of the agent connected: the request on it leaves the client (D1)"
51
+ },
52
+ "connect.failed": {
53
+ kind: "local",
54
+ note: "a connect failed: its error, or connect_bound"
55
+ },
56
+ "reuse.failed": {
57
+ kind: "rx",
58
+ note: "a request on a free socket that the agent reused failed: the server closed that socket"
59
+ },
60
+ "command.reissue": { kind: "local" },
61
+ "close.request": { kind: "local" },
62
+ "close.bound": {
63
+ kind: "timer",
64
+ note: "a call in flight did not end in close_bound"
65
+ },
66
+ "close.destroy": {
67
+ kind: "local",
68
+ note: "the bound destroys each socket of the agent, and each call in flight is indeterminate"
69
+ },
70
+ "status.end": { kind: "local" }
71
+ },
72
+ knobs: {
73
+ connect_bound: clientKnob("connect.bound"),
74
+ request_timeout: clientKnob("request.bound"),
75
+ pool_idle_expiry: clientKnob("timeout"),
76
+ hint_buffer: clientKnob("agentKeepAliveTimeoutBuffer"),
77
+ keepalive_idle: clientKnob("keepAliveMsecs"),
78
+ close_bound: clientKnob("close.bound")
79
+ },
80
+ timers: {
81
+ connect_timeout: {
82
+ duration: {
83
+ knob: "connect_bound",
84
+ unit: "s"
85
+ },
86
+ arms: ["enter:connecting"],
87
+ cancels: ["join", "connect.failed"],
88
+ fires: "connect.failed",
89
+ note: "the timer of the wrapper on the connect of a new socket. The agent has no connect timer"
90
+ },
91
+ close: closeTimer()
92
+ },
93
+ transitions: [
94
+ transition("connect", "none", "status.connecting", "connecting"),
95
+ transition("join", [...SERVING], "join", "ready"),
96
+ transition("connect-failed", [...SERVING], "connect.failed", "failing", { timer: "connect_timeout" }),
97
+ transition("join-closing", "closing", "join", "closing"),
98
+ transition("connect-failed-closing", "closing", "connect.failed", "closing"),
99
+ ...OPEN.map((state) => transition(`reuse-failed-${state}`, state, "reuse.failed", state)),
100
+ ...OPEN.map((state) => transition(`reissue-${state}`, state, "command.reissue", state)),
101
+ transition("close", [...SERVING], "close.request", "closing"),
102
+ transition("close-bound", "closing", "close.bound", "closing", { timer: "close" }),
103
+ transition("close-destroy", "closing", "close.destroy", "closing"),
104
+ transition("end", "closing", "status.end", "end")
105
+ ]
106
+ };
107
+ export { HTTP_CLIENT_MACHINE };
108
+
109
+ //# sourceMappingURL=machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"machine.js","names":["knob","t"],"sources":["../../src/http-client/machine.ts"],"sourcesContent":["import type { Machine } from \"@mark1russell7/algebra\";\nimport { clientKnob as knob, closeTimer, transition as t } from \"../client/machine.ts\";\n\n/** The states where the agent exists and serves. */\nconst SERVING = [\"connecting\", \"ready\", \"failing\"] as const;\nconst OPEN = [...SERVING, \"closing\"] as const;\n\n/**\n * The HTTP client of the service as a `mark1russell7.machine/1` document. It is the agent as the\n * wrapper sees it, not one socket: the document `node-http-agent` of `@mark1russell7/machines`\n * gives each socket of the agent. The state is the outcome of the last connect of a socket:\n * - `ready`: the last connect succeeded.\n * - `failing`: the last connect failed, or did not end in connect_bound. The agent does not connect\n * again by itself. The next request tries again.\n *\n * A free socket that the agent closes does not change the state. A request on a reused socket that\n * fails records `reuse.failed`, and the state stays. A test records the transitions of the client\n * and replays them against this document.\n */\nexport const HTTP_CLIENT_MACHINE: Machine = {\n format: \"mark1russell7.machine/1\",\n id: \"service.machine.http-client\",\n title: \"The HTTP client of the service, over an http.Agent of Node\",\n layer: \"driver\",\n version: \"0.1.0\",\n sources: [{ ref: \"packages/service/src/http-client (the client implements this document)\", rung: \"implemented\" }],\n states: {\n none: { initial: true, note: \"the client exists, and its agent does not\" },\n connecting: { note: \"the check request of the startup opens the first socket\" },\n ready: { note: \"the last connect succeeded. A dead free socket stays hidden until the free socket timer or a request meets it\" },\n failing: { note: \"the last connect failed. A request that waits for a socket of a full pool does not change the state\" },\n closing: { note: \"the client waits for its calls in flight in close_bound, then destroys each socket of the agent\" },\n end: { final: true, note: \"the service closed the client\" },\n },\n events: {\n \"status.connecting\": { kind: \"local\" },\n join: { kind: \"rx\", note: \"a new socket of the agent connected: the request on it leaves the client (D1)\" },\n \"connect.failed\": { kind: \"local\", note: \"a connect failed: its error, or connect_bound\" },\n \"reuse.failed\": { kind: \"rx\", note: \"a request on a free socket that the agent reused failed: the server closed that socket\" },\n \"command.reissue\": { kind: \"local\" },\n \"close.request\": { kind: \"local\" },\n \"close.bound\": { kind: \"timer\", note: \"a call in flight did not end in close_bound\" },\n \"close.destroy\": { kind: \"local\", note: \"the bound destroys each socket of the agent, and each call in flight is indeterminate\" },\n \"status.end\": { kind: \"local\" },\n },\n knobs: {\n connect_bound: knob(\"connect.bound\"),\n request_timeout: knob(\"request.bound\"),\n pool_idle_expiry: knob(\"timeout\"),\n hint_buffer: knob(\"agentKeepAliveTimeoutBuffer\"),\n keepalive_idle: knob(\"keepAliveMsecs\"),\n close_bound: knob(\"close.bound\"),\n },\n timers: {\n connect_timeout: {\n duration: { knob: \"connect_bound\", unit: \"s\" },\n arms: [\"enter:connecting\"],\n cancels: [\"join\", \"connect.failed\"],\n fires: \"connect.failed\",\n note: \"the timer of the wrapper on the connect of a new socket. The agent has no connect timer\",\n },\n close: closeTimer(),\n },\n transitions: [\n t(\"connect\", \"none\", \"status.connecting\", \"connecting\"),\n t(\"join\", [...SERVING], \"join\", \"ready\"),\n t(\"connect-failed\", [...SERVING], \"connect.failed\", \"failing\", { timer: \"connect_timeout\" }),\n // a request that is in flight at the close can still connect, or fail\n t(\"join-closing\", \"closing\", \"join\", \"closing\"),\n t(\"connect-failed-closing\", \"closing\", \"connect.failed\", \"closing\"),\n ...OPEN.map((state) => t(`reuse-failed-${state}`, state, \"reuse.failed\", state)),\n ...OPEN.map((state) => t(`reissue-${state}`, state, \"command.reissue\", state)),\n t(\"close\", [...SERVING], \"close.request\", \"closing\"),\n t(\"close-bound\", \"closing\", \"close.bound\", \"closing\", { timer: \"close\" }),\n t(\"close-destroy\", \"closing\", \"close.destroy\", \"closing\"),\n t(\"end\", \"closing\", \"status.end\", \"end\"),\n ],\n};\n"],"mappings":";;;AAIA,MAAM,UAAU;CAAC;CAAc;CAAS;AAAS;AACjD,MAAM,OAAO,CAAC,GAAG,SAAS,SAAS;;;;;;;;;;;;;AAcnC,MAAa,sBAA+B;CAC1C,QAAQ;CACR,IAAI;CACJ,OAAO;CACP,OAAO;CACP,SAAS;CACT,SAAS,CAAC;EAAE,KAAK;EAA0E,MAAM;CAAc,CAAC;CAChH,QAAQ;EACN,MAAM;GAAE,SAAS;GAAM,MAAM;EAA4C;EACzE,YAAY,EAAE,MAAM,0DAA0D;EAC9E,OAAO,EAAE,MAAM,gHAAgH;EAC/H,SAAS,EAAE,MAAM,sGAAsG;EACvH,SAAS,EAAE,MAAM,kGAAkG;EACnH,KAAK;GAAE,OAAO;GAAM,MAAM;EAAgC;CAC5D;CACA,QAAQ;EACN,qBAAqB,EAAE,MAAM,QAAQ;EACrC,MAAM;GAAE,MAAM;GAAM,MAAM;EAAgF;EAC1G,kBAAkB;GAAE,MAAM;GAAS,MAAM;EAAgD;EACzF,gBAAgB;GAAE,MAAM;GAAM,MAAM;EAAyF;EAC7H,mBAAmB,EAAE,MAAM,QAAQ;EACnC,iBAAiB,EAAE,MAAM,QAAQ;EACjC,eAAe;GAAE,MAAM;GAAS,MAAM;EAA8C;EACpF,iBAAiB;GAAE,MAAM;GAAS,MAAM;EAAwF;EAChI,cAAc,EAAE,MAAM,QAAQ;CAChC;CACA,OAAO;EACL,eAAeA,WAAK,eAAe;EACnC,iBAAiBA,WAAK,eAAe;EACrC,kBAAkBA,WAAK,SAAS;EAChC,aAAaA,WAAK,6BAA6B;EAC/C,gBAAgBA,WAAK,gBAAgB;EACrC,aAAaA,WAAK,aAAa;CACjC;CACA,QAAQ;EACN,iBAAiB;GACf,UAAU;IAAE,MAAM;IAAiB,MAAM;GAAI;GAC7C,MAAM,CAAC,kBAAkB;GACzB,SAAS,CAAC,QAAQ,gBAAgB;GAClC,OAAO;GACP,MAAM;EACR;EACA,OAAO,WAAW;CACpB;CACA,aAAa;EACXC,WAAE,WAAW,QAAQ,qBAAqB,YAAY;EACtDA,WAAE,QAAQ,CAAC,GAAG,OAAO,GAAG,QAAQ,OAAO;EACvCA,WAAE,kBAAkB,CAAC,GAAG,OAAO,GAAG,kBAAkB,WAAW,EAAE,OAAO,kBAAkB,CAAC;EAE3FA,WAAE,gBAAgB,WAAW,QAAQ,SAAS;EAC9CA,WAAE,0BAA0B,WAAW,kBAAkB,SAAS;EAClE,GAAG,KAAK,KAAK,UAAUA,WAAE,gBAAgB,SAAS,OAAO,gBAAgB,KAAK,CAAC;EAC/E,GAAG,KAAK,KAAK,UAAUA,WAAE,WAAW,SAAS,OAAO,mBAAmB,KAAK,CAAC;EAC7EA,WAAE,SAAS,CAAC,GAAG,OAAO,GAAG,iBAAiB,SAAS;EACnDA,WAAE,eAAe,WAAW,eAAe,WAAW,EAAE,OAAO,QAAQ,CAAC;EACxEA,WAAE,iBAAiB,WAAW,iBAAiB,SAAS;EACxDA,WAAE,OAAO,WAAW,cAAc,KAAK;CACzC;AACF"}
@@ -0,0 +1,11 @@
1
+ import { Meeting } from "../client/meets.js";
2
+ import { HttpClientKnobs } from "./client.js";
3
+ /**
4
+ * This function gives the manifestations that an HTTP client can meet, and the detectors of each,
5
+ * from its knobs. The HTTP cells measured them on the agent of Node 24.21.0:
6
+ * - The agent has no timer of a call, thus the timer of the wrapper finds each silent call in flight.
7
+ * - The free socket timer closes an idle socket at `pool_idle_expiry` at most. Thus no request goes
8
+ * later on a socket that went silent while it was free.
9
+ * - A FIN on a busy socket fails the call with "socket hang up". A FIN on a free socket destroys it.
10
+ */
11
+ export declare const httpClientMeetings: (name: string, knobs: HttpClientKnobs) => Meeting[];
@@ -0,0 +1,74 @@
1
+ import { WHAT, immediate, keepaliveAnswered, keepaliveReset, keepaliveSilent, kernelGiveUp } from "../client/meets.js";
2
+ // src/http-client/meets.ts
3
+ /**
4
+ * This function gives the manifestations that an HTTP client can meet, and the detectors of each,
5
+ * from its knobs. The HTTP cells measured them on the agent of Node 24.21.0:
6
+ * - The agent has no timer of a call, thus the timer of the wrapper finds each silent call in flight.
7
+ * - The free socket timer closes an idle socket at `pool_idle_expiry` at most. Thus no request goes
8
+ * later on a socket that went silent while it was free.
9
+ * - A FIN on a busy socket fails the call with "socket hang up". A FIN on a free socket destroys it.
10
+ */
11
+ const httpClientMeetings = (name, knobs) => {
12
+ const call = {
13
+ by: "request_timeout",
14
+ within: knobs.request_timeout,
15
+ situation: "in flight",
16
+ effect: `the timer of the wrapper ends the call as indeterminate, and ${name} destroys its socket`
17
+ };
18
+ const idleExpiry = (situation) => ({
19
+ by: "pool_idle_expiry",
20
+ within: knobs.pool_idle_expiry,
21
+ situation,
22
+ effect: "the free socket timer of the agent closes the socket, and the next request opens a new socket"
23
+ });
24
+ const giveUp = kernelGiveUp(knobs.retrans_giveup_time, "the call fails as indeterminate");
25
+ const silent = (manifestation) => ({
26
+ manifestation,
27
+ what: WHAT[manifestation],
28
+ detectors: [
29
+ call,
30
+ giveUp,
31
+ idleExpiry("idle"),
32
+ keepaliveSilent(knobs.keepalive_idle)
33
+ ]
34
+ });
35
+ return [
36
+ {
37
+ manifestation: "rst",
38
+ what: WHAT.rst,
39
+ detectors: [
40
+ immediate("in flight", "the call fails with ECONNRESET as indeterminate, and the next request opens a new socket"),
41
+ idleExpiry("idle"),
42
+ keepaliveReset(knobs.keepalive_idle)
43
+ ]
44
+ },
45
+ {
46
+ manifestation: "fin",
47
+ what: WHAT.fin,
48
+ detectors: [immediate("in flight", "the call fails with \"socket hang up\" as indeterminate"), immediate("idle", "the agent destroys the free socket, and the next request opens a new socket")]
49
+ },
50
+ silent("blackhole"),
51
+ silent("freeze-host"),
52
+ {
53
+ manifestation: "freeze-process",
54
+ what: WHAT["freeze-process"],
55
+ detectors: [
56
+ call,
57
+ idleExpiry("idle"),
58
+ keepaliveAnswered()
59
+ ]
60
+ },
61
+ {
62
+ manifestation: "app-stall",
63
+ what: "the server holds its reply, for example in a slow handler, and its kernel stays up",
64
+ detectors: [
65
+ call,
66
+ idleExpiry("idle"),
67
+ keepaliveAnswered()
68
+ ]
69
+ }
70
+ ];
71
+ };
72
+ export { httpClientMeetings };
73
+
74
+ //# sourceMappingURL=meets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meets.js","names":[],"sources":["../../src/http-client/meets.ts"],"sourcesContent":["import type { Detector, Meeting, Situation } from \"../client/meets.ts\";\nimport { WHAT, immediate, keepaliveAnswered, keepaliveReset, keepaliveSilent, kernelGiveUp } from \"../client/meets.ts\";\nimport type { HttpClientKnobs } from \"./client.ts\";\n\n/**\n * This function gives the manifestations that an HTTP client can meet, and the detectors of each,\n * from its knobs. The HTTP cells measured them on the agent of Node 24.21.0:\n * - The agent has no timer of a call, thus the timer of the wrapper finds each silent call in flight.\n * - The free socket timer closes an idle socket at `pool_idle_expiry` at most. Thus no request goes\n * later on a socket that went silent while it was free.\n * - A FIN on a busy socket fails the call with \"socket hang up\". A FIN on a free socket destroys it.\n */\nexport const httpClientMeetings = (name: string, knobs: HttpClientKnobs): Meeting[] => {\n const call: Detector = {\n by: \"request_timeout\",\n within: knobs.request_timeout,\n situation: \"in flight\",\n effect: `the timer of the wrapper ends the call as indeterminate, and ${name} destroys its socket`,\n };\n const idleExpiry = (situation: Situation): Detector => ({\n by: \"pool_idle_expiry\",\n within: knobs.pool_idle_expiry,\n situation,\n effect: \"the free socket timer of the agent closes the socket, and the next request opens a new socket\",\n });\n const giveUp = kernelGiveUp(knobs.retrans_giveup_time, \"the call fails as indeterminate\");\n const silent = (manifestation: \"blackhole\" | \"freeze-host\"): Meeting => ({\n manifestation,\n what: WHAT[manifestation],\n detectors: [call, giveUp, idleExpiry(\"idle\"), keepaliveSilent(knobs.keepalive_idle)],\n });\n return [\n {\n manifestation: \"rst\",\n what: WHAT.rst,\n detectors: [\n immediate(\"in flight\", \"the call fails with ECONNRESET as indeterminate, and the next request opens a new socket\"),\n idleExpiry(\"idle\"),\n keepaliveReset(knobs.keepalive_idle),\n ],\n },\n {\n manifestation: \"fin\",\n what: WHAT.fin,\n detectors: [\n immediate(\"in flight\", 'the call fails with \"socket hang up\" as indeterminate'),\n immediate(\"idle\", \"the agent destroys the free socket, and the next request opens a new socket\"),\n ],\n },\n silent(\"blackhole\"),\n silent(\"freeze-host\"),\n {\n manifestation: \"freeze-process\",\n what: WHAT[\"freeze-process\"],\n detectors: [call, idleExpiry(\"idle\"), keepaliveAnswered()],\n },\n {\n manifestation: \"app-stall\",\n what: \"the server holds its reply, for example in a slow handler, and its kernel stays up\",\n detectors: [call, idleExpiry(\"idle\"), keepaliveAnswered()],\n },\n ];\n};\n"],"mappings":";;;;;;;;;;AAYA,MAAa,sBAAsB,MAAc,UAAsC;CACrF,MAAM,OAAiB;EACrB,IAAI;EACJ,QAAQ,MAAM;EACd,WAAW;EACX,QAAQ,gEAAgE,KAAK;CAC/E;CACA,MAAM,cAAc,eAAoC;EACtD,IAAI;EACJ,QAAQ,MAAM;EACd;EACA,QAAQ;CACV;CACA,MAAM,SAAS,aAAa,MAAM,qBAAqB,iCAAiC;CACxF,MAAM,UAAU,mBAAyD;EACvE;EACA,MAAM,KAAK;EACX,WAAW;GAAC;GAAM;GAAQ,WAAW,MAAM;GAAG,gBAAgB,MAAM,cAAc;EAAC;CACrF;CACA,OAAO;EACL;GACE,eAAe;GACf,MAAM,KAAK;GACX,WAAW;IACT,UAAU,aAAa,0FAA0F;IACjH,WAAW,MAAM;IACjB,eAAe,MAAM,cAAc;GACrC;EACF;EACA;GACE,eAAe;GACf,MAAM,KAAK;GACX,WAAW,CACT,UAAU,aAAa,yDAAuD,GAC9E,UAAU,QAAQ,6EAA6E,CACjG;EACF;EACA,OAAO,WAAW;EAClB,OAAO,aAAa;EACpB;GACE,eAAe;GACf,MAAM,KAAK;GACX,WAAW;IAAC;IAAM,WAAW,MAAM;IAAG,kBAAkB;GAAC;EAC3D;EACA;GACE,eAAe;GACf,MAAM;GACN,WAAW;IAAC;IAAM,WAAW,MAAM;IAAG,kBAAkB;GAAC;EAC3D;CACF;AACF"}
@@ -0,0 +1,87 @@
1
+ import { Clock } from "../clock.js";
2
+ import { Extent, Quantity } from "@mark1russell7/quantity";
3
+ /**
4
+ * These are the knobs of the session check of an HTTP/2 client. They have the names and the units of
5
+ * the gRPC client, because the check is the same PING. The grpc-js driver ends its transport at the first PING with no ACK.
6
+ */
7
+ export interface SessionCheckKnobs {
8
+ /**
9
+ * This time is the quiet interval of a session. A tick comes at each interval, and it sends a PING
10
+ * when the session heard nothing since the last tick. "infinite" sends no PING.
11
+ */
12
+ readonly keepalive_time: Extent;
13
+ /** This time bounds the ACK of each PING. With no ACK in it, the check closes the session. */
14
+ readonly keepalive_timeout: Quantity;
15
+ }
16
+ /**
17
+ * A session is the part of an HTTP/2 session that the check uses. A `ClientHttp2Session` of
18
+ * `node:http2` has each member, thus the check does not load `node:http2`.
19
+ */
20
+ export interface H2Session {
21
+ /** This flag is true until the socket of the session connects. */
22
+ readonly connecting: boolean;
23
+ /** This method sends a PING. The callback gets null at the ACK, and an error otherwise. It gives false when the PING did not go. */
24
+ ping(callback: (error: Error | null) => void): boolean;
25
+ /** This method ends the session and each stream on it at once. */
26
+ destroy(error?: Error): void;
27
+ }
28
+ /** A close is the part of the check that closed the session. */
29
+ export type SessionClose = "stream timeout" | "no PING answer";
30
+ /** These options make a session check. */
31
+ export interface SessionCheckOptions {
32
+ readonly knobs: SessionCheckKnobs;
33
+ /**
34
+ * True lets a quiet session with no stream get a PING, as the option of the gRPC client does.
35
+ * The default is false: a server can refuse a PING with no stream (O26).
36
+ */
37
+ readonly keepaliveWithoutCalls?: boolean | undefined;
38
+ /** This clock gives the ticks and the timeouts. The default is `realClock`. */
39
+ readonly clock?: Clock | undefined;
40
+ /** This function receives the close of the session by the check, with its cause. */
41
+ readonly onClose?: ((cause: SessionClose) => void) | undefined;
42
+ }
43
+ /**
44
+ * A session check closes an HTTP/2 session that stopped answering. The caller tells it of each
45
+ * stream and of each frame from the peer. The next stream of the caller then opens a new session.
46
+ */
47
+ export interface SessionCheck {
48
+ /** This method tells the check that a stream started on the session. */
49
+ opened(): void;
50
+ /** This method tells the check that a stream ended with an answer or an error. */
51
+ ended(): void;
52
+ /** This method tells the check that a stream ended at its timeout. The check then closes the session. */
53
+ timedOut(): void;
54
+ /** This method tells the check that a frame came from the peer, for example a response or the SETTINGS of the peer. */
55
+ heard(): void;
56
+ /** This method stops the check, and the session stays. A second use does nothing. */
57
+ stop(): void;
58
+ /** This count is the streams in flight on the session. */
59
+ readonly streams: number;
60
+ /** This cause is why the check closed the session, or null while it did not. */
61
+ readonly closed: SessionClose | null;
62
+ }
63
+ /** This code is on the error that ends each stream of a session that the check closes. */
64
+ export declare const SESSION_CHECK_CLOSE = "ERR_SESSION_CHECK";
65
+ /**
66
+ * This function starts the check of one HTTP/2 session. It has two parts:
67
+ * - A stream that times out closes its session, and not only the stream. On HTTP/1.1, a request
68
+ * that times out destroys its socket. On HTTP/2, the session is the connection.
69
+ * - The heartbeat of the package sends a PING after a quiet interval. With no ACK in
70
+ * `keepalive_timeout`, it closes the session.
71
+ *
72
+ * A session that has not connected cannot answer a PING. Thus its tick waits for the SETTINGS of the
73
+ * peer through `heard()`, in `keepalive_timeout`.
74
+ */
75
+ export declare const sessionCheck: (session: H2Session, options: SessionCheckOptions) => SessionCheck;
76
+ /**
77
+ * This function gives the most time from the last frame of the peer to the close of a session by the
78
+ * PING. The first quiet tick comes up to two intervals after that frame, and its PING then waits
79
+ * `keepalive_timeout`. "infinite" is a check with no PING. Then only a stream timeout closes the session.
80
+ */
81
+ export declare const sessionCheckDetection: (knobs: SessionCheckKnobs) => Extent;
82
+ /**
83
+ * This function gives the problems of the knobs of a session check. Each knob is a time of zero or
84
+ * more. `keepalive_time` is "infinite" for no PING, and not zero. `keepalive_timeout` is a finite time
85
+ * above zero, because the check is the only bound of the PING.
86
+ */
87
+ export declare const sessionCheckProblems: (name: string, knobs: SessionCheckKnobs) => string[];
@@ -0,0 +1,99 @@
1
+ import { realClock, unrefClock } from "../clock.js";
2
+ import { ms, timeProblems, wrapperTimerProblems, zeroProblems } from "../client/core.js";
3
+ import { heartbeat } from "../heartbeat.js";
4
+ import { quantity } from "@mark1russell7/quantity";
5
+ // src/http-client/session.ts
6
+ /** This code is on the error that ends each stream of a session that the check closes. */
7
+ const SESSION_CHECK_CLOSE = "ERR_SESSION_CHECK";
8
+ /**
9
+ * This function starts the check of one HTTP/2 session. It has two parts:
10
+ * - A stream that times out closes its session, and not only the stream. On HTTP/1.1, a request
11
+ * that times out destroys its socket. On HTTP/2, the session is the connection.
12
+ * - The heartbeat of the package sends a PING after a quiet interval. With no ACK in
13
+ * `keepalive_timeout`, it closes the session.
14
+ *
15
+ * A session that has not connected cannot answer a PING. Thus its tick waits for the SETTINGS of the
16
+ * peer through `heard()`, in `keepalive_timeout`.
17
+ */
18
+ const sessionCheck = (session, options) => {
19
+ const { knobs, keepaliveWithoutCalls = false, clock = realClock } = options;
20
+ let streams = 0;
21
+ let heardSince = false;
22
+ let closed = null;
23
+ const close = (cause, why) => {
24
+ if (closed !== null) return;
25
+ closed = cause;
26
+ beat.stop();
27
+ session.destroy(Object.assign(/* @__PURE__ */ new Error(`the session check closed the session: ${why}`), { code: SESSION_CHECK_CLOSE }));
28
+ options.onClose?.(cause);
29
+ };
30
+ const beat = heartbeat({
31
+ interval: ms(knobs.keepalive_time),
32
+ timeout: ms(knobs.keepalive_timeout),
33
+ misses: 1,
34
+ clock: unrefClock(clock),
35
+ due: () => {
36
+ const quiet = !heardSince;
37
+ heardSince = false;
38
+ return closed === null && quiet && (keepaliveWithoutCalls || streams > 0);
39
+ },
40
+ ping: () => {
41
+ if (session.connecting) return void 0;
42
+ return new Promise((resolve) => {
43
+ try {
44
+ if (!session.ping((error) => resolve(error === null))) resolve(false);
45
+ } catch {
46
+ resolve(false);
47
+ }
48
+ });
49
+ },
50
+ onDead: () => close("no PING answer", "no PING ACK in keepalive_timeout")
51
+ });
52
+ return {
53
+ opened() {
54
+ streams += 1;
55
+ },
56
+ ended() {
57
+ streams = Math.max(0, streams - 1);
58
+ },
59
+ timedOut() {
60
+ streams = Math.max(0, streams - 1);
61
+ close("stream timeout", "a stream timed out");
62
+ },
63
+ heard() {
64
+ heardSince = true;
65
+ beat.answer();
66
+ },
67
+ stop() {
68
+ beat.stop();
69
+ },
70
+ get streams() {
71
+ return streams;
72
+ },
73
+ get closed() {
74
+ return closed;
75
+ }
76
+ };
77
+ };
78
+ /**
79
+ * This function gives the most time from the last frame of the peer to the close of a session by the
80
+ * PING. The first quiet tick comes up to two intervals after that frame, and its PING then waits
81
+ * `keepalive_timeout`. "infinite" is a check with no PING. Then only a stream timeout closes the session.
82
+ */
83
+ const sessionCheckDetection = (knobs) => knobs.keepalive_time.value === "infinite" ? {
84
+ value: "infinite",
85
+ unit: "s"
86
+ } : quantity((2 * ms(knobs.keepalive_time) + ms(knobs.keepalive_timeout)) / 1e3, "s");
87
+ /**
88
+ * This function gives the problems of the knobs of a session check. Each knob is a time of zero or
89
+ * more. `keepalive_time` is "infinite" for no PING, and not zero. `keepalive_timeout` is a finite time
90
+ * above zero, because the check is the only bound of the PING.
91
+ */
92
+ const sessionCheckProblems = (name, knobs) => {
93
+ const times = timeProblems(name, knobs);
94
+ if (times.length > 0) return times;
95
+ return [...zeroProblems(name, "the session check", knobs, { open: ["keepalive_time"] }), ...wrapperTimerProblems(name, knobs, { keepalive_timeout: "a PING" })];
96
+ };
97
+ export { SESSION_CHECK_CLOSE, sessionCheck, sessionCheckDetection, sessionCheckProblems };
98
+
99
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","names":[],"sources":["../../src/http-client/session.ts"],"sourcesContent":["import type { Extent, Quantity } from \"@mark1russell7/quantity\";\nimport { quantity } from \"@mark1russell7/quantity\";\nimport type { Clock } from \"../clock.ts\";\nimport { realClock, unrefClock } from \"../clock.ts\";\nimport { ms, timeProblems, wrapperTimerProblems, zeroProblems } from \"../client/core.ts\";\nimport type { Heartbeat } from \"../heartbeat.ts\";\nimport { heartbeat } from \"../heartbeat.ts\";\n\n/**\n * These are the knobs of the session check of an HTTP/2 client. They have the names and the units of\n * the gRPC client, because the check is the same PING. The grpc-js driver ends its transport at the first PING with no ACK.\n */\nexport interface SessionCheckKnobs {\n /**\n * This time is the quiet interval of a session. A tick comes at each interval, and it sends a PING\n * when the session heard nothing since the last tick. \"infinite\" sends no PING.\n */\n readonly keepalive_time: Extent;\n /** This time bounds the ACK of each PING. With no ACK in it, the check closes the session. */\n readonly keepalive_timeout: Quantity;\n}\n\n/**\n * A session is the part of an HTTP/2 session that the check uses. A `ClientHttp2Session` of\n * `node:http2` has each member, thus the check does not load `node:http2`.\n */\nexport interface H2Session {\n /** This flag is true until the socket of the session connects. */\n readonly connecting: boolean;\n /** This method sends a PING. The callback gets null at the ACK, and an error otherwise. It gives false when the PING did not go. */\n ping(callback: (error: Error | null) => void): boolean;\n /** This method ends the session and each stream on it at once. */\n destroy(error?: Error): void;\n}\n\n/** A close is the part of the check that closed the session. */\nexport type SessionClose = \"stream timeout\" | \"no PING answer\";\n\n/** These options make a session check. */\nexport interface SessionCheckOptions {\n readonly knobs: SessionCheckKnobs;\n /**\n * True lets a quiet session with no stream get a PING, as the option of the gRPC client does.\n * The default is false: a server can refuse a PING with no stream (O26).\n */\n readonly keepaliveWithoutCalls?: boolean | undefined;\n /** This clock gives the ticks and the timeouts. The default is `realClock`. */\n readonly clock?: Clock | undefined;\n /** This function receives the close of the session by the check, with its cause. */\n readonly onClose?: ((cause: SessionClose) => void) | undefined;\n}\n\n/**\n * A session check closes an HTTP/2 session that stopped answering. The caller tells it of each\n * stream and of each frame from the peer. The next stream of the caller then opens a new session.\n */\nexport interface SessionCheck {\n /** This method tells the check that a stream started on the session. */\n opened(): void;\n /** This method tells the check that a stream ended with an answer or an error. */\n ended(): void;\n /** This method tells the check that a stream ended at its timeout. The check then closes the session. */\n timedOut(): void;\n /** This method tells the check that a frame came from the peer, for example a response or the SETTINGS of the peer. */\n heard(): void;\n /** This method stops the check, and the session stays. A second use does nothing. */\n stop(): void;\n /** This count is the streams in flight on the session. */\n readonly streams: number;\n /** This cause is why the check closed the session, or null while it did not. */\n readonly closed: SessionClose | null;\n}\n\n/** This code is on the error that ends each stream of a session that the check closes. */\nexport const SESSION_CHECK_CLOSE = \"ERR_SESSION_CHECK\";\n\n/**\n * This function starts the check of one HTTP/2 session. It has two parts:\n * - A stream that times out closes its session, and not only the stream. On HTTP/1.1, a request\n * that times out destroys its socket. On HTTP/2, the session is the connection.\n * - The heartbeat of the package sends a PING after a quiet interval. With no ACK in\n * `keepalive_timeout`, it closes the session.\n *\n * A session that has not connected cannot answer a PING. Thus its tick waits for the SETTINGS of the\n * peer through `heard()`, in `keepalive_timeout`.\n */\nexport const sessionCheck = (session: H2Session, options: SessionCheckOptions): SessionCheck => {\n const { knobs, keepaliveWithoutCalls = false, clock = realClock } = options;\n let streams = 0;\n let heardSince = false;\n let closed: SessionClose | null = null;\n\n const close = (cause: SessionClose, why: string): void => {\n if (closed !== null) return;\n closed = cause;\n beat.stop();\n session.destroy(Object.assign(new Error(`the session check closed the session: ${why}`), { code: SESSION_CHECK_CLOSE }));\n options.onClose?.(cause);\n };\n\n const beat: Heartbeat = heartbeat({\n interval: ms(knobs.keepalive_time),\n timeout: ms(knobs.keepalive_timeout),\n misses: 1,\n // the session decides if it keeps the process alive: its owner can unref an idle session.\n // Thus the heartbeat does not keep the process alive (SYS-126)\n clock: unrefClock(clock),\n due: () => {\n const quiet = !heardSince;\n heardSince = false;\n return closed === null && quiet && (keepaliveWithoutCalls || streams > 0);\n },\n ping: () => {\n // the answer of a session that connects is the SETTINGS of the peer, through heard()\n if (session.connecting) return undefined;\n return new Promise<boolean>((resolve) => {\n try {\n if (!session.ping((error) => resolve(error === null))) resolve(false);\n } catch {\n resolve(false);\n }\n });\n },\n onDead: () => close(\"no PING answer\", \"no PING ACK in keepalive_timeout\"),\n });\n\n return {\n opened() {\n streams += 1;\n },\n ended() {\n streams = Math.max(0, streams - 1);\n },\n timedOut() {\n streams = Math.max(0, streams - 1);\n close(\"stream timeout\", \"a stream timed out\");\n },\n heard() {\n heardSince = true;\n beat.answer();\n },\n stop() {\n beat.stop();\n },\n get streams() {\n return streams;\n },\n get closed() {\n return closed;\n },\n };\n};\n\n/**\n * This function gives the most time from the last frame of the peer to the close of a session by the\n * PING. The first quiet tick comes up to two intervals after that frame, and its PING then waits\n * `keepalive_timeout`. \"infinite\" is a check with no PING. Then only a stream timeout closes the session.\n */\nexport const sessionCheckDetection = (knobs: SessionCheckKnobs): Extent =>\n knobs.keepalive_time.value === \"infinite\"\n ? { value: \"infinite\", unit: \"s\" }\n : quantity((2 * ms(knobs.keepalive_time) + ms(knobs.keepalive_timeout)) / 1000, \"s\");\n\n/**\n * This function gives the problems of the knobs of a session check. Each knob is a time of zero or\n * more. `keepalive_time` is \"infinite\" for no PING, and not zero. `keepalive_timeout` is a finite time\n * above zero, because the check is the only bound of the PING.\n */\nexport const sessionCheckProblems = (name: string, knobs: SessionCheckKnobs): string[] => {\n const times = timeProblems(name, knobs);\n if (times.length > 0) return times;\n return [\n ...zeroProblems(name, \"the session check\", knobs, { open: [\"keepalive_time\"] }),\n ...wrapperTimerProblems(name, knobs, { keepalive_timeout: \"a PING\" }),\n ];\n};\n"],"mappings":";;;;;;AA0EA,MAAa,sBAAsB;;;;;;;;;;;AAYnC,MAAa,gBAAgB,SAAoB,YAA+C;CAC9F,MAAM,EAAE,OAAO,wBAAwB,OAAO,QAAQ,cAAc;CACpE,IAAI,UAAU;CACd,IAAI,aAAa;CACjB,IAAI,SAA8B;CAElC,MAAM,SAAS,OAAqB,QAAsB;EACxD,IAAI,WAAW,MAAM;EACrB,SAAS;EACT,KAAK,KAAK;EACV,QAAQ,QAAQ,OAAO,uBAAO,IAAI,MAAM,yCAAyC,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC,CAAC;EACvH,QAAQ,UAAU,KAAK;CACzB;CAEA,MAAM,OAAkB,UAAU;EAChC,UAAU,GAAG,MAAM,cAAc;EACjC,SAAS,GAAG,MAAM,iBAAiB;EACnC,QAAQ;EAGR,OAAO,WAAW,KAAK;EACvB,WAAW;GACT,MAAM,QAAQ,CAAC;GACf,aAAa;GACb,OAAO,WAAW,QAAQ,UAAU,yBAAyB,UAAU;EACzE;EACA,YAAY;GAEV,IAAI,QAAQ,YAAY,OAAO,KAAA;GAC/B,OAAO,IAAI,SAAkB,YAAY;IACvC,IAAI;KACF,IAAI,CAAC,QAAQ,MAAM,UAAU,QAAQ,UAAU,IAAI,CAAC,GAAG,QAAQ,KAAK;IACtE,QAAQ;KACN,QAAQ,KAAK;IACf;GACF,CAAC;EACH;EACA,cAAc,MAAM,kBAAkB,kCAAkC;CAC1E,CAAC;CAED,OAAO;EACL,SAAS;GACP,WAAW;EACb;EACA,QAAQ;GACN,UAAU,KAAK,IAAI,GAAG,UAAU,CAAC;EACnC;EACA,WAAW;GACT,UAAU,KAAK,IAAI,GAAG,UAAU,CAAC;GACjC,MAAM,kBAAkB,oBAAoB;EAC9C;EACA,QAAQ;GACN,aAAa;GACb,KAAK,OAAO;EACd;EACA,OAAO;GACL,KAAK,KAAK;EACZ;EACA,IAAI,UAAU;GACZ,OAAO;EACT;EACA,IAAI,SAAS;GACX,OAAO;EACT;CACF;AACF;;;;;;AAOA,MAAa,yBAAyB,UACpC,MAAM,eAAe,UAAU,aAC3B;CAAE,OAAO;CAAY,MAAM;AAAI,IAC/B,UAAU,IAAI,GAAG,MAAM,cAAc,IAAI,GAAG,MAAM,iBAAiB,KAAK,KAAM,GAAG;;;;;;AAOvF,MAAa,wBAAwB,MAAc,UAAuC;CACxF,MAAM,QAAQ,aAAa,MAAM,KAAK;CACtC,IAAI,MAAM,SAAS,GAAG,OAAO;CAC7B,OAAO,CACL,GAAG,aAAa,MAAM,qBAAqB,OAAO,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,GAC9E,GAAG,qBAAqB,MAAM,OAAO,EAAE,mBAAmB,SAAS,CAAC,CACtE;AACF"}
@@ -0,0 +1,25 @@
1
+ import { Poll } from "../timing.js";
2
+ import { HttpClientKnobs } from "./client.js";
3
+ /**
4
+ * This poll is the poll of the checks that `HTTP_CLIENT_STARTING_KNOBS` fits. It is `STARTING_POLL` of
5
+ * the core: each 5 s with a jitter of 20 %, and a timeout of 4 s (B6, O12). The poll does not depend on the driver.
6
+ */
7
+ export declare const HTTP_CLIENT_STARTING_POLL: Poll;
8
+ /**
9
+ * These knobs are a declaration to start from. They come from what the HTTP cells measured on the
10
+ * agent of Node 24.21.0 against a Node server at its defaults. The runtime has no defaults: a service gives
11
+ * these knobs, or its own. Each value holds the borders that the cells measured:
12
+ * - `connect_bound` 5 s: the connect timeout of DP44. The agent has no connect timer.
13
+ * - `request_timeout` 9.5 s: in the slowest poll of 10 s (O13). The agent has no timer of a call.
14
+ * A frozen server held the call of undici until its headersTimeout, at 10.187 s.
15
+ * - `pool_idle_expiry` 4 s: the free socket timer. The agent then closes a free socket at 4 s, the
16
+ * hint of 5 s less `hint_buffer`. That is below the idle close of the server.
17
+ * - `hint_buffer` 1 s: the default of the agent.
18
+ * - `server_idle_close` 6 s: a Node server closes an idle connection at its `keepAliveTimeout` of 5 s
19
+ * plus its buffer of 1 s. The cells measured 6.0003 s. O01 then has a margin of 2 s.
20
+ * - `keepalive_idle` 1 s: the default of the agent. Node truncates it to whole seconds.
21
+ * - `max_connection_age` "infinite": the agent does not replace a connection at an age.
22
+ * - `close_bound` 2 s: a call in flight behind a black hole holds its socket with no bound.
23
+ * - `retrans_giveup_time` 924.6 s: the give-up of Linux at `tcp_retries2 = 15`.
24
+ */
25
+ export declare const HTTP_CLIENT_STARTING_KNOBS: HttpClientKnobs;
@@ -0,0 +1,65 @@
1
+ import { STARTING_POLL } from "../client/core.js";
2
+ // src/http-client/starting.ts
3
+ /**
4
+ * This poll is the poll of the checks that `HTTP_CLIENT_STARTING_KNOBS` fits. It is `STARTING_POLL` of
5
+ * the core: each 5 s with a jitter of 20 %, and a timeout of 4 s (B6, O12). The poll does not depend on the driver.
6
+ */
7
+ const HTTP_CLIENT_STARTING_POLL = STARTING_POLL;
8
+ /**
9
+ * These knobs are a declaration to start from. They come from what the HTTP cells measured on the
10
+ * agent of Node 24.21.0 against a Node server at its defaults. The runtime has no defaults: a service gives
11
+ * these knobs, or its own. Each value holds the borders that the cells measured:
12
+ * - `connect_bound` 5 s: the connect timeout of DP44. The agent has no connect timer.
13
+ * - `request_timeout` 9.5 s: in the slowest poll of 10 s (O13). The agent has no timer of a call.
14
+ * A frozen server held the call of undici until its headersTimeout, at 10.187 s.
15
+ * - `pool_idle_expiry` 4 s: the free socket timer. The agent then closes a free socket at 4 s, the
16
+ * hint of 5 s less `hint_buffer`. That is below the idle close of the server.
17
+ * - `hint_buffer` 1 s: the default of the agent.
18
+ * - `server_idle_close` 6 s: a Node server closes an idle connection at its `keepAliveTimeout` of 5 s
19
+ * plus its buffer of 1 s. The cells measured 6.0003 s. O01 then has a margin of 2 s.
20
+ * - `keepalive_idle` 1 s: the default of the agent. Node truncates it to whole seconds.
21
+ * - `max_connection_age` "infinite": the agent does not replace a connection at an age.
22
+ * - `close_bound` 2 s: a call in flight behind a black hole holds its socket with no bound.
23
+ * - `retrans_giveup_time` 924.6 s: the give-up of Linux at `tcp_retries2 = 15`.
24
+ */
25
+ const HTTP_CLIENT_STARTING_KNOBS = {
26
+ connect_bound: {
27
+ value: 5,
28
+ unit: "s"
29
+ },
30
+ request_timeout: {
31
+ value: 9.5,
32
+ unit: "s"
33
+ },
34
+ pool_idle_expiry: {
35
+ value: 4,
36
+ unit: "s"
37
+ },
38
+ hint_buffer: {
39
+ value: 1,
40
+ unit: "s"
41
+ },
42
+ server_idle_close: {
43
+ value: 6,
44
+ unit: "s"
45
+ },
46
+ keepalive_idle: {
47
+ value: 1,
48
+ unit: "s"
49
+ },
50
+ max_connection_age: {
51
+ value: "infinite",
52
+ unit: "s"
53
+ },
54
+ close_bound: {
55
+ value: 2,
56
+ unit: "s"
57
+ },
58
+ retrans_giveup_time: {
59
+ value: 924.6,
60
+ unit: "s"
61
+ }
62
+ };
63
+ export { HTTP_CLIENT_STARTING_KNOBS, HTTP_CLIENT_STARTING_POLL };
64
+
65
+ //# sourceMappingURL=starting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"starting.js","names":[],"sources":["../../src/http-client/starting.ts"],"sourcesContent":["import { STARTING_POLL } from \"../client/core.ts\";\nimport type { Poll } from \"../timing.ts\";\nimport type { HttpClientKnobs } from \"./client.ts\";\n\n/**\n * This poll is the poll of the checks that `HTTP_CLIENT_STARTING_KNOBS` fits. It is `STARTING_POLL` of\n * the core: each 5 s with a jitter of 20 %, and a timeout of 4 s (B6, O12). The poll does not depend on the driver.\n */\nexport const HTTP_CLIENT_STARTING_POLL: Poll = STARTING_POLL;\n\n/**\n * These knobs are a declaration to start from. They come from what the HTTP cells measured on the\n * agent of Node 24.21.0 against a Node server at its defaults. The runtime has no defaults: a service gives\n * these knobs, or its own. Each value holds the borders that the cells measured:\n * - `connect_bound` 5 s: the connect timeout of DP44. The agent has no connect timer.\n * - `request_timeout` 9.5 s: in the slowest poll of 10 s (O13). The agent has no timer of a call.\n * A frozen server held the call of undici until its headersTimeout, at 10.187 s.\n * - `pool_idle_expiry` 4 s: the free socket timer. The agent then closes a free socket at 4 s, the\n * hint of 5 s less `hint_buffer`. That is below the idle close of the server.\n * - `hint_buffer` 1 s: the default of the agent.\n * - `server_idle_close` 6 s: a Node server closes an idle connection at its `keepAliveTimeout` of 5 s\n * plus its buffer of 1 s. The cells measured 6.0003 s. O01 then has a margin of 2 s.\n * - `keepalive_idle` 1 s: the default of the agent. Node truncates it to whole seconds.\n * - `max_connection_age` \"infinite\": the agent does not replace a connection at an age.\n * - `close_bound` 2 s: a call in flight behind a black hole holds its socket with no bound.\n * - `retrans_giveup_time` 924.6 s: the give-up of Linux at `tcp_retries2 = 15`.\n */\nexport const HTTP_CLIENT_STARTING_KNOBS: HttpClientKnobs = {\n connect_bound: { value: 5, unit: \"s\" },\n request_timeout: { value: 9.5, unit: \"s\" },\n pool_idle_expiry: { value: 4, unit: \"s\" },\n hint_buffer: { value: 1, unit: \"s\" },\n server_idle_close: { value: 6, unit: \"s\" },\n keepalive_idle: { value: 1, unit: \"s\" },\n max_connection_age: { value: \"infinite\", unit: \"s\" },\n close_bound: { value: 2, unit: \"s\" },\n retrans_giveup_time: { value: 924.6, unit: \"s\" },\n};\n"],"mappings":";;;;;;AAQA,MAAa,4BAAkC;;;;;;;;;;;;;;;;;;AAmB/C,MAAa,6BAA8C;CACzD,eAAe;EAAE,OAAO;EAAG,MAAM;CAAI;CACrC,iBAAiB;EAAE,OAAO;EAAK,MAAM;CAAI;CACzC,kBAAkB;EAAE,OAAO;EAAG,MAAM;CAAI;CACxC,aAAa;EAAE,OAAO;EAAG,MAAM;CAAI;CACnC,mBAAmB;EAAE,OAAO;EAAG,MAAM;CAAI;CACzC,gBAAgB;EAAE,OAAO;EAAG,MAAM;CAAI;CACtC,oBAAoB;EAAE,OAAO;EAAY,MAAM;CAAI;CACnD,aAAa;EAAE,OAAO;EAAG,MAAM;CAAI;CACnC,qBAAqB;EAAE,OAAO;EAAO,MAAM;CAAI;AACjD"}