@autofleet/nitur 2.2.0-0 → 2.2.0-beta.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 (69) hide show
  1. package/lib/alive-endpoint/middleware.cjs +1 -1
  2. package/lib/alive-endpoint/middleware.js +1 -1
  3. package/lib/fastify.cjs +1 -1
  4. package/lib/fastify.d.cts +1 -6
  5. package/lib/fastify.d.ts +1 -6
  6. package/lib/fastify.js +1 -1
  7. package/lib/health-manager/health-check-handlers.cjs +2 -0
  8. package/lib/health-manager/health-check-handlers.cjs.map +1 -0
  9. package/lib/health-manager/health-check-handlers.js +2 -0
  10. package/lib/health-manager/health-check-handlers.js.map +1 -0
  11. package/lib/health-manager/health-manager.cjs +2 -0
  12. package/lib/health-manager/health-manager.cjs.map +1 -0
  13. package/lib/health-manager/health-manager.d.cts +80 -0
  14. package/lib/health-manager/health-manager.d.ts +80 -0
  15. package/lib/health-manager/health-manager.js +2 -0
  16. package/lib/health-manager/health-manager.js.map +1 -0
  17. package/lib/health-manager/shutdown-handlers.cjs +2 -0
  18. package/lib/health-manager/shutdown-handlers.cjs.map +1 -0
  19. package/lib/health-manager/shutdown-handlers.js +2 -0
  20. package/lib/health-manager/shutdown-handlers.js.map +1 -0
  21. package/lib/health-manager/types.cjs +2 -0
  22. package/lib/health-manager/types.cjs.map +1 -0
  23. package/lib/health-manager/types.d.cts +104 -0
  24. package/lib/health-manager/types.d.ts +104 -0
  25. package/lib/health-manager/types.js +2 -0
  26. package/lib/health-manager/types.js.map +1 -0
  27. package/lib/index.cjs +1 -1
  28. package/lib/index.d.cts +2 -6
  29. package/lib/index.d.ts +2 -6
  30. package/lib/index.js +1 -1
  31. package/lib/utils.cjs +2 -0
  32. package/lib/utils.cjs.map +1 -0
  33. package/lib/utils.js +2 -0
  34. package/lib/utils.js.map +1 -0
  35. package/package.json +11 -14
  36. package/lib/health-check/checkers.cjs +0 -2
  37. package/lib/health-check/checkers.cjs.map +0 -1
  38. package/lib/health-check/checkers.d.cts +0 -44
  39. package/lib/health-check/checkers.d.ts +0 -44
  40. package/lib/health-check/checkers.js +0 -2
  41. package/lib/health-check/checkers.js.map +0 -1
  42. package/lib/health-check/express-adapter.cjs +0 -2
  43. package/lib/health-check/express-adapter.cjs.map +0 -1
  44. package/lib/health-check/express-adapter.d.cts +0 -23
  45. package/lib/health-check/express-adapter.d.ts +0 -23
  46. package/lib/health-check/express-adapter.js +0 -2
  47. package/lib/health-check/express-adapter.js.map +0 -1
  48. package/lib/health-check/fastify-adapter.cjs +0 -2
  49. package/lib/health-check/fastify-adapter.cjs.map +0 -1
  50. package/lib/health-check/fastify-adapter.d.cts +0 -28
  51. package/lib/health-check/fastify-adapter.d.ts +0 -28
  52. package/lib/health-check/fastify-adapter.js +0 -2
  53. package/lib/health-check/fastify-adapter.js.map +0 -1
  54. package/lib/health-check/index.cjs +0 -1
  55. package/lib/health-check/index.js +0 -1
  56. package/lib/health-check/manager.cjs +0 -2
  57. package/lib/health-check/manager.cjs.map +0 -1
  58. package/lib/health-check/manager.d.cts +0 -53
  59. package/lib/health-check/manager.d.ts +0 -53
  60. package/lib/health-check/manager.js +0 -2
  61. package/lib/health-check/manager.js.map +0 -1
  62. package/lib/health-check/setup.cjs +0 -2
  63. package/lib/health-check/setup.cjs.map +0 -1
  64. package/lib/health-check/setup.d.cts +0 -69
  65. package/lib/health-check/setup.d.ts +0 -69
  66. package/lib/health-check/setup.js +0 -2
  67. package/lib/health-check/setup.js.map +0 -1
  68. package/lib/health-check/types.d.cts +0 -156
  69. package/lib/health-check/types.d.ts +0 -156
