@n8io/baseline-shutdown 2.1.0 → 3.0.1

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.
package/README.md CHANGED
@@ -8,7 +8,7 @@ pnpm add @n8io/baseline-shutdown
8
8
 
9
9
  ## Exports
10
10
 
11
- - `shutdownHandle({ intakes, resources, deadlineMs?, drainDelayMs? })`: owns `SIGTERM`, `SIGINT`, `uncaughtException` and `unhandledRejection`, and exits the process: 0 when every step closed in time, 1 otherwise or after a crash.
11
+ - `shutdownHandleCreate({ intakes, resources, deadlineMs?, drainDelayMs? })`: owns `SIGTERM`, `SIGINT`, `uncaughtException` and `unhandledRejection`, and exits the process: 0 when every step closed in time, 1 otherwise or after a crash.
12
12
  1. Waits `drainDelayMs` (default 5 s; pass 0 outside production) while readiness answers 503.
13
13
  2. Closes every intake (HTTP server, live streams, Consumers) at once.
14
14
  3. Closes each resource (queue, pools, clients, health, telemetry last) in order.
@@ -20,10 +20,10 @@ pnpm add @n8io/baseline-shutdown
20
20
 
21
21
  ```ts
22
22
  import { httpServerClose } from "@n8io/baseline-http";
23
- import { shutdownHandle } from "@n8io/baseline-shutdown";
23
+ import { shutdownHandleCreate } from "@n8io/baseline-shutdown";
24
24
  import { telemetryShutdown } from "@n8io/baseline-telemetry";
25
25
 
26
- const shutdown = shutdownHandle({
26
+ const shutdown = shutdownHandleCreate({
27
27
  drainDelayMs: envLocal ? 0 : 5_000,
28
28
  intakes: [
29
29
  { close: () => httpServerClose(server), name: "http" },
package/dist/index.d.ts CHANGED
@@ -11,5 +11,5 @@ type ShutdownOptions = {
11
11
  export type ShutdownHandle = {
12
12
  isShuttingDown(): boolean;
13
13
  };
14
- export declare const shutdownHandle: ({ deadlineMs, drainDelayMs, intakes, resources }: ShutdownOptions) => ShutdownHandle;
14
+ export declare const shutdownHandleCreate: ({ deadlineMs, drainDelayMs, intakes, resources }: ShutdownOptions) => ShutdownHandle;
15
15
  export {};
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ const stepClose = async (kind, step) => {
14
14
  return false;
15
15
  }
16
16
  };
17
- const shutdownHandle = ({ deadlineMs = 25e3, drainDelayMs = 5e3, intakes, resources }) => {
17
+ const shutdownHandleCreate = ({ deadlineMs = 25e3, drainDelayMs = 5e3, intakes, resources }) => {
18
18
  let shuttingDown = false;
19
19
  let crashed = false;
20
20
  const shutdownRun = async (drainMs) => {
@@ -69,4 +69,4 @@ const shutdownHandle = ({ deadlineMs = 25e3, drainDelayMs = 5e3, intakes, resour
69
69
  process.on("unhandledRejection", onCrash);
70
70
  return { isShuttingDown: () => shuttingDown };
71
71
  };
72
- export { shutdownHandle };
72
+ export { shutdownHandleCreate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n8io/baseline-shutdown",
3
- "version": "2.1.0",
3
+ "version": "3.0.1",
4
4
  "description": "Graceful shutdown: drain, close intakes together, then resources in order.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "registry": "https://registry.npmjs.org"
28
28
  },
29
29
  "dependencies": {
30
- "@n8io/baseline-logger": "^2.1.0"
30
+ "@n8io/baseline-logger": "^3.0.0"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsdown",