@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,112 @@
1
+ import { Factory } from "../client/core.js";
2
+ /** A document is a BSON document as the driver gives it: a command, or the reply of the server. */
3
+ export type MongoDocument = Record<string, unknown>;
4
+ /** A database is the part of a `Db` of the driver that the wrapper uses: `command` sends one command. */
5
+ export interface MongoDb {
6
+ /** This method sends a command. Its signal ends the command, and an abort during the read closes the connection. */
7
+ command(document: MongoDocument, options?: {
8
+ readonly signal?: AbortSignal | undefined;
9
+ }): Promise<MongoDocument>;
10
+ }
11
+ /** A server is the part of a `ServerDescription` that the wrapper reads: its type, for example `RSPrimary`. */
12
+ export interface MongoServer {
13
+ readonly type: string;
14
+ }
15
+ /** These are the events of the driver that the wrapper listens to, by name, with the fields that it reads. */
16
+ export interface MongoEvents {
17
+ /** The view of the topology changed. A writable server is a primary, a standalone, a mongos or a load balancer. */
18
+ topologyDescriptionChanged: {
19
+ readonly newDescription: {
20
+ readonly servers: ReadonlyMap<string, MongoServer>;
21
+ };
22
+ };
23
+ /** A connection of the pool finished its handshake. `connectionId` is the id that the pool gives. */
24
+ connectionReady: {
25
+ readonly connectionId: number | string;
26
+ readonly address: string;
27
+ };
28
+ /** A command went to a connection. `serverConnectionId` is the id that the server gave in its hello. */
29
+ commandStarted: {
30
+ readonly connectionId?: number | string | undefined;
31
+ readonly address: string;
32
+ readonly serverConnectionId?: bigint | number | null | undefined;
33
+ };
34
+ /** The pool of a server closed its connections, for example at the write-off of the server. */
35
+ connectionPoolCleared: {
36
+ readonly address: string;
37
+ readonly interruptInUseConnections?: boolean | undefined;
38
+ };
39
+ /** A hello of the monitor failed. `connectionId` is the address of the server. */
40
+ serverHeartbeatFailed: {
41
+ readonly connectionId: string;
42
+ readonly failure: Error;
43
+ };
44
+ /** An error of the topology. In Node, an error with no listener throws. */
45
+ error: Error;
46
+ }
47
+ /** An event name is a name of `MongoEvents`. */
48
+ export type MongoEventName = keyof MongoEvents;
49
+ /**
50
+ * A driver client is the part of a `MongoClient` that the wrapper uses. A `MongoClient` of the
51
+ * driver 7 has each part. A fake for tests has them too. Thus the package depends on no type of the driver.
52
+ */
53
+ export interface MongoDriverClient {
54
+ /** This method opens the topology and waits for a server to select. A failure closes the topology, and a later command opens it again. */
55
+ connect(): Promise<unknown>;
56
+ /** This method fails the commands in flight, sends `endSessions` to a selectable server, and closes the topology. */
57
+ close(): Promise<void>;
58
+ db(name: string): MongoDb;
59
+ on<E extends MongoEventName>(event: E, listener: (payload: MongoEvents[E]) => void): unknown;
60
+ off<E extends MongoEventName>(event: E, listener: (payload: MongoEvents[E]) => void): unknown;
61
+ }
62
+ /**
63
+ * These are the options that the wrapper gives `MongoClient`. Each one comes from the declaration.
64
+ * The wrapper sets each option that has an effect on a timer, thus no default of the driver decides
65
+ * one. A knob of the driver at 0 has no timer. The wrapper writes "infinite" as 0, and it refuses a bound of 0.
66
+ */
67
+ export interface MongoDriverOptions {
68
+ /** The server shows this name in `$currentOp` and in its log, thus the prober can join on it too. */
69
+ readonly appName: string;
70
+ readonly replicaSet?: string | undefined;
71
+ readonly auth?: {
72
+ readonly username: string;
73
+ readonly password: string;
74
+ } | undefined;
75
+ readonly authSource?: string | undefined;
76
+ readonly maxPoolSize: number;
77
+ readonly minPoolSize: number;
78
+ /** This time bounds the TCP connect and the handshake of each connection, and of the monitor. */
79
+ readonly connectTimeoutMS: number;
80
+ /** This time bounds a read on a connection that has a command in flight. At its end, the driver closes the connection. */
81
+ readonly socketTimeoutMS: number;
82
+ /** This time bounds the wait for a server to select, for each command and for `connect`. */
83
+ readonly serverSelectionTimeoutMS: number;
84
+ /** This time is the period of the monitor, and the wait of its streaming hello. */
85
+ readonly heartbeatFrequencyMS: number;
86
+ /** This time bounds a checkout from a full pool. 0 is no bound. */
87
+ readonly waitQueueTimeoutMS: number;
88
+ /** A checkout ends an idle connection older than this time. 0 is no limit. The driver has no timer for it. */
89
+ readonly maxIdleTimeMS: number;
90
+ /** This time is the idle time of TCP keepalive. The driver always turns keepalive on. Node truncates the time to whole seconds. */
91
+ readonly keepAliveInitialDelay: number;
92
+ /** The monitor streams its hello, as in the cells. Thus a silent server is written off at `connectTimeoutMS + heartbeatFrequencyMS`. */
93
+ readonly serverMonitoringMode: "stream";
94
+ /** The driver does not send a command again by itself. The core sends again only an idempotent operation. */
95
+ readonly retryReads: false;
96
+ readonly retryWrites: false;
97
+ /** The driver emits `commandStarted`, which gives the id of the server for each connection (D1). */
98
+ readonly monitorCommands: true;
99
+ }
100
+ /** These are the arguments of `new MongoClient(url, options)`. The URL gives only the hosts. */
101
+ export interface MongoConnectOptions {
102
+ readonly url: string;
103
+ readonly options: MongoDriverOptions;
104
+ }
105
+ /** A driver factory makes the client of the driver from its options. */
106
+ export type MongoFactory = Factory<MongoConnectOptions, MongoDriverClient>;
107
+ /**
108
+ * This factory makes a `MongoClient`. It loads the driver only when a client connects, thus a
109
+ * service that does not use MongoDB does not need it. The specifier is a value, thus the package
110
+ * needs no types of the driver. The driver gives `MongoClient` as a named export.
111
+ */
112
+ export declare const nodeMongo: MongoFactory;
@@ -0,0 +1,12 @@
1
+ // src/mongodb/connection.ts
2
+ /**
3
+ * This factory makes a `MongoClient`. It loads the driver only when a client connects, thus a
4
+ * service that does not use MongoDB does not need it. The specifier is a value, thus the package
5
+ * needs no types of the driver. The driver gives `MongoClient` as a named export.
6
+ */
7
+ const nodeMongo = async ({ url, options }) => {
8
+ return new (await (import("mongodb"))).MongoClient(url, options);
9
+ };
10
+ export { nodeMongo };
11
+
12
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","names":[],"sources":["../../src/mongodb/connection.ts"],"sourcesContent":["import type { Factory } from \"../client/core.ts\";\n\n/** A document is a BSON document as the driver gives it: a command, or the reply of the server. */\nexport type MongoDocument = Record<string, unknown>;\n\n/** A database is the part of a `Db` of the driver that the wrapper uses: `command` sends one command. */\nexport interface MongoDb {\n /** This method sends a command. Its signal ends the command, and an abort during the read closes the connection. */\n command(document: MongoDocument, options?: { readonly signal?: AbortSignal | undefined }): Promise<MongoDocument>;\n}\n\n/** A server is the part of a `ServerDescription` that the wrapper reads: its type, for example `RSPrimary`. */\nexport interface MongoServer {\n readonly type: string;\n}\n\n/** These are the events of the driver that the wrapper listens to, by name, with the fields that it reads. */\nexport interface MongoEvents {\n /** The view of the topology changed. A writable server is a primary, a standalone, a mongos or a load balancer. */\n topologyDescriptionChanged: { readonly newDescription: { readonly servers: ReadonlyMap<string, MongoServer> } };\n /** A connection of the pool finished its handshake. `connectionId` is the id that the pool gives. */\n connectionReady: { readonly connectionId: number | string; readonly address: string };\n /** A command went to a connection. `serverConnectionId` is the id that the server gave in its hello. */\n commandStarted: {\n readonly connectionId?: number | string | undefined;\n readonly address: string;\n readonly serverConnectionId?: bigint | number | null | undefined;\n };\n /** The pool of a server closed its connections, for example at the write-off of the server. */\n connectionPoolCleared: { readonly address: string; readonly interruptInUseConnections?: boolean | undefined };\n /** A hello of the monitor failed. `connectionId` is the address of the server. */\n serverHeartbeatFailed: { readonly connectionId: string; readonly failure: Error };\n /** An error of the topology. In Node, an error with no listener throws. */\n error: Error;\n}\n\n/** An event name is a name of `MongoEvents`. */\nexport type MongoEventName = keyof MongoEvents;\n\n/**\n * A driver client is the part of a `MongoClient` that the wrapper uses. A `MongoClient` of the\n * driver 7 has each part. A fake for tests has them too. Thus the package depends on no type of the driver.\n */\nexport interface MongoDriverClient {\n /** This method opens the topology and waits for a server to select. A failure closes the topology, and a later command opens it again. */\n connect(): Promise<unknown>;\n /** This method fails the commands in flight, sends `endSessions` to a selectable server, and closes the topology. */\n close(): Promise<void>;\n db(name: string): MongoDb;\n on<E extends MongoEventName>(event: E, listener: (payload: MongoEvents[E]) => void): unknown;\n off<E extends MongoEventName>(event: E, listener: (payload: MongoEvents[E]) => void): unknown;\n}\n\n/**\n * These are the options that the wrapper gives `MongoClient`. Each one comes from the declaration.\n * The wrapper sets each option that has an effect on a timer, thus no default of the driver decides\n * one. A knob of the driver at 0 has no timer. The wrapper writes \"infinite\" as 0, and it refuses a bound of 0.\n */\nexport interface MongoDriverOptions {\n /** The server shows this name in `$currentOp` and in its log, thus the prober can join on it too. */\n readonly appName: string;\n readonly replicaSet?: string | undefined;\n readonly auth?: { readonly username: string; readonly password: string } | undefined;\n readonly authSource?: string | undefined;\n readonly maxPoolSize: number;\n readonly minPoolSize: number;\n /** This time bounds the TCP connect and the handshake of each connection, and of the monitor. */\n readonly connectTimeoutMS: number;\n /** This time bounds a read on a connection that has a command in flight. At its end, the driver closes the connection. */\n readonly socketTimeoutMS: number;\n /** This time bounds the wait for a server to select, for each command and for `connect`. */\n readonly serverSelectionTimeoutMS: number;\n /** This time is the period of the monitor, and the wait of its streaming hello. */\n readonly heartbeatFrequencyMS: number;\n /** This time bounds a checkout from a full pool. 0 is no bound. */\n readonly waitQueueTimeoutMS: number;\n /** A checkout ends an idle connection older than this time. 0 is no limit. The driver has no timer for it. */\n readonly maxIdleTimeMS: number;\n /** This time is the idle time of TCP keepalive. The driver always turns keepalive on. Node truncates the time to whole seconds. */\n readonly keepAliveInitialDelay: number;\n /** The monitor streams its hello, as in the cells. Thus a silent server is written off at `connectTimeoutMS + heartbeatFrequencyMS`. */\n readonly serverMonitoringMode: \"stream\";\n /** The driver does not send a command again by itself. The core sends again only an idempotent operation. */\n readonly retryReads: false;\n readonly retryWrites: false;\n /** The driver emits `commandStarted`, which gives the id of the server for each connection (D1). */\n readonly monitorCommands: true;\n}\n\n/** These are the arguments of `new MongoClient(url, options)`. The URL gives only the hosts. */\nexport interface MongoConnectOptions {\n readonly url: string;\n readonly options: MongoDriverOptions;\n}\n\n/** A driver factory makes the client of the driver from its options. */\nexport type MongoFactory = Factory<MongoConnectOptions, MongoDriverClient>;\n\n/**\n * This factory makes a `MongoClient`. It loads the driver only when a client connects, thus a\n * service that does not use MongoDB does not need it. The specifier is a value, thus the package\n * needs no types of the driver. The driver gives `MongoClient` as a named export.\n */\nexport const nodeMongo: MongoFactory = async ({ url, options }) => {\n const specifier = \"mongodb\";\n const loaded = (await import(specifier)) as {\n readonly MongoClient: new (url: string, options: MongoDriverOptions) => MongoDriverClient;\n };\n return new loaded.MongoClient(url, options);\n};\n"],"mappings":";;;;;;AAuGA,MAAa,YAA0B,OAAO,EAAE,KAAK,cAAc;CAKjE,OAAO,KAAI,OAHW,OAAO,YAAA,CAGX,YAAY,KAAK,OAAO;AAC5C"}
@@ -0,0 +1,14 @@
1
+ import { Machine } from "@mark1russell7/algebra";
2
+ /**
3
+ * The MongoDB client of the service as a `mark1russell7.machine/1` document. It is the topology as
4
+ * the wrapper sees it, not one connection: the document `mongodb-node` of `@mark1russell7/machines`
5
+ * gives the monitor and each connection. The state is the view of the topology:
6
+ * - `ready`: a server is writable: a primary, a standalone, a mongos, or a load balancer.
7
+ * - `failing`: no server is writable, or the startup found none in `connect_bound`. The monitor
8
+ * goes on, and a command waits for a writable server in `client_retry_window`.
9
+ *
10
+ * A connection that closes and a pool that the driver clears do not change the state by themselves.
11
+ * The write-off of a server changes the view of the topology, and that changes the state. A test
12
+ * records the transitions of the client and replays them against this document.
13
+ */
14
+ export declare const MONGO_CLIENT_MACHINE: Machine;
@@ -0,0 +1,122 @@
1
+ import { clientKnob, closeTimer, transition } from "../client/machine.js";
2
+ // src/mongodb/machine.ts
3
+ /** The states where the driver exists and serves. */
4
+ const SERVING = [
5
+ "connecting",
6
+ "ready",
7
+ "failing"
8
+ ];
9
+ const OPEN = [...SERVING, "closing"];
10
+ /**
11
+ * The MongoDB client of the service as a `mark1russell7.machine/1` document. It is the topology as
12
+ * the wrapper sees it, not one connection: the document `mongodb-node` of `@mark1russell7/machines`
13
+ * gives the monitor and each connection. The state is the view of the topology:
14
+ * - `ready`: a server is writable: a primary, a standalone, a mongos, or a load balancer.
15
+ * - `failing`: no server is writable, or the startup found none in `connect_bound`. The monitor
16
+ * goes on, and a command waits for a writable server in `client_retry_window`.
17
+ *
18
+ * A connection that closes and a pool that the driver clears do not change the state by themselves.
19
+ * The write-off of a server changes the view of the topology, and that changes the state. A test
20
+ * records the transitions of the client and replays them against this document.
21
+ */
22
+ const MONGO_CLIENT_MACHINE = {
23
+ format: "mark1russell7.machine/1",
24
+ id: "service.machine.mongodb-client",
25
+ title: "The MongoDB client of the service, over a MongoClient of the driver 7",
26
+ layer: "driver",
27
+ version: "0.1.0",
28
+ sources: [{
29
+ ref: "packages/service/src/mongodb (the client implements this document)",
30
+ rung: "implemented"
31
+ }],
32
+ states: {
33
+ none: {
34
+ initial: true,
35
+ note: "the client exists, and its MongoClient does not"
36
+ },
37
+ connecting: { note: "the monitor looks for the servers of the topology" },
38
+ ready: { note: "a server is writable. A dead idle connection stays hidden until the monitor writes the server off" },
39
+ failing: { note: "no server is writable. A command waits for one in client_retry_window" },
40
+ closing: { note: "the close of the driver: it fails the commands in flight, sends endSessions, and closes the topology" },
41
+ end: {
42
+ final: true,
43
+ note: "the service closed the client"
44
+ }
45
+ },
46
+ events: {
47
+ "status.connecting": { kind: "local" },
48
+ "topology.writable": {
49
+ kind: "rx",
50
+ note: "the view of the topology has a writable server"
51
+ },
52
+ "topology.unwritable": {
53
+ kind: "rx",
54
+ note: "the view of the topology has no writable server, for example after a write-off or a step down"
55
+ },
56
+ join: {
57
+ kind: "rx",
58
+ note: "a connection of the pool finished its handshake (D1). The id of the server comes with its first command"
59
+ },
60
+ "connect.failed": {
61
+ kind: "local",
62
+ note: "the startup found no writable server in connect_bound, or the connect of the driver failed"
63
+ },
64
+ "pool.cleared": {
65
+ kind: "rx",
66
+ note: "the driver cleared the pool of a server, and with a write-off also failed its commands in flight"
67
+ },
68
+ "heartbeat.failed": {
69
+ kind: "rx",
70
+ note: "a hello of the monitor failed"
71
+ },
72
+ "client.error": {
73
+ kind: "rx",
74
+ note: "an error event of the driver"
75
+ },
76
+ "command.reissue": { kind: "local" },
77
+ "close.request": { kind: "local" },
78
+ "close.bound": {
79
+ kind: "timer",
80
+ note: "the close of the driver goes on after the bound, in the background"
81
+ },
82
+ "close.destroy": {
83
+ kind: "local",
84
+ note: "the client never records it: the driver gives no socket that the bound can destroy"
85
+ },
86
+ "status.end": { kind: "local" }
87
+ },
88
+ knobs: {
89
+ connect_bound: clientKnob("connectTimeoutMS"),
90
+ close_bound: clientKnob("close.bound")
91
+ },
92
+ timers: {
93
+ connect_timeout: {
94
+ duration: {
95
+ knob: "connect_bound",
96
+ unit: "s"
97
+ },
98
+ arms: ["enter:connecting"],
99
+ cancels: ["topology.writable", "connect.failed"],
100
+ fires: "connect.failed",
101
+ note: "the startup stops its wait, and the connect of the driver goes on in client_retry_window"
102
+ },
103
+ close: closeTimer()
104
+ },
105
+ transitions: [
106
+ transition("connect", "none", "status.connecting", "connecting"),
107
+ transition("writable", ["connecting", "failing"], "topology.writable", "ready"),
108
+ transition("unwritable", "ready", "topology.unwritable", "failing"),
109
+ transition("connect-failed", ["connecting", "failing"], "connect.failed", "failing", { timer: "connect_timeout" }),
110
+ ...OPEN.map((state) => transition(`join-${state}`, state, "join", state)),
111
+ ...OPEN.map((state) => transition(`pool-cleared-${state}`, state, "pool.cleared", state)),
112
+ ...OPEN.map((state) => transition(`heartbeat-failed-${state}`, state, "heartbeat.failed", state)),
113
+ ...OPEN.map((state) => transition(`client-error-${state}`, state, "client.error", state)),
114
+ ...OPEN.map((state) => transition(`reissue-${state}`, state, "command.reissue", state)),
115
+ transition("close", [...SERVING], "close.request", "closing"),
116
+ transition("close-bound", "closing", "close.bound", "closing", { timer: "close" }),
117
+ transition("end", "closing", "status.end", "end")
118
+ ]
119
+ };
120
+ export { MONGO_CLIENT_MACHINE };
121
+
122
+ //# sourceMappingURL=machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"machine.js","names":["knob","t"],"sources":["../../src/mongodb/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 driver exists and serves. */\nconst SERVING = [\"connecting\", \"ready\", \"failing\"] as const;\nconst OPEN = [...SERVING, \"closing\"] as const;\n\n/**\n * The MongoDB client of the service as a `mark1russell7.machine/1` document. It is the topology as\n * the wrapper sees it, not one connection: the document `mongodb-node` of `@mark1russell7/machines`\n * gives the monitor and each connection. The state is the view of the topology:\n * - `ready`: a server is writable: a primary, a standalone, a mongos, or a load balancer.\n * - `failing`: no server is writable, or the startup found none in `connect_bound`. The monitor\n * goes on, and a command waits for a writable server in `client_retry_window`.\n *\n * A connection that closes and a pool that the driver clears do not change the state by themselves.\n * The write-off of a server changes the view of the topology, and that changes the state. A test\n * records the transitions of the client and replays them against this document.\n */\nexport const MONGO_CLIENT_MACHINE: Machine = {\n format: \"mark1russell7.machine/1\",\n id: \"service.machine.mongodb-client\",\n title: \"The MongoDB client of the service, over a MongoClient of the driver 7\",\n layer: \"driver\",\n version: \"0.1.0\",\n sources: [{ ref: \"packages/service/src/mongodb (the client implements this document)\", rung: \"implemented\" }],\n states: {\n none: { initial: true, note: \"the client exists, and its MongoClient does not\" },\n connecting: { note: \"the monitor looks for the servers of the topology\" },\n ready: { note: \"a server is writable. A dead idle connection stays hidden until the monitor writes the server off\" },\n failing: { note: \"no server is writable. A command waits for one in client_retry_window\" },\n closing: { note: \"the close of the driver: it fails the commands in flight, sends endSessions, and closes the topology\" },\n end: { final: true, note: \"the service closed the client\" },\n },\n events: {\n \"status.connecting\": { kind: \"local\" },\n \"topology.writable\": { kind: \"rx\", note: \"the view of the topology has a writable server\" },\n \"topology.unwritable\": { kind: \"rx\", note: \"the view of the topology has no writable server, for example after a write-off or a step down\" },\n join: { kind: \"rx\", note: \"a connection of the pool finished its handshake (D1). The id of the server comes with its first command\" },\n \"connect.failed\": { kind: \"local\", note: \"the startup found no writable server in connect_bound, or the connect of the driver failed\" },\n \"pool.cleared\": { kind: \"rx\", note: \"the driver cleared the pool of a server, and with a write-off also failed its commands in flight\" },\n \"heartbeat.failed\": { kind: \"rx\", note: \"a hello of the monitor failed\" },\n \"client.error\": { kind: \"rx\", note: \"an error event of the driver\" },\n \"command.reissue\": { kind: \"local\" },\n \"close.request\": { kind: \"local\" },\n \"close.bound\": { kind: \"timer\", note: \"the close of the driver goes on after the bound, in the background\" },\n \"close.destroy\": { kind: \"local\", note: \"the client never records it: the driver gives no socket that the bound can destroy\" },\n \"status.end\": { kind: \"local\" },\n },\n knobs: {\n connect_bound: knob(\"connectTimeoutMS\"),\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: [\"topology.writable\", \"connect.failed\"],\n fires: \"connect.failed\",\n note: \"the startup stops its wait, and the connect of the driver goes on in client_retry_window\",\n },\n close: closeTimer(),\n },\n transitions: [\n t(\"connect\", \"none\", \"status.connecting\", \"connecting\"),\n t(\"writable\", [\"connecting\", \"failing\"], \"topology.writable\", \"ready\"),\n t(\"unwritable\", \"ready\", \"topology.unwritable\", \"failing\"),\n t(\"connect-failed\", [\"connecting\", \"failing\"], \"connect.failed\", \"failing\", { timer: \"connect_timeout\" }),\n ...OPEN.map((state) => t(`join-${state}`, state, \"join\", state)),\n ...OPEN.map((state) => t(`pool-cleared-${state}`, state, \"pool.cleared\", state)),\n ...OPEN.map((state) => t(`heartbeat-failed-${state}`, state, \"heartbeat.failed\", state)),\n ...OPEN.map((state) => t(`client-error-${state}`, state, \"client.error\", 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(\"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,uBAAgC;CAC3C,QAAQ;CACR,IAAI;CACJ,OAAO;CACP,OAAO;CACP,SAAS;CACT,SAAS,CAAC;EAAE,KAAK;EAAsE,MAAM;CAAc,CAAC;CAC5G,QAAQ;EACN,MAAM;GAAE,SAAS;GAAM,MAAM;EAAkD;EAC/E,YAAY,EAAE,MAAM,oDAAoD;EACxE,OAAO,EAAE,MAAM,oGAAoG;EACnH,SAAS,EAAE,MAAM,wEAAwE;EACzF,SAAS,EAAE,MAAM,uGAAuG;EACxH,KAAK;GAAE,OAAO;GAAM,MAAM;EAAgC;CAC5D;CACA,QAAQ;EACN,qBAAqB,EAAE,MAAM,QAAQ;EACrC,qBAAqB;GAAE,MAAM;GAAM,MAAM;EAAiD;EAC1F,uBAAuB;GAAE,MAAM;GAAM,MAAM;EAAgG;EAC3I,MAAM;GAAE,MAAM;GAAM,MAAM;EAA0G;EACpI,kBAAkB;GAAE,MAAM;GAAS,MAAM;EAA6F;EACtI,gBAAgB;GAAE,MAAM;GAAM,MAAM;EAAmG;EACvI,oBAAoB;GAAE,MAAM;GAAM,MAAM;EAAgC;EACxE,gBAAgB;GAAE,MAAM;GAAM,MAAM;EAA+B;EACnE,mBAAmB,EAAE,MAAM,QAAQ;EACnC,iBAAiB,EAAE,MAAM,QAAQ;EACjC,eAAe;GAAE,MAAM;GAAS,MAAM;EAAqE;EAC3G,iBAAiB;GAAE,MAAM;GAAS,MAAM;EAAqF;EAC7H,cAAc,EAAE,MAAM,QAAQ;CAChC;CACA,OAAO;EACL,eAAeA,WAAK,kBAAkB;EACtC,aAAaA,WAAK,aAAa;CACjC;CACA,QAAQ;EACN,iBAAiB;GACf,UAAU;IAAE,MAAM;IAAiB,MAAM;GAAI;GAC7C,MAAM,CAAC,kBAAkB;GACzB,SAAS,CAAC,qBAAqB,gBAAgB;GAC/C,OAAO;GACP,MAAM;EACR;EACA,OAAO,WAAW;CACpB;CACA,aAAa;EACXC,WAAE,WAAW,QAAQ,qBAAqB,YAAY;EACtDA,WAAE,YAAY,CAAC,cAAc,SAAS,GAAG,qBAAqB,OAAO;EACrEA,WAAE,cAAc,SAAS,uBAAuB,SAAS;EACzDA,WAAE,kBAAkB,CAAC,cAAc,SAAS,GAAG,kBAAkB,WAAW,EAAE,OAAO,kBAAkB,CAAC;EACxG,GAAG,KAAK,KAAK,UAAUA,WAAE,QAAQ,SAAS,OAAO,QAAQ,KAAK,CAAC;EAC/D,GAAG,KAAK,KAAK,UAAUA,WAAE,gBAAgB,SAAS,OAAO,gBAAgB,KAAK,CAAC;EAC/E,GAAG,KAAK,KAAK,UAAUA,WAAE,oBAAoB,SAAS,OAAO,oBAAoB,KAAK,CAAC;EACvF,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,OAAO,WAAW,cAAc,KAAK;CACzC;AACF"}
@@ -0,0 +1,15 @@
1
+ import { Meeting } from "../client/meets.js";
2
+ import { MongoKnobs } from "./client.js";
3
+ /**
4
+ * This function gives the manifestations that a MongoDB client can meet, and the detectors of each,
5
+ * from its knobs. The cells of S1 measured them on the driver 7.7.0 against mongod 9.0.4:
6
+ * - The monitor writes off a silent server at `connectTimeoutMS + heartbeatFrequencyMS` after its last
7
+ * answer: 40.002 s at the defaults, and 7 s for 5 s + 2 s. The driver then clears the pool, and
8
+ * fails each command in flight. With `connectTimeoutMS` 0, nothing found a freeze in 60 s.
9
+ * - At `tcp_retries2 = 5`, the kernel gave up at 12.936 s.
10
+ * - A `keepAliveInitialDelay` of 27 s ended an idle stream at 37.255 s.
11
+ *
12
+ * The monitor tests the server, not each connection of the pool. Thus a write-off finds a failure of
13
+ * the server in flight and idle, and a failure of one connection waits for its own detector.
14
+ */
15
+ export declare const mongoMeetings: (name: string, knobs: MongoKnobs) => Meeting[];
@@ -0,0 +1,103 @@
1
+ import { WHAT, immediate, keepaliveAnswered, keepaliveReset, keepaliveSilent, kernelGiveUp } from "../client/meets.js";
2
+ import { ms } from "../client/core.js";
3
+ import { quantity } from "@mark1russell7/quantity";
4
+ // src/mongodb/meets.ts
5
+ /**
6
+ * This function gives the manifestations that a MongoDB client can meet, and the detectors of each,
7
+ * from its knobs. The cells of S1 measured them on the driver 7.7.0 against mongod 9.0.4:
8
+ * - The monitor writes off a silent server at `connectTimeoutMS + heartbeatFrequencyMS` after its last
9
+ * answer: 40.002 s at the defaults, and 7 s for 5 s + 2 s. The driver then clears the pool, and
10
+ * fails each command in flight. With `connectTimeoutMS` 0, nothing found a freeze in 60 s.
11
+ * - At `tcp_retries2 = 5`, the kernel gave up at 12.936 s.
12
+ * - A `keepAliveInitialDelay` of 27 s ended an idle stream at 37.255 s.
13
+ *
14
+ * The monitor tests the server, not each connection of the pool. Thus a write-off finds a failure of
15
+ * the server in flight and idle, and a failure of one connection waits for its own detector.
16
+ */
17
+ const mongoMeetings = (name, knobs) => {
18
+ const writeoffTime = quantity((ms(knobs.connect_bound) + ms(knobs.heartbeat_interval)) / 1e3, "s");
19
+ const writeoff = (situation) => ({
20
+ by: "driver_writeoff_time",
21
+ within: writeoffTime,
22
+ situation,
23
+ effect: situation === "in flight" ? `the monitor writes the server off, and the driver fails the command as indeterminate. ${name} goes to failing` : `the monitor writes the server off, and the driver closes each idle connection. ${name} goes to failing`
24
+ });
25
+ const read = {
26
+ by: "request_timeout",
27
+ within: knobs.request_timeout,
28
+ situation: "in flight",
29
+ effect: "the command fails with a timeout of the socket, as indeterminate, and the driver closes the connection"
30
+ };
31
+ const idleExpiry = {
32
+ by: "pool_idle_expiry",
33
+ within: knobs.pool_idle_expiry,
34
+ situation: "idle",
35
+ effect: "the next checkout ends the idle connection, thus no command gets the dead connection"
36
+ };
37
+ const giveUp = kernelGiveUp(knobs.retrans_giveup_time, "the command fails as indeterminate");
38
+ const silent = (manifestation) => ({
39
+ manifestation,
40
+ what: WHAT[manifestation],
41
+ detectors: [
42
+ writeoff("in flight"),
43
+ read,
44
+ giveUp,
45
+ writeoff("idle"),
46
+ idleExpiry,
47
+ keepaliveSilent(knobs.keepalive_idle)
48
+ ]
49
+ });
50
+ return [
51
+ {
52
+ manifestation: "rst",
53
+ what: WHAT.rst,
54
+ detectors: [
55
+ immediate("in flight", "the command fails with ECONNRESET, and the driver clears the pool"),
56
+ {
57
+ by: "heartbeat_interval",
58
+ within: knobs.heartbeat_interval,
59
+ situation: "idle",
60
+ effect: "the next answer of the monitor gets a reset, thus the driver writes the server off and clears the pool"
61
+ },
62
+ idleExpiry,
63
+ keepaliveReset(knobs.keepalive_idle)
64
+ ]
65
+ },
66
+ {
67
+ manifestation: "fin",
68
+ what: WHAT.fin,
69
+ detectors: [immediate("in flight", "the command fails: the connection closed"), immediate("idle", "the stream of the monitor closes, thus the driver writes the server off and clears the pool")]
70
+ },
71
+ silent("blackhole"),
72
+ silent("freeze-host"),
73
+ {
74
+ manifestation: "freeze-process",
75
+ what: WHAT["freeze-process"],
76
+ detectors: [
77
+ writeoff("in flight"),
78
+ read,
79
+ writeoff("idle"),
80
+ idleExpiry,
81
+ keepaliveAnswered()
82
+ ]
83
+ },
84
+ {
85
+ manifestation: "app-stall",
86
+ what: "the server stops its replies to commands for a time, for example behind a lock, and its monitor still answers",
87
+ detectors: [
88
+ {
89
+ by: "statement_timeout",
90
+ within: knobs.statement_timeout,
91
+ situation: "in flight",
92
+ effect: "the server ends the command with error 50 (MaxTimeMSExpired), a certain outcome, and the connection stays"
93
+ },
94
+ read,
95
+ idleExpiry,
96
+ keepaliveAnswered()
97
+ ]
98
+ }
99
+ ];
100
+ };
101
+ export { mongoMeetings };
102
+
103
+ //# sourceMappingURL=meets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meets.js","names":[],"sources":["../../src/mongodb/meets.ts"],"sourcesContent":["import { quantity } from \"@mark1russell7/quantity\";\nimport type { Detector, Meeting } from \"../client/meets.ts\";\nimport { WHAT, immediate, keepaliveAnswered, keepaliveReset, keepaliveSilent, kernelGiveUp } from \"../client/meets.ts\";\nimport { ms } from \"../client/core.ts\";\nimport type { MongoKnobs } from \"./client.ts\";\n\n/**\n * This function gives the manifestations that a MongoDB client can meet, and the detectors of each,\n * from its knobs. The cells of S1 measured them on the driver 7.7.0 against mongod 9.0.4:\n * - The monitor writes off a silent server at `connectTimeoutMS + heartbeatFrequencyMS` after its last\n * answer: 40.002 s at the defaults, and 7 s for 5 s + 2 s. The driver then clears the pool, and\n * fails each command in flight. With `connectTimeoutMS` 0, nothing found a freeze in 60 s.\n * - At `tcp_retries2 = 5`, the kernel gave up at 12.936 s.\n * - A `keepAliveInitialDelay` of 27 s ended an idle stream at 37.255 s.\n *\n * The monitor tests the server, not each connection of the pool. Thus a write-off finds a failure of\n * the server in flight and idle, and a failure of one connection waits for its own detector.\n */\nexport const mongoMeetings = (name: string, knobs: MongoKnobs): Meeting[] => {\n const writeoffTime = quantity((ms(knobs.connect_bound) + ms(knobs.heartbeat_interval)) / 1000, \"s\");\n const writeoff = (situation: \"in flight\" | \"idle\"): Detector => ({\n by: \"driver_writeoff_time\",\n within: writeoffTime,\n situation,\n effect:\n situation === \"in flight\"\n ? `the monitor writes the server off, and the driver fails the command as indeterminate. ${name} goes to failing`\n : `the monitor writes the server off, and the driver closes each idle connection. ${name} goes to failing`,\n });\n const read: Detector = {\n by: \"request_timeout\",\n within: knobs.request_timeout,\n situation: \"in flight\",\n effect: \"the command fails with a timeout of the socket, as indeterminate, and the driver closes the connection\",\n };\n const idleExpiry: Detector = {\n by: \"pool_idle_expiry\",\n within: knobs.pool_idle_expiry,\n situation: \"idle\",\n effect: \"the next checkout ends the idle connection, thus no command gets the dead connection\",\n };\n const giveUp = kernelGiveUp(knobs.retrans_giveup_time, \"the command fails as indeterminate\");\n const silent = (manifestation: \"blackhole\" | \"freeze-host\"): Meeting => ({\n manifestation,\n what: WHAT[manifestation],\n detectors: [writeoff(\"in flight\"), read, giveUp, writeoff(\"idle\"), idleExpiry, keepaliveSilent(knobs.keepalive_idle)],\n });\n return [\n {\n manifestation: \"rst\",\n what: WHAT.rst,\n detectors: [\n immediate(\"in flight\", \"the command fails with ECONNRESET, and the driver clears the pool\"),\n {\n by: \"heartbeat_interval\",\n within: knobs.heartbeat_interval,\n situation: \"idle\",\n effect: \"the next answer of the monitor gets a reset, thus the driver writes the server off and clears the pool\",\n },\n idleExpiry,\n keepaliveReset(knobs.keepalive_idle),\n ],\n },\n {\n manifestation: \"fin\",\n what: WHAT.fin,\n detectors: [\n immediate(\"in flight\", \"the command fails: the connection closed\"),\n immediate(\"idle\", \"the stream of the monitor closes, thus the driver writes the server off and clears the pool\"),\n ],\n },\n silent(\"blackhole\"),\n silent(\"freeze-host\"),\n {\n manifestation: \"freeze-process\",\n what: WHAT[\"freeze-process\"],\n detectors: [writeoff(\"in flight\"), read, writeoff(\"idle\"), idleExpiry, keepaliveAnswered()],\n },\n {\n manifestation: \"app-stall\",\n what: \"the server stops its replies to commands for a time, for example behind a lock, and its monitor still answers\",\n detectors: [\n {\n by: \"statement_timeout\",\n within: knobs.statement_timeout,\n situation: \"in flight\",\n effect: \"the server ends the command with error 50 (MaxTimeMSExpired), a certain outcome, and the connection stays\",\n },\n read,\n idleExpiry,\n keepaliveAnswered(),\n ],\n },\n ];\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAa,iBAAiB,MAAc,UAAiC;CAC3E,MAAM,eAAe,UAAU,GAAG,MAAM,aAAa,IAAI,GAAG,MAAM,kBAAkB,KAAK,KAAM,GAAG;CAClG,MAAM,YAAY,eAA+C;EAC/D,IAAI;EACJ,QAAQ;EACR;EACA,QACE,cAAc,cACV,yFAAyF,KAAK,oBAC9F,kFAAkF,KAAK;CAC/F;CACA,MAAM,OAAiB;EACrB,IAAI;EACJ,QAAQ,MAAM;EACd,WAAW;EACX,QAAQ;CACV;CACA,MAAM,aAAuB;EAC3B,IAAI;EACJ,QAAQ,MAAM;EACd,WAAW;EACX,QAAQ;CACV;CACA,MAAM,SAAS,aAAa,MAAM,qBAAqB,oCAAoC;CAC3F,MAAM,UAAU,mBAAyD;EACvE;EACA,MAAM,KAAK;EACX,WAAW;GAAC,SAAS,WAAW;GAAG;GAAM;GAAQ,SAAS,MAAM;GAAG;GAAY,gBAAgB,MAAM,cAAc;EAAC;CACtH;CACA,OAAO;EACL;GACE,eAAe;GACf,MAAM,KAAK;GACX,WAAW;IACT,UAAU,aAAa,mEAAmE;IAC1F;KACE,IAAI;KACJ,QAAQ,MAAM;KACd,WAAW;KACX,QAAQ;IACV;IACA;IACA,eAAe,MAAM,cAAc;GACrC;EACF;EACA;GACE,eAAe;GACf,MAAM,KAAK;GACX,WAAW,CACT,UAAU,aAAa,0CAA0C,GACjE,UAAU,QAAQ,6FAA6F,CACjH;EACF;EACA,OAAO,WAAW;EAClB,OAAO,aAAa;EACpB;GACE,eAAe;GACf,MAAM,KAAK;GACX,WAAW;IAAC,SAAS,WAAW;IAAG;IAAM,SAAS,MAAM;IAAG;IAAY,kBAAkB;GAAC;EAC5F;EACA;GACE,eAAe;GACf,MAAM;GACN,WAAW;IACT;KACE,IAAI;KACJ,QAAQ,MAAM;KACd,WAAW;KACX,QAAQ;IACV;IACA;IACA;IACA,kBAAkB;GACpB;EACF;CACF;AACF"}
@@ -0,0 +1,29 @@
1
+ import { Poll } from "../timing.js";
2
+ import { MongoKnobs } from "./client.js";
3
+ /**
4
+ * This poll is the poll of the checks that `MONGO_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 MONGO_STARTING_POLL: Poll;
8
+ /**
9
+ * These knobs are a declaration to start from, from what the cells of S1 measured on the driver
10
+ * 7.7.0 on Node 24.21.0 against mongod 9.0.4. The runtime has no defaults: a service gives these
11
+ * knobs, or its own. Each value holds the borders that the cells measured:
12
+ * - `connect_bound` 5 s and `heartbeat_interval` 2 s: the write-off of a silent server came 7 s after
13
+ * its last answer, and the cells T01.border-off.75 and .76 held. At the defaults it came at 40.002 s.
14
+ * - `request_timeout` 9.5 s: in the slowest poll of 10 s (O13). At the defaults the driver has no
15
+ * bound on a read, and only the write-off ends the command.
16
+ * - `statement_timeout` 9 s: below `request_timeout`, thus the server ends a slow command first,
17
+ * with error 50 (O07).
18
+ * - `client_retry_window` 30 s: after an election, the first write took 17 s to 18 s, and the band
19
+ * ended at 26.58 s (T11.defaults.10). The default of the driver, 30 s, holds that band.
20
+ * - `checkout_timeout` 5 s: a full pool fails a checkout in a startup budget. At the defaults the wait has no bound.
21
+ * - `pool_idle_expiry` 10 s: no cell measured it. It is the bound of O03 and O01 that the pg client
22
+ * uses: below a router that forgets an idle flow at 12 s. The driver applies it at the next checkout.
23
+ * - `keepalive_idle` 30 s: the driver always turns keepalive on, at 120 s by default. This value
24
+ * refreshes a held idle connection through the NAT forms of the cells (240 s and 350 s).
25
+ * - `max_connection_age` "infinite": the driver has no age for a connection.
26
+ * - `close_bound` 2 s: behind a black hole the close of the driver waits for `endSessions`.
27
+ * - `retrans_giveup_time` 924.6 s: the give-up of Linux at `tcp_retries2 = 15`. The cells measured 12.936 s at `tcp_retries2 = 5`.
28
+ */
29
+ export declare const MONGO_STARTING_KNOBS: MongoKnobs;
@@ -0,0 +1,77 @@
1
+ import { STARTING_POLL } from "../client/core.js";
2
+ // src/mongodb/starting.ts
3
+ /**
4
+ * This poll is the poll of the checks that `MONGO_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 MONGO_STARTING_POLL = STARTING_POLL;
8
+ /**
9
+ * These knobs are a declaration to start from, from what the cells of S1 measured on the driver
10
+ * 7.7.0 on Node 24.21.0 against mongod 9.0.4. The runtime has no defaults: a service gives these
11
+ * knobs, or its own. Each value holds the borders that the cells measured:
12
+ * - `connect_bound` 5 s and `heartbeat_interval` 2 s: the write-off of a silent server came 7 s after
13
+ * its last answer, and the cells T01.border-off.75 and .76 held. At the defaults it came at 40.002 s.
14
+ * - `request_timeout` 9.5 s: in the slowest poll of 10 s (O13). At the defaults the driver has no
15
+ * bound on a read, and only the write-off ends the command.
16
+ * - `statement_timeout` 9 s: below `request_timeout`, thus the server ends a slow command first,
17
+ * with error 50 (O07).
18
+ * - `client_retry_window` 30 s: after an election, the first write took 17 s to 18 s, and the band
19
+ * ended at 26.58 s (T11.defaults.10). The default of the driver, 30 s, holds that band.
20
+ * - `checkout_timeout` 5 s: a full pool fails a checkout in a startup budget. At the defaults the wait has no bound.
21
+ * - `pool_idle_expiry` 10 s: no cell measured it. It is the bound of O03 and O01 that the pg client
22
+ * uses: below a router that forgets an idle flow at 12 s. The driver applies it at the next checkout.
23
+ * - `keepalive_idle` 30 s: the driver always turns keepalive on, at 120 s by default. This value
24
+ * refreshes a held idle connection through the NAT forms of the cells (240 s and 350 s).
25
+ * - `max_connection_age` "infinite": the driver has no age for a connection.
26
+ * - `close_bound` 2 s: behind a black hole the close of the driver waits for `endSessions`.
27
+ * - `retrans_giveup_time` 924.6 s: the give-up of Linux at `tcp_retries2 = 15`. The cells measured 12.936 s at `tcp_retries2 = 5`.
28
+ */
29
+ const MONGO_STARTING_KNOBS = {
30
+ connect_bound: {
31
+ value: 5,
32
+ unit: "s"
33
+ },
34
+ request_timeout: {
35
+ value: 9.5,
36
+ unit: "s"
37
+ },
38
+ statement_timeout: {
39
+ value: 9,
40
+ unit: "s"
41
+ },
42
+ heartbeat_interval: {
43
+ value: 2,
44
+ unit: "s"
45
+ },
46
+ client_retry_window: {
47
+ value: 30,
48
+ unit: "s"
49
+ },
50
+ checkout_timeout: {
51
+ value: 5,
52
+ unit: "s"
53
+ },
54
+ pool_idle_expiry: {
55
+ value: 10,
56
+ unit: "s"
57
+ },
58
+ keepalive_idle: {
59
+ value: 30,
60
+ unit: "s"
61
+ },
62
+ max_connection_age: {
63
+ value: "infinite",
64
+ unit: "s"
65
+ },
66
+ close_bound: {
67
+ value: 2,
68
+ unit: "s"
69
+ },
70
+ retrans_giveup_time: {
71
+ value: 924.6,
72
+ unit: "s"
73
+ }
74
+ };
75
+ export { MONGO_STARTING_KNOBS, MONGO_STARTING_POLL };
76
+
77
+ //# sourceMappingURL=starting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"starting.js","names":[],"sources":["../../src/mongodb/starting.ts"],"sourcesContent":["import { STARTING_POLL } from \"../client/core.ts\";\nimport type { Poll } from \"../timing.ts\";\nimport type { MongoKnobs } from \"./client.ts\";\n\n/**\n * This poll is the poll of the checks that `MONGO_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 MONGO_STARTING_POLL: Poll = STARTING_POLL;\n\n/**\n * These knobs are a declaration to start from, from what the cells of S1 measured on the driver\n * 7.7.0 on Node 24.21.0 against mongod 9.0.4. The runtime has no defaults: a service gives these\n * knobs, or its own. Each value holds the borders that the cells measured:\n * - `connect_bound` 5 s and `heartbeat_interval` 2 s: the write-off of a silent server came 7 s after\n * its last answer, and the cells T01.border-off.75 and .76 held. At the defaults it came at 40.002 s.\n * - `request_timeout` 9.5 s: in the slowest poll of 10 s (O13). At the defaults the driver has no\n * bound on a read, and only the write-off ends the command.\n * - `statement_timeout` 9 s: below `request_timeout`, thus the server ends a slow command first,\n * with error 50 (O07).\n * - `client_retry_window` 30 s: after an election, the first write took 17 s to 18 s, and the band\n * ended at 26.58 s (T11.defaults.10). The default of the driver, 30 s, holds that band.\n * - `checkout_timeout` 5 s: a full pool fails a checkout in a startup budget. At the defaults the wait has no bound.\n * - `pool_idle_expiry` 10 s: no cell measured it. It is the bound of O03 and O01 that the pg client\n * uses: below a router that forgets an idle flow at 12 s. The driver applies it at the next checkout.\n * - `keepalive_idle` 30 s: the driver always turns keepalive on, at 120 s by default. This value\n * refreshes a held idle connection through the NAT forms of the cells (240 s and 350 s).\n * - `max_connection_age` \"infinite\": the driver has no age for a connection.\n * - `close_bound` 2 s: behind a black hole the close of the driver waits for `endSessions`.\n * - `retrans_giveup_time` 924.6 s: the give-up of Linux at `tcp_retries2 = 15`. The cells measured 12.936 s at `tcp_retries2 = 5`.\n */\nexport const MONGO_STARTING_KNOBS: MongoKnobs = {\n connect_bound: { value: 5, unit: \"s\" },\n request_timeout: { value: 9.5, unit: \"s\" },\n statement_timeout: { value: 9, unit: \"s\" },\n heartbeat_interval: { value: 2, unit: \"s\" },\n client_retry_window: { value: 30, unit: \"s\" },\n checkout_timeout: { value: 5, unit: \"s\" },\n pool_idle_expiry: { value: 10, unit: \"s\" },\n keepalive_idle: { value: 30, 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,sBAA4B;;;;;;;;;;;;;;;;;;;;;;AAuBzC,MAAa,uBAAmC;CAC9C,eAAe;EAAE,OAAO;EAAG,MAAM;CAAI;CACrC,iBAAiB;EAAE,OAAO;EAAK,MAAM;CAAI;CACzC,mBAAmB;EAAE,OAAO;EAAG,MAAM;CAAI;CACzC,oBAAoB;EAAE,OAAO;EAAG,MAAM;CAAI;CAC1C,qBAAqB;EAAE,OAAO;EAAI,MAAM;CAAI;CAC5C,kBAAkB;EAAE,OAAO;EAAG,MAAM;CAAI;CACxC,kBAAkB;EAAE,OAAO;EAAI,MAAM;CAAI;CACzC,gBAAgB;EAAE,OAAO;EAAI,MAAM;CAAI;CACvC,oBAAoB;EAAE,OAAO;EAAY,MAAM;CAAI;CACnD,aAAa;EAAE,OAAO;EAAG,MAAM;CAAI;CACnC,qBAAqB;EAAE,OAAO;EAAO,MAAM;CAAI;AACjD"}