@@ -1,69 +0,0 @@
1
- import { GracefulShutdownConfig, LivenessConfig, ReadinessConfig } from "./types.cjs";
2
- import { HealthCheckManager } from "./manager.cjs";
3
- import { LoggerInstanceManager } from "@autofleet/logger";
4
- import { Server } from "http";
5
- import { HttpTerminator } from "http-terminator";
6
-
7
- //#region src/health-check/setup.d.ts
8
-
9
- /**
10
- * Generic app interface - works for both Express and Fastify
11
- */
12
- interface App {
13
- get(path: string, handler: (req: any, res: any) => void | Promise<any>): any;
14
- }
15
- /**
16
- * Configuration for health check setup
17
- */
18
- interface HealthCheckSetupConfig {
19
- /**
20
- * Application instance (Express or Fastify)
21
- */
22
- app: App;
23
- /**
24
- * HTTP server instance
25
- */
26
- server: Server;
27
- /**
28
- * Logger instance
29
- */
30
- logger?: LoggerInstanceManager;
31
- /**
32
- * Liveness probe configuration
33
- */
34
- liveness?: LivenessConfig;
35
- /**
36
- * Readiness probe configuration
37
- */
38
- readiness?: ReadinessConfig;
39
- /**
40
- * Graceful shutdown configuration
41
- */
42
- gracefulShutdown?: GracefulShutdownConfig;
43
- /**
44
- * Custom endpoint paths
45
- */
46
- endpoints?: {
47
- liveness?: string;
48
- readiness?: string;
49
- };
50
- }
51
- /**
52
- * Health Check Setup Result
53
- */
54
- interface HealthCheckSetup {
55
- healthCheckManager: HealthCheckManager;
56
- httpTerminator: HttpTerminator;
57
- addShutdownHook: (name: string, hook: () => Promise<void>) => void;
58
- checkLiveness: () => Promise<any>;
59
- checkReadiness: () => Promise<any>;
60
- shutdown: () => Promise<void>;
61
- }
62
- /**
63
- * Setup health checks and graceful shutdown
64
- * Works with both Express and Fastify
65
- */
66
- declare function setupHealthCheck(config: HealthCheckSetupConfig): HealthCheckSetup;
67
- //#endregion
68
- export { HealthCheckSetup, HealthCheckSetupConfig, setupHealthCheck };
69
- //# sourceMappingURL=setup.d.cts.map
@@ -1,69 +0,0 @@
1
- import { GracefulShutdownConfig, LivenessConfig, ReadinessConfig } from "./types.js";
2
- import { HealthCheckManager } from "./manager.js";
3
- import { LoggerInstanceManager } from "@autofleet/logger";
4
- import { HttpTerminator } from "http-terminator";
5
- import { Server } from "http";
6
-
7
- //#region src/health-check/setup.d.ts
8
-
9
- /**
10
- * Generic app interface - works for both Express and Fastify
11
- */
12
- interface App {
13
- get(path: string, handler: (req: any, res: any) => void | Promise<any>): any;
14
- }
15
- /**
16
- * Configuration for health check setup
17
- */
18
- interface HealthCheckSetupConfig {
19
- /**
20
- * Application instance (Express or Fastify)
21
- */
22
- app: App;
23
- /**
24
- * HTTP server instance
25
- */
26
- server: Server;
27
- /**
28
- * Logger instance
29
- */
30
- logger?: LoggerInstanceManager;
31
- /**
32
- * Liveness probe configuration
33
- */
34
- liveness?: LivenessConfig;
35
- /**
36
- * Readiness probe configuration
37
- */
38
- readiness?: ReadinessConfig;
39
- /**
40
- * Graceful shutdown configuration
41
- */
42
- gracefulShutdown?: GracefulShutdownConfig;
43
- /**
44
- * Custom endpoint paths
45
- */
46
- endpoints?: {
47
- liveness?: string;
48
- readiness?: string;
49
- };
50
- }
51
- /**
52
- * Health Check Setup Result
53
- */
54
- interface HealthCheckSetup {
55
- healthCheckManager: HealthCheckManager;
56
- httpTerminator: HttpTerminator;
57
- addShutdownHook: (name: string, hook: () => Promise<void>) => void;
58
- checkLiveness: () => Promise<any>;
59
- checkReadiness: () => Promise<any>;
60
- shutdown: () => Promise<void>;
61
- }
62
- /**
63
- * Setup health checks and graceful shutdown
64
- * Works with both Express and Fastify
65
- */
66
- declare function setupHealthCheck(config: HealthCheckSetupConfig): HealthCheckSetup;
67
- //#endregion
68
- export { HealthCheckSetup, HealthCheckSetupConfig, setupHealthCheck };
69
- //# sourceMappingURL=setup.d.ts.map
@@ -1,2 +0,0 @@
1
- import{logger as e}from"../logger.js";import{HealthCheckManager as t}from"./manager.js";import{createTerminus as n}from"@godaddy/terminus";import{createHttpTerminator as r}from"http-terminator";function i(i){let a=i.logger??e,o=i.endpoints?.liveness||`/health/live`,s=i.endpoints?.readiness||`/health/ready`,c=new t(i.liveness,i.readiness),l=r({server:i.server}),u=i.gracefulShutdown?.shutdownHooks||[],d={signals:i.gracefulShutdown?.signals??[`SIGTERM`,`SIGINT`],timeout:i.gracefulShutdown?.timeout||3e4,healthChecks:{[o]:async()=>{let e=await c.checkLiveness();if(e.status===`fail`)throw Error(e.checks.filter(e=>e.status===`fail`).map(e=>e.error).join(`, `))},[s]:async()=>{let e=await c.checkReadiness();if(e.status===`fail`)throw Error(e.checks.filter(e=>e.status===`fail`).map(e=>e.error).join(`, `))}},beforeShutdown:async()=>{a.info(`Received shutdown signal`),await new Promise(e=>setTimeout(e,5e3))},onSignal:async()=>{a.info(`Executing shutdown hooks`),await Promise.all(u.map(async({name:e,hook:t})=>{try{a.info(`Running shutdown hook: ${e}`),await t()}catch(t){throw a.error(`Shutdown hook '${e}' failed`,{error:t}),t}}))},onShutdown:async()=>{a.info(`Graceful shutdown completed`)},logger:(e,t)=>{t?a.error(e,{error:t}):a.info(e)}};return n(i.server,d),a.info(`Health checks and graceful shutdown initialized`,{livenessPath:o,readinessPath:s}),{healthCheckManager:c,httpTerminator:l,addShutdownHook:(e,t)=>{u.push({name:e,hook:t})},checkLiveness:()=>c.checkLiveness(),checkReadiness:()=>c.checkReadiness(),shutdown:async()=>{a.info(`Manual shutdown initiated`),await l.terminate()}}}export{i as setupHealthCheck};
2
- //# sourceMappingURL=setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.js","names":["logger","defaultLogger","shutdownHooks: NamedShutdownHook[]","terminusOptions: TerminusOptions"],"sources":["../../src/health-check/setup.ts"],"sourcesContent":["import type { Server } from 'http';\nimport type { LoggerInstanceManager } from '@autofleet/logger';\nimport { createTerminus, type TerminusOptions } from '@godaddy/terminus';\nimport { createHttpTerminator, type HttpTerminator } from 'http-terminator';\nimport { logger as defaultLogger } from '../logger';\nimport { HealthCheckManager } from './manager';\nimport type {\n LivenessConfig,\n ReadinessConfig,\n GracefulShutdownConfig,\n NamedShutdownHook,\n} from './types';\n\n/**\n * Generic app interface - works for both Express and Fastify\n */\ninterface App {\n get(path: string, handler: (req: any, res: any) => void | Promise<any>): any;\n}\n\n/**\n * Configuration for health check setup\n */\nexport interface HealthCheckSetupConfig {\n /**\n * Application instance (Express or Fastify)\n */\n app: App;\n\n /**\n * HTTP server instance\n */\n server: Server;\n\n /**\n * Logger instance\n */\n logger?: LoggerInstanceManager;\n\n /**\n * Liveness probe configuration\n */\n liveness?: LivenessConfig;\n\n /**\n * Readiness probe configuration\n */\n readiness?: ReadinessConfig;\n\n /**\n * Graceful shutdown configuration\n */\n gracefulShutdown?: GracefulShutdownConfig;\n\n /**\n * Custom endpoint paths\n */\n endpoints?: {\n liveness?: string;\n readiness?: string;\n };\n}\n\n/**\n * Health Check Setup Result\n */\nexport interface HealthCheckSetup {\n healthCheckManager: HealthCheckManager;\n httpTerminator: HttpTerminator;\n addShutdownHook: (name: string, hook: () => Promise<void>) => void;\n checkLiveness: () => Promise<any>;\n checkReadiness: () => Promise<any>;\n shutdown: () => Promise<void>;\n}\n\n/**\n * Setup health checks and graceful shutdown\n * Works with both Express and Fastify\n */\nexport function setupHealthCheck(config: HealthCheckSetupConfig): HealthCheckSetup {\n const logger = config.logger ?? defaultLogger;\n const livenessPath = config.endpoints?.liveness || '/health/live';\n const readinessPath = config.endpoints?.readiness || '/health/ready';\n\n // Create health check manager\n const healthCheckManager = new HealthCheckManager(config.liveness, config.readiness);\n\n // Create http terminator\n const httpTerminator = createHttpTerminator({ server: config.server });\n\n // Shutdown hooks\n const shutdownHooks: NamedShutdownHook[] = config.gracefulShutdown?.shutdownHooks || [];\n\n // Setup terminus\n const terminusOptions: TerminusOptions = {\n signals: config.gracefulShutdown?.signals ?? ['SIGTERM', 'SIGINT'],\n timeout: config.gracefulShutdown?.timeout || 30000,\n\n healthChecks: {\n [livenessPath]: async () => {\n const status = await healthCheckManager.checkLiveness();\n if (status.status === 'fail') {\n throw new Error(status.checks.filter(c => c.status === 'fail').map(c => c.error).join(', '));\n }\n },\n [readinessPath]: async () => {\n const status = await healthCheckManager.checkReadiness();\n if (status.status === 'fail') {\n throw new Error(status.checks.filter(c => c.status === 'fail').map(c => c.error).join(', '));\n }\n },\n },\n\n beforeShutdown: async () => {\n logger.info('Received shutdown signal');\n // Give load balancers time to remove instance\n await new Promise(resolve => setTimeout(resolve, 5000));\n },\n\n onSignal: async () => {\n logger.info('Executing shutdown hooks');\n await Promise.all(shutdownHooks.map(async ({ name, hook }) => {\n try {\n logger.info(`Running shutdown hook: ${name}`);\n await hook();\n } catch (error) {\n logger.error(`Shutdown hook '${name}' failed`, { error });\n throw error;\n }\n }));\n },\n\n onShutdown: async () => {\n logger.info('Graceful shutdown completed');\n },\n\n logger: (msg, error) => {\n if (error) {\n logger.error(msg, { error });\n } else {\n logger.info(msg);\n }\n },\n };\n\n createTerminus(config.server, terminusOptions);\n\n logger.info('Health checks and graceful shutdown initialized', {\n livenessPath,\n readinessPath,\n });\n\n return {\n healthCheckManager,\n httpTerminator,\n addShutdownHook: (name: string, hook: () => Promise<void>) => {\n shutdownHooks.push({ name, hook });\n },\n checkLiveness: () => healthCheckManager.checkLiveness(),\n checkReadiness: () => healthCheckManager.checkReadiness(),\n shutdown: async () => {\n logger.info('Manual shutdown initiated');\n await httpTerminator.terminate();\n },\n };\n}\n"],"mappings":"kMA+EA,SAAgB,EAAiB,EAAkD,CACjF,IAAMA,EAAS,EAAO,QAAUC,EAC1B,EAAe,EAAO,WAAW,UAAY,eAC7C,EAAgB,EAAO,WAAW,WAAa,gBAG/C,EAAqB,IAAI,EAAmB,EAAO,SAAU,EAAO,UAAU,CAG9E,EAAiB,EAAqB,CAAE,OAAQ,EAAO,OAAQ,CAAC,CAGhEC,EAAqC,EAAO,kBAAkB,eAAiB,EAAE,CAGjFC,EAAmC,CACvC,QAAS,EAAO,kBAAkB,SAAW,CAAC,UAAW,SAAS,CAClE,QAAS,EAAO,kBAAkB,SAAW,IAE7C,aAAc,EACX,GAAe,SAAY,CAC1B,IAAM,EAAS,MAAM,EAAmB,eAAe,CACvD,GAAI,EAAO,SAAW,OACpB,MAAU,MAAM,EAAO,OAAO,OAAO,GAAK,EAAE,SAAW,OAAO,CAAC,IAAI,GAAK,EAAE,MAAM,CAAC,KAAK,KAAK,CAAC,GAG/F,GAAgB,SAAY,CAC3B,IAAM,EAAS,MAAM,EAAmB,gBAAgB,CACxD,GAAI,EAAO,SAAW,OACpB,MAAU,MAAM,EAAO,OAAO,OAAO,GAAK,EAAE,SAAW,OAAO,CAAC,IAAI,GAAK,EAAE,MAAM,CAAC,KAAK,KAAK,CAAC,EAGjG,CAED,eAAgB,SAAY,CAC1B,EAAO,KAAK,2BAA2B,CAEvC,MAAM,IAAI,QAAQ,GAAW,WAAW,EAAS,IAAK,CAAC,EAGzD,SAAU,SAAY,CACpB,EAAO,KAAK,2BAA2B,CACvC,MAAM,QAAQ,IAAI,EAAc,IAAI,MAAO,CAAE,OAAM,UAAW,CAC5D,GAAI,CACF,EAAO,KAAK,0BAA0B,IAAO,CAC7C,MAAM,GAAM,OACL,EAAO,CAEd,MADA,EAAO,MAAM,kBAAkB,EAAK,UAAW,CAAE,QAAO,CAAC,CACnD,IAER,CAAC,EAGL,WAAY,SAAY,CACtB,EAAO,KAAK,8BAA8B,EAG5C,QAAS,EAAK,IAAU,CAClB,EACF,EAAO,MAAM,EAAK,CAAE,QAAO,CAAC,CAE5B,EAAO,KAAK,EAAI,EAGrB,CASD,OAPA,EAAe,EAAO,OAAQ,EAAgB,CAE9C,EAAO,KAAK,kDAAmD,CAC7D,eACA,gBACD,CAAC,CAEK,CACL,qBACA,iBACA,iBAAkB,EAAc,IAA8B,CAC5D,EAAc,KAAK,CAAE,OAAM,OAAM,CAAC,EAEpC,kBAAqB,EAAmB,eAAe,CACvD,mBAAsB,EAAmB,gBAAgB,CACzD,SAAU,SAAY,CACpB,EAAO,KAAK,4BAA4B,CACxC,MAAM,EAAe,WAAW,EAEnC"}
@@ -1,156 +0,0 @@
1
- import { LoggerInstanceManager } from "@autofleet/logger";
2
-
3
- //#region src/health-check/types.d.ts
4
-
5
- /**
6
- * Health check function that returns health status
7
- * @returns Promise that resolves on success or rejects with error message
8
- */
9
- type HealthCheck = () => Promise<void>;
10
- /**
11
- * Named health check with identifier
12
- */
13
- interface NamedHealthCheck {
14
- name: string;
15
- check: HealthCheck;
16
- }
17
- /**
18
- * Health check result for a single check
19
- */
20
- interface HealthCheckResult {
21
- name: string;
22
- status: "pass" | "fail";
23
- error?: string;
24
- duration: number;
25
- }
26
- /**
27
- * Overall health status response
28
- */
29
- interface HealthStatus {
30
- status: "pass" | "fail";
31
- timestamp: string;
32
- checks: HealthCheckResult[];
33
- duration: number;
34
- }
35
- /**
36
- * Redis client interface - supports multiple instances
37
- */
38
- interface RedisClient {
39
- ping: () => Promise<string | void>;
40
- }
41
- /**
42
- * Sequelize database interface
43
- */
44
- interface SequelizeClient {
45
- query(sql: string | {
46
- query: string;
47
- values: unknown[];
48
- }): Promise<any>;
49
- }
50
- /**
51
- * Elasticsearch client interface
52
- */
53
- interface ElasticsearchClient {
54
- ping: () => Promise<boolean>;
55
- }
56
- /**
57
- * RabbitMQ client interface
58
- */
59
- interface RabbitMQClient {
60
- isConnected: () => Promise<boolean> | boolean;
61
- }
62
- /**
63
- * Configuration for resource checkers
64
- */
65
- interface ResourceCheckConfig {
66
- /**
67
- * Logger instance for health check operations
68
- */
69
- logger?: LoggerInstanceManager;
70
- /**
71
- * Redis instances to check - can be multiple
72
- * Key is the instance name, value is the client
73
- */
74
- redis?: Record<string, RedisClient>;
75
- /**
76
- * Sequelize database instance to check
77
- */
78
- sequelize?: SequelizeClient;
79
- /**
80
- * Elasticsearch instance to check
81
- */
82
- elasticsearch?: ElasticsearchClient;
83
- /**
84
- * RabbitMQ instance to check
85
- */
86
- rabbitmq?: RabbitMQClient;
87
- /**
88
- * Custom health checks to run
89
- */
90
- customChecks?: NamedHealthCheck[];
91
- }
92
- /**
93
- * Configuration for liveness probe
94
- * Liveness indicates if the application is running and not deadlocked
95
- */
96
- interface LivenessConfig extends ResourceCheckConfig {
97
- /**
98
- * Timeout for liveness checks in milliseconds
99
- * @default 5000
100
- */
101
- timeout?: number;
102
- }
103
- /**
104
- * Configuration for readiness probe
105
- * Readiness indicates if the application is ready to serve traffic
106
- */
107
- interface ReadinessConfig extends ResourceCheckConfig {
108
- /**
109
- * Timeout for readiness checks in milliseconds
110
- * @default 10000
111
- */
112
- timeout?: number;
113
- }
114
- /**
115
- * Graceful shutdown hook
116
- * @returns Promise that resolves when cleanup is complete
117
- */
118
- type ShutdownHook = () => Promise<void>;
119
- /**
120
- * Named shutdown hook
121
- */
122
- interface NamedShutdownHook {
123
- name: string;
124
- hook: ShutdownHook;
125
- }
126
- /**
127
- * Configuration for graceful shutdown
128
- */
129
- interface GracefulShutdownConfig {
130
- /**
131
- * Logger instance
132
- */
133
- logger?: LoggerInstanceManager;
134
- /**
135
- * Timeout before forced shutdown in milliseconds
136
- * @default 30000
137
- */
138
- timeout?: number;
139
- /**
140
- * Custom shutdown hooks to run on termination
141
- */
142
- shutdownHooks?: NamedShutdownHook[];
143
- /**
144
- * Signals to listen for
145
- * @default ['SIGTERM', 'SIGINT']
146
- */
147
- signals?: NodeJS.Signals[];
148
- /**
149
- * Whether to send failure during shutdown
150
- * @default true
151
- */
152
- sendFailuresDuringShutdown?: boolean;
153
- }
154
- //#endregion
155
- export { ElasticsearchClient, GracefulShutdownConfig, HealthCheck, HealthCheckResult, HealthStatus, LivenessConfig, NamedHealthCheck, NamedShutdownHook, RabbitMQClient, ReadinessConfig, RedisClient, ResourceCheckConfig, SequelizeClient, ShutdownHook };
156
- //# sourceMappingURL=types.d.cts.map
@@ -1,156 +0,0 @@
1
- import { LoggerInstanceManager } from "@autofleet/logger";
2
-
3
- //#region src/health-check/types.d.ts
4
-
5
- /**
6
- * Health check function that returns health status
7
- * @returns Promise that resolves on success or rejects with error message
8
- */
9
- type HealthCheck = () => Promise<void>;
10
- /**
11
- * Named health check with identifier
12
- */
13
- interface NamedHealthCheck {
14
- name: string;
15
- check: HealthCheck;
16
- }
17
- /**
18
- * Health check result for a single check
19
- */
20
- interface HealthCheckResult {
21
- name: string;
22
- status: "pass" | "fail";
23
- error?: string;
24
- duration: number;
25
- }
26
- /**
27
- * Overall health status response
28
- */
29
- interface HealthStatus {
30
- status: "pass" | "fail";
31
- timestamp: string;
32
- checks: HealthCheckResult[];
33
- duration: number;
34
- }
35
- /**
36
- * Redis client interface - supports multiple instances
37
- */
38
- interface RedisClient {
39
- ping: () => Promise<string | void>;
40
- }
41
- /**
42
- * Sequelize database interface
43
- */
44
- interface SequelizeClient {
45
- query(sql: string | {
46
- query: string;
47
- values: unknown[];
48
- }): Promise<any>;
49
- }
50
- /**
51
- * Elasticsearch client interface
52
- */
53
- interface ElasticsearchClient {
54
- ping: () => Promise<boolean>;
55
- }
56
- /**
57
- * RabbitMQ client interface
58
- */
59
- interface RabbitMQClient {
60
- isConnected: () => Promise<boolean> | boolean;
61
- }
62
- /**
63
- * Configuration for resource checkers
64
- */
65
- interface ResourceCheckConfig {
66
- /**
67
- * Logger instance for health check operations
68
- */
69
- logger?: LoggerInstanceManager;
70
- /**
71
- * Redis instances to check - can be multiple
72
- * Key is the instance name, value is the client
73
- */
74
- redis?: Record<string, RedisClient>;
75
- /**
76
- * Sequelize database instance to check
77
- */
78
- sequelize?: SequelizeClient;
79
- /**
80
- * Elasticsearch instance to check
81
- */
82
- elasticsearch?: ElasticsearchClient;
83
- /**
84
- * RabbitMQ instance to check
85
- */
86
- rabbitmq?: RabbitMQClient;
87
- /**
88
- * Custom health checks to run
89
- */
90
- customChecks?: NamedHealthCheck[];
91
- }
92
- /**
93
- * Configuration for liveness probe
94
- * Liveness indicates if the application is running and not deadlocked
95
- */
96
- interface LivenessConfig extends ResourceCheckConfig {
97
- /**
98
- * Timeout for liveness checks in milliseconds
99
- * @default 5000
100
- */
101
- timeout?: number;
102
- }
103
- /**
104
- * Configuration for readiness probe
105
- * Readiness indicates if the application is ready to serve traffic
106
- */
107
- interface ReadinessConfig extends ResourceCheckConfig {
108
- /**
109
- * Timeout for readiness checks in milliseconds
110
- * @default 10000
111
- */
112
- timeout?: number;
113
- }
114
- /**
115
- * Graceful shutdown hook
116
- * @returns Promise that resolves when cleanup is complete
117
- */
118
- type ShutdownHook = () => Promise<void>;
119
- /**
120
- * Named shutdown hook
121
- */
122
- interface NamedShutdownHook {
123
- name: string;
124
- hook: ShutdownHook;
125
- }
126
- /**
127
- * Configuration for graceful shutdown
128
- */
129
- interface GracefulShutdownConfig {
130
- /**
131
- * Logger instance
132
- */
133
- logger?: LoggerInstanceManager;
134
- /**
135
- * Timeout before forced shutdown in milliseconds
136
- * @default 30000
137
- */
138
- timeout?: number;
139
- /**
140
- * Custom shutdown hooks to run on termination
141
- */
142
- shutdownHooks?: NamedShutdownHook[];
143
- /**
144
- * Signals to listen for
145
- * @default ['SIGTERM', 'SIGINT']
146
- */
147
- signals?: NodeJS.Signals[];
148
- /**
149
- * Whether to send failure during shutdown
150
- * @default true
151
- */
152
- sendFailuresDuringShutdown?: boolean;
153
- }
154
- //#endregion
155
- export { ElasticsearchClient, GracefulShutdownConfig, HealthCheck, HealthCheckResult, HealthStatus, LivenessConfig, NamedHealthCheck, NamedShutdownHook, RabbitMQClient, ReadinessConfig, RedisClient, ResourceCheckConfig, SequelizeClient, ShutdownHook };
156
- //# sourceMappingURL=types.d.ts.map