@fluojs/terminus 1.0.3 → 1.0.4

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.ko.md CHANGED
@@ -30,8 +30,6 @@ Redis indicator subpath를 사용할 때만 선택적 peer를 설치하세요.
30
30
  pnpm add @fluojs/redis ioredis
31
31
  ```
32
32
 
33
- `path`로 health endpoint를 custom path 아래에 mount할 수 있고, `readinessChecks`로 애플리케이션별 readiness logic을 Terminus indicator 및 platform readiness check와 합성할 수 있습니다.
34
-
35
33
  ## 사용 시점
36
34
 
37
35
  - 외부 의존성(데이터베이스, Redis, API 등)의 상태를 애플리케이션 헬스 체크 결과에 포함해야 할 때.
@@ -74,7 +72,7 @@ class AppModule {}
74
72
 
75
73
  ### DI 기반 인디케이터
76
74
 
77
- Redis나 DB 클라이언트와 같이 DI 컨테이너의 의존성이 필요한 인디케이터를 사용할 때는, 모듈 로드 시점에 피어 의존성을 import하지 않도록 제공되는 provider 팩토리를 사용하세요.
75
+ Redis나 DB 클라이언트와 같이 DI 컨테이너의 의존성이 필요한 인디케이터를 사용할 때는, 모듈 로드 시점에 피어 의존성을 import하지 않도록 문서화된 provider 팩토리를 사용하세요. 이 helper들은 `TerminusModule.forRoot({ indicatorProviders })`에 전달할 indicator provider entry를 만들며 module facade를 대체하지 않습니다.
78
76
 
79
77
  ```typescript
80
78
  import { TerminusModule } from '@fluojs/terminus';
@@ -119,6 +117,8 @@ TerminusModule.forRoot({
119
117
  });
120
118
  ```
121
119
 
120
+ `path`로 health endpoint를 custom path 아래에 mount할 수 있고, `readinessChecks`로 애플리케이션별 readiness logic을 Terminus indicator 및 platform readiness check와 합성할 수 있습니다.
121
+
122
122
  ### 실패 시맨틱
123
123
 
124
124
  인디케이터가 실패하면 `HealthCheckError`를 던집니다. `TerminusHealthService`는 이 실패들을 모아 보고서를 작성합니다.
@@ -154,7 +154,7 @@ TerminusModule.forRoot({
154
154
 
155
155
  - `runHealthCheck(...)`, `assertHealthCheck(...)`: 직접 aggregation/testing helper입니다.
156
156
  - `TERMINUS_HEALTH_INDICATORS`, `TERMINUS_INDICATOR_PROVIDER_TOKENS`: 등록된 indicator와 provider token을 위한 DI token입니다.
157
- - Built-in indicator는 `create*HealthIndicator()` 및 `create*HealthIndicatorProvider()` helper도 노출합니다.
157
+ - Built-in indicator는 `create*HealthIndicator()` 및 `create*HealthIndicatorProvider()` helper도 노출합니다. Provider helper는 `indicatorProviders`를 위한 의도적인 DI composition 예외이며, 애플리케이션 등록은 계속 `TerminusModule.forRoot(...)`를 사용해야 합니다.
158
158
 
159
159
  ### `@fluojs/terminus/redis`
160
160
 
package/README.md CHANGED
@@ -72,7 +72,7 @@ The package provides several indicators out of the box:
72
72
 
73
73
  ### DI-Backed Indicators
74
74
 
75
- To use indicators that require dependencies from the DI container (like Redis or Database clients) without importing peer dependencies at module load time, use the provider factories.
75
+ To use indicators that require dependencies from the DI container (like Redis or Database clients) without importing peer dependencies at module load time, use the documented provider factories. These helpers create indicator provider entries for `TerminusModule.forRoot({ indicatorProviders })`; they do not replace the module facade.
76
76
 
77
77
  ```typescript
78
78
  import { TerminusModule } from '@fluojs/terminus';
