@tumbaland/backend-core 1.55.0 → 1.56.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.
@@ -1,16 +1,16 @@
1
1
  import { ConnectOptions } from 'mongoose';
2
2
  /**
3
- * How the pool behaves toward a database that is across the internet.
3
+ * How the pool behaves, so a burst of requests does not pay for opening connections.
4
4
  *
5
- * Measured, not assumed: on the Pi a database lookup took about 17 ms on a warm
6
- * connection and 850 to 1,370 ms on a cold one, so the distance to Atlas is not
7
- * the cost. Opening a connection is. It is a TCP and TLS handshake and an
8
- * authentication, from a small machine, and the driver defaults make a burst of
9
- * requests pay for it badly:
5
+ * Measured, not assumed: against a database across the internet (the hosted one
6
+ * this replaced) a lookup took about 17 ms on a warm connection and 850 to
7
+ * 1,370 ms on a cold one, so distance was not the cost. Opening a connection was.
8
+ * It is a TCP and TLS handshake and an authentication, from a small machine, and
9
+ * the driver defaults make a burst of requests pay for it badly:
10
10
  *
11
11
  * - It keeps no connections open, and an idle one is eventually dropped by
12
- * something between here and Atlas, so the first request after a quiet spell
13
- * starts from nothing.
12
+ * something on the way, so the first request after a quiet spell starts from
13
+ * nothing.
14
14
  * - It opens at most two connections at a time. Opening a thread sends five or
15
15
  * six requests at once, so they queued behind each other, a second or so per
16
16
  * pair, and the thread took three to seven seconds.
@@ -20,8 +20,8 @@ import { ConnectOptions } from 'mongoose';
20
20
  * - `maxConnecting` lets the pool open several at once when it does need more.
21
21
  * - `maxIdleTimeMS` retires a connection that has sat idle for a few minutes,
22
22
  * before something else kills it, and the pool opens a fresh one in its place.
23
- * - `family: 4` skips the IPv6 half of every hostname lookup. Atlas is IPv4, and
24
- * a resolver that is slow to answer for AAAA delays every new connection.
23
+ * - `family: 4` skips the IPv6 half of every hostname lookup. The database is
24
+ * IPv4, and a resolver that is slow to answer for AAAA delays every new connection.
25
25
  *
26
26
  * Each can be set per deployment, for a database that is somewhere else.
27
27
  */
@@ -29,12 +29,12 @@ export declare function poolOptions(env?: NodeJS.ProcessEnv): ConnectOptions;
29
29
  /**
30
30
  * Connects once and throws on failure. There is deliberately no retry loop here.
31
31
  *
32
- * MongoDB is Atlas (`mongodb+srv://`), not a sidecar container, so there is no
33
- * boot race to ride out — and the driver already retries for us: `connect()`
34
- * keeps doing server selection for `serverSelectionTimeoutMS` (30s by default)
35
- * before it rejects, so a transient DNS or network blip is absorbed there.
36
- * Anything that survives that is a real fault — bad credentials, an IP missing
37
- * from the Atlas allowlist, a dead cluster — and no amount of retrying fixes it.
32
+ * The driver already retries for us: `connect()` keeps doing server selection
33
+ * for `serverSelectionTimeoutMS` (30s by default) before it rejects, so a
34
+ * transient DNS or network blip, or a database container that is still starting,
35
+ * is absorbed there. Anything that survives that is a real fault — bad
36
+ * credentials, a wrong address, a database that is down — and no amount of
37
+ * retrying fixes it.
38
38
  *
39
39
  * Callers exit non-zero when this throws, which hands the problem to the
40
40
  * container restart policy (`restart: unless-stopped`) that already supervises
@@ -16,17 +16,17 @@ let connected = false;
16
16
  let pending = null;
17
17
  let listenersRegistered = false;
18
18
  /**
19
- * How the pool behaves toward a database that is across the internet.
19
+ * How the pool behaves, so a burst of requests does not pay for opening connections.
20
20
  *
21
- * Measured, not assumed: on the Pi a database lookup took about 17 ms on a warm
22
- * connection and 850 to 1,370 ms on a cold one, so the distance to Atlas is not
23
- * the cost. Opening a connection is. It is a TCP and TLS handshake and an
24
- * authentication, from a small machine, and the driver defaults make a burst of
25
- * requests pay for it badly:
21
+ * Measured, not assumed: against a database across the internet (the hosted one
22
+ * this replaced) a lookup took about 17 ms on a warm connection and 850 to
23
+ * 1,370 ms on a cold one, so distance was not the cost. Opening a connection was.
24
+ * It is a TCP and TLS handshake and an authentication, from a small machine, and
25
+ * the driver defaults make a burst of requests pay for it badly:
26
26
  *
27
27
  * - It keeps no connections open, and an idle one is eventually dropped by
28
- * something between here and Atlas, so the first request after a quiet spell
29
- * starts from nothing.
28
+ * something on the way, so the first request after a quiet spell starts from
29
+ * nothing.
30
30
  * - It opens at most two connections at a time. Opening a thread sends five or
31
31
  * six requests at once, so they queued behind each other, a second or so per
32
32
  * pair, and the thread took three to seven seconds.
@@ -36,8 +36,8 @@ let listenersRegistered = false;
36
36
  * - `maxConnecting` lets the pool open several at once when it does need more.
37
37
  * - `maxIdleTimeMS` retires a connection that has sat idle for a few minutes,
38
38
  * before something else kills it, and the pool opens a fresh one in its place.
39
- * - `family: 4` skips the IPv6 half of every hostname lookup. Atlas is IPv4, and
40
- * a resolver that is slow to answer for AAAA delays every new connection.
39
+ * - `family: 4` skips the IPv6 half of every hostname lookup. The database is
40
+ * IPv4, and a resolver that is slow to answer for AAAA delays every new connection.
41
41
  *
42
42
  * Each can be set per deployment, for a database that is somewhere else.
43
43
  */
@@ -57,12 +57,12 @@ function poolOptions(env = process.env) {
57
57
  /**
58
58
  * Connects once and throws on failure. There is deliberately no retry loop here.
59
59
  *
60
- * MongoDB is Atlas (`mongodb+srv://`), not a sidecar container, so there is no
61
- * boot race to ride out — and the driver already retries for us: `connect()`
62
- * keeps doing server selection for `serverSelectionTimeoutMS` (30s by default)
63
- * before it rejects, so a transient DNS or network blip is absorbed there.
64
- * Anything that survives that is a real fault — bad credentials, an IP missing
65
- * from the Atlas allowlist, a dead cluster — and no amount of retrying fixes it.
60
+ * The driver already retries for us: `connect()` keeps doing server selection
61
+ * for `serverSelectionTimeoutMS` (30s by default) before it rejects, so a
62
+ * transient DNS or network blip, or a database container that is still starting,
63
+ * is absorbed there. Anything that survives that is a real fault — bad
64
+ * credentials, a wrong address, a database that is down — and no amount of
65
+ * retrying fixes it.
66
66
  *
67
67
  * Callers exit non-zero when this throws, which hands the problem to the
68
68
  * container restart policy (`restart: unless-stopped`) that already supervises
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tumbaland/backend-core",
3
- "version": "1.55.0",
3
+ "version": "1.56.0",
4
4
  "description": "Core shared functionality for Tumbaland backend services",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",