@@ -154,7 +154,7 @@ When an indicator fails, it throws a `HealthCheckError`. The `TerminusHealthServ
154
154
 
155
155
  - `runHealthCheck(...)`, `assertHealthCheck(...)`: Direct aggregation/testing helpers.
156
156
  - `TERMINUS_HEALTH_INDICATORS`, `TERMINUS_INDICATOR_PROVIDER_TOKENS`: DI tokens for registered indicators and provider tokens.
157
- - Built-in indicators also expose `create*HealthIndicator()` and `create*HealthIndicatorProvider()` helpers.
157
+ - Built-in indicators also expose `create*HealthIndicator()` and `create*HealthIndicatorProvider()` helpers. Provider helpers are intentional DI-composition exceptions for `indicatorProviders`, while application registration should still go through `TerminusModule.forRoot(...)`.
158
158
 
159
159
  ### `@fluojs/terminus/redis`
160
160
 
@@ -1,17 +1,28 @@
1
1
  import type { Provider } from '@fluojs/di';
2
2
  import type { HealthIndicator, HealthIndicatorResult } from '../types.js';
3
+ /** Snapshot returned by a memory usage sampler. */
4
+ export interface MemoryUsageSnapshot {
5
+ arrayBuffers: number;
6
+ external: number;
7
+ heapTotal: number;
8
+ heapUsed: number;
9
+ rss: number;
10
+ }
11
+ /** Function that samples runtime memory usage for `MemoryHealthIndicator`. */
12
+ export type MemoryUsageSampler = () => MemoryUsageSnapshot;
3
13
  /** Options for checking process heap and RSS thresholds. */
4
14
  export interface MemoryHealthIndicatorOptions {
5
15
  heapUsedThresholdBytes?: number;
6
16
  heapUsedThresholdRatio?: number;
7
17
  key?: string;
18
+ memoryUsage?: MemoryUsageSampler;
8
19
  rssThresholdBytes?: number;
9
20
  }
10
21
  /**
11
22
  * Create a process-memory health indicator.
12
23
  *
13
24
  * @param options Optional heap and RSS thresholds plus an indicator key override.
14
- * @returns A health indicator backed by `process.memoryUsage()`.
25
+ * @returns A health indicator backed by the Node runtime memory sampler.
15
26
  */
16
27
  export declare function createMemoryHealthIndicator(options?: MemoryHealthIndicatorOptions): HealthIndicator;
17
28
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/indicators/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE1E,4DAA4D;AAC5D,MAAM,WAAW,4BAA4B;IAC3C,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAYD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,4BAAiC,GAAG,eAAe,CAEvG;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,GAAE,4BAAiC,GAAG,QAAQ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,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEJ,OAAO,GAAE,4BAAiC;IAIjE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAiCzD"}
@@ -1,4 +1,9 @@
1
1
  import { createDownResult, createUpResult, resolveIndicatorKey, throwHealthCheckError } from './utils.js';
2
+ import { readNodeMemoryUsage } from '../node-runtime.js';
3
+
4
+ /** Snapshot returned by a memory usage sampler. */
5
+
6
+ /** Function that samples runtime memory usage for `MemoryHealthIndicator`. */
2
7
 
3
8
  /** Options for checking process heap and RSS thresholds. */
4
9
 
@@ -14,7 +19,7 @@ function exceedsRatioThreshold(used, total, threshold) {
14
19
  * Create a process-memory health indicator.
15
20
  *
16
21
  * @param options Optional heap and RSS thresholds plus an indicator key override.
17
- * @returns A health indicator backed by `process.memoryUsage()`.
22
+ * @returns A health indicator backed by the Node runtime memory sampler.
18
23
  */
19
24
  export function createMemoryHealthIndicator(options = {}) {
20
25
  return new MemoryHealthIndicator(options);
@@ -44,7 +49,7 @@ export class MemoryHealthIndicator {
44
49
  async check(key) {
45
50
  const indicatorKey = resolveIndicatorKey('memory', this.options.key ?? key);
46
51
  const heapRatioThreshold = this.options.heapUsedThresholdRatio ?? DEFAULT_HEAP_RATIO_THRESHOLD;
47
- const usage = process.memoryUsage();
52
+ const usage = (this.options.memoryUsage ?? readNodeMemoryUsage)();
48
53
  const usageDetails = {
49
54
  arrayBuffers: usage.arrayBuffers,
50
55
  external: usage.external,
@@ -0,0 +1,11 @@
1
+ interface NodeMemoryUsageSnapshot {
2
+ arrayBuffers: number;
3
+ external: number;
4
+ heapTotal: number;
5
+ heapUsed: number;
6
+ rss: number;
7
+ }
8
+ /** Read Node.js process memory usage through the Terminus Node runtime seam. */
9
+ export declare function readNodeMemoryUsage(): NodeMemoryUsageSnapshot;
10
+ export {};
11
+ //# sourceMappingURL=node-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-runtime.d.ts","sourceRoot":"","sources":["../src/node-runtime.ts"],"names":[],"mappings":"AAAA,UAAU,uBAAuB;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAkBD,gFAAgF;AAChF,wBAAgB,mBAAmB,IAAI,uBAAuB,CAQ7D"}
@@ -0,0 +1,13 @@
1
+ function resolveNodeProcess() {
2
+ const runtimeGlobal = globalThis;
3
+ return runtimeGlobal.process;
4
+ }
5
+
6
+ /** Read Node.js process memory usage through the Terminus Node runtime seam. */
7
+ export function readNodeMemoryUsage() {
8
+ const memoryUsage = resolveNodeProcess()?.memoryUsage;
9
+ if (typeof memoryUsage !== 'function') {
10
+ throw new Error('Node.js process.memoryUsage() is not available in this runtime.');
11
+ }
12
+ return memoryUsage();
13
+ }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "liveness",
10
10
  "health-check"
11
11
  ],
12
- "version": "1.0.3",
12
+ "version": "1.0.4",
13
13
  "private": false,
14
14
  "license": "MIT",
15
15
  "repository": {
@@ -45,14 +45,14 @@
45
45
  ],
46
46
  "dependencies": {
47
47
  "@fluojs/core": "^1.0.3",
48
- "@fluojs/di": "^1.0.3",
48
+ "@fluojs/di": "^1.1.0",
49
49
  "@fluojs/http": "^1.1.0",
50
- "@fluojs/runtime": "^1.1.1"
50
+ "@fluojs/runtime": "^1.1.6"
51
51
  },
52
52
  "peerDependencies": {
53
- "@fluojs/drizzle": "^1.0.1",
54
- "@fluojs/prisma": "^1.0.1",
55
- "@fluojs/redis": "^1.0.0"
53
+ "@fluojs/drizzle": "^1.0.2",
54
+ "@fluojs/prisma": "^1.0.2",
55
+ "@fluojs/redis": "^1.0.1"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "@fluojs/drizzle": {
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "devDependencies": {
69
69
  "vitest": "^3.2.4",
70
- "@fluojs/testing": "^1.0.3"
70
+ "@fluojs/testing": "^1.0.5"
71
71
  },
72
72
  "scripts": {
73
73
  "prebuild": "node ../../tooling/scripts/clean-dist.mjs",