@nexusts/resilience 0.7.9 → 0.8.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.
- package/dist/admin.module.d.ts +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +140 -2
- package/dist/index.js.map +6 -5
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -13,4 +13,6 @@ export { CircuitBreaker, CircuitOpenError } from "./circuit-breaker.js";
|
|
|
13
13
|
export { Bulkhead, BulkheadFullError } from "./bulkhead.js";
|
|
14
14
|
export { ResilienceService } from "./resilience.service.js";
|
|
15
15
|
export { ResilienceModule } from "./resilience.module.js";
|
|
16
|
+
export { ResilienceAdminModule } from "./admin.module.js";
|
|
17
|
+
export type { ResilienceAdminConfig } from "./admin.module.js";
|
|
16
18
|
export { Retry, CircuitBreaker as CircuitBreakerDecorator, Bulkhead as BulkheadDecorator, Resilient, applyResilience, getMethodRetry, getMethodCircuit, getMethodBulkhead, getMethodResilient, setResilienceService, getResilienceService, } from "./decorators/index.js";
|
package/dist/index.js
CHANGED
|
@@ -478,7 +478,7 @@ ResilienceService = __legacyDecorateClassTS([
|
|
|
478
478
|
])
|
|
479
479
|
], ResilienceService);
|
|
480
480
|
// packages/resilience/src/resilience.module.ts
|
|
481
|
-
import { Module } from "@nexusts/core";
|
|
481
|
+
import { Module, setControllerMethodHook } from "@nexusts/core";
|
|
482
482
|
|
|
483
483
|
// packages/resilience/src/decorators/index.ts
|
|
484
484
|
import"reflect-metadata";
|
|
@@ -505,6 +505,31 @@ function makeMethodDecorator(key, extract) {
|
|
|
505
505
|
};
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
|
+
function getResilientMetadata(target, propertyKey) {
|
|
509
|
+
const resilient = getMethodResilient(target, propertyKey);
|
|
510
|
+
const retry2 = resilient?.retry ?? getMethodRetry(target, propertyKey);
|
|
511
|
+
const circuit = resilient?.circuit ?? getMethodCircuit(target, propertyKey);
|
|
512
|
+
const bulkhead = resilient?.bulkhead ?? getMethodBulkhead(target, propertyKey);
|
|
513
|
+
return { retry: retry2, circuit, bulkhead };
|
|
514
|
+
}
|
|
515
|
+
function makeResilientWrapper(original, resolveMeta) {
|
|
516
|
+
return function(...args) {
|
|
517
|
+
const meta = resolveMeta();
|
|
518
|
+
if (!meta.retry && !meta.circuit && !meta.bulkhead) {
|
|
519
|
+
return original.apply(this, args);
|
|
520
|
+
}
|
|
521
|
+
const svc = getResilienceService();
|
|
522
|
+
if (!svc) {
|
|
523
|
+
return original.apply(this, args);
|
|
524
|
+
}
|
|
525
|
+
const name = original.name || "anonymous";
|
|
526
|
+
const fn = () => original.apply(this, args);
|
|
527
|
+
const runOnce = () => meta.bulkhead ? svc.getOrCreateBulkhead(name, meta.bulkhead).execute(fn) : fn();
|
|
528
|
+
const runWithCircuit = () => meta.circuit ? svc.getOrCreateCircuit(name, meta.circuit).execute(runOnce) : runOnce();
|
|
529
|
+
const runWithRetry = () => meta.retry ? svc.retry(runWithCircuit, meta.retry) : runWithCircuit();
|
|
530
|
+
return runWithRetry();
|
|
531
|
+
};
|
|
532
|
+
}
|
|
508
533
|
var _resilienceService = null;
|
|
509
534
|
function setResilienceService(svc) {
|
|
510
535
|
_resilienceService = svc;
|
|
@@ -562,6 +587,13 @@ function applyResilience(target, propertyKey, descriptor, svc) {
|
|
|
562
587
|
// packages/resilience/src/resilience.module.ts
|
|
563
588
|
class ResilienceModule {
|
|
564
589
|
static forRoot(config = {}) {
|
|
590
|
+
setControllerMethodHook((proto, propertyKey, handler) => {
|
|
591
|
+
const meta = getResilientMetadata(proto, propertyKey);
|
|
592
|
+
if (!meta.retry && !meta.circuit && !meta.bulkhead)
|
|
593
|
+
return handler;
|
|
594
|
+
return makeResilientWrapper(handler, () => getResilientMetadata(proto, propertyKey));
|
|
595
|
+
});
|
|
596
|
+
|
|
565
597
|
class ConfiguredResilienceModule {
|
|
566
598
|
}
|
|
567
599
|
ConfiguredResilienceModule = __legacyDecorateClassTS([
|
|
@@ -598,6 +630,111 @@ ResilienceModule = __legacyDecorateClassTS([
|
|
|
598
630
|
exports: [ResilienceService, ResilienceService.TOKEN]
|
|
599
631
|
})
|
|
600
632
|
], ResilienceModule);
|
|
633
|
+
// packages/resilience/src/admin.module.ts
|
|
634
|
+
import { Controller, Get, Post, Param, Inject as Inject2, Module as Module2 } from "@nexusts/core";
|
|
635
|
+
class ResilienceAdminModule {
|
|
636
|
+
static forRoot(config = {}) {
|
|
637
|
+
const prefix = config.prefix ?? "/resilience";
|
|
638
|
+
|
|
639
|
+
class ResilienceAdminController {
|
|
640
|
+
_svc;
|
|
641
|
+
constructor(svc) {
|
|
642
|
+
this._svc = svc;
|
|
643
|
+
}
|
|
644
|
+
listCircuits() {
|
|
645
|
+
return this._svc.listCircuits();
|
|
646
|
+
}
|
|
647
|
+
listBulkheads() {
|
|
648
|
+
return this._svc.listBulkheads();
|
|
649
|
+
}
|
|
650
|
+
forceOpen(name) {
|
|
651
|
+
const cb = this._svc.getCircuit(name);
|
|
652
|
+
if (!cb) {
|
|
653
|
+
return { status: 404, body: { error: `Circuit "${name}" not found` } };
|
|
654
|
+
}
|
|
655
|
+
cb.forceOpen();
|
|
656
|
+
return { name, state: "open" };
|
|
657
|
+
}
|
|
658
|
+
forceClose(name) {
|
|
659
|
+
const cb = this._svc.getCircuit(name);
|
|
660
|
+
if (!cb) {
|
|
661
|
+
return { status: 404, body: { error: `Circuit "${name}" not found` } };
|
|
662
|
+
}
|
|
663
|
+
cb.forceClose();
|
|
664
|
+
return { name, state: "closed" };
|
|
665
|
+
}
|
|
666
|
+
reset(name) {
|
|
667
|
+
const cb = this._svc.getCircuit(name);
|
|
668
|
+
if (!cb) {
|
|
669
|
+
return { status: 404, body: { error: `Circuit "${name}" not found` } };
|
|
670
|
+
}
|
|
671
|
+
cb.reset();
|
|
672
|
+
return { name, state: "closed" };
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
__legacyDecorateClassTS([
|
|
676
|
+
Get("/circuits"),
|
|
677
|
+
__legacyMetadataTS("design:type", Function),
|
|
678
|
+
__legacyMetadataTS("design:paramtypes", []),
|
|
679
|
+
__legacyMetadataTS("design:returntype", undefined)
|
|
680
|
+
], ResilienceAdminController.prototype, "listCircuits", null);
|
|
681
|
+
__legacyDecorateClassTS([
|
|
682
|
+
Get("/bulkheads"),
|
|
683
|
+
__legacyMetadataTS("design:type", Function),
|
|
684
|
+
__legacyMetadataTS("design:paramtypes", []),
|
|
685
|
+
__legacyMetadataTS("design:returntype", undefined)
|
|
686
|
+
], ResilienceAdminController.prototype, "listBulkheads", null);
|
|
687
|
+
__legacyDecorateClassTS([
|
|
688
|
+
Post("/circuits/:name/force-open"),
|
|
689
|
+
__legacyDecorateParamTS(0, Param("name")),
|
|
690
|
+
__legacyMetadataTS("design:type", Function),
|
|
691
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
692
|
+
String
|
|
693
|
+
]),
|
|
694
|
+
__legacyMetadataTS("design:returntype", undefined)
|
|
695
|
+
], ResilienceAdminController.prototype, "forceOpen", null);
|
|
696
|
+
__legacyDecorateClassTS([
|
|
697
|
+
Post("/circuits/:name/force-close"),
|
|
698
|
+
__legacyDecorateParamTS(0, Param("name")),
|
|
699
|
+
__legacyMetadataTS("design:type", Function),
|
|
700
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
701
|
+
String
|
|
702
|
+
]),
|
|
703
|
+
__legacyMetadataTS("design:returntype", undefined)
|
|
704
|
+
], ResilienceAdminController.prototype, "forceClose", null);
|
|
705
|
+
__legacyDecorateClassTS([
|
|
706
|
+
Post("/circuits/:name/reset"),
|
|
707
|
+
__legacyDecorateParamTS(0, Param("name")),
|
|
708
|
+
__legacyMetadataTS("design:type", Function),
|
|
709
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
710
|
+
String
|
|
711
|
+
]),
|
|
712
|
+
__legacyMetadataTS("design:returntype", undefined)
|
|
713
|
+
], ResilienceAdminController.prototype, "reset", null);
|
|
714
|
+
ResilienceAdminController = __legacyDecorateClassTS([
|
|
715
|
+
Controller(prefix),
|
|
716
|
+
__legacyDecorateParamTS(0, Inject2(ResilienceService.TOKEN)),
|
|
717
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
718
|
+
typeof ResilienceService === "undefined" ? Object : ResilienceService
|
|
719
|
+
])
|
|
720
|
+
], ResilienceAdminController);
|
|
721
|
+
Object.defineProperty(ResilienceAdminController, "name", {
|
|
722
|
+
value: "ResilienceAdminController"
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
class ConfiguredResilienceAdminModule {
|
|
726
|
+
}
|
|
727
|
+
ConfiguredResilienceAdminModule = __legacyDecorateClassTS([
|
|
728
|
+
Module2({
|
|
729
|
+
controllers: [ResilienceAdminController]
|
|
730
|
+
})
|
|
731
|
+
], ConfiguredResilienceAdminModule);
|
|
732
|
+
Object.defineProperty(ConfiguredResilienceAdminModule, "name", {
|
|
733
|
+
value: "ConfiguredResilienceAdminModule"
|
|
734
|
+
});
|
|
735
|
+
return ConfiguredResilienceAdminModule;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
601
738
|
export {
|
|
602
739
|
setResilienceService,
|
|
603
740
|
retry,
|
|
@@ -612,6 +749,7 @@ export {
|
|
|
612
749
|
Resilient,
|
|
613
750
|
ResilienceService,
|
|
614
751
|
ResilienceModule,
|
|
752
|
+
ResilienceAdminModule,
|
|
615
753
|
RESILIENCE_META,
|
|
616
754
|
CircuitOpenError,
|
|
617
755
|
CircuitBreaker2 as CircuitBreakerDecorator,
|
|
@@ -621,5 +759,5 @@ export {
|
|
|
621
759
|
Bulkhead
|
|
622
760
|
};
|
|
623
761
|
|
|
624
|
-
//# debugId=
|
|
762
|
+
//# debugId=0E90B0DDA626E48864756E2164756E21
|
|
625
763
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/types.ts", "../src/retry.ts", "../src/circuit-breaker.ts", "../src/bulkhead.ts", "../src/resilience.service.ts", "../src/resilience.module.ts", "../src/decorators/index.ts"],
|
|
3
|
+
"sources": ["../src/types.ts", "../src/retry.ts", "../src/circuit-breaker.ts", "../src/bulkhead.ts", "../src/resilience.service.ts", "../src/resilience.module.ts", "../src/decorators/index.ts", "../src/admin.module.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * `nexusjs/resilience` — public types and config.\n *\n * The resilience module groups three classic distributed-systems\n * primitives — retry with backoff, circuit breaker, and bulkhead\n * (concurrency limiter) — under a single, decorator-friendly API.\n * Each primitive can be used as a class, a method decorator, or a\n * standalone function.\n */\n\n// ============================================================================\n// Retry\n// ============================================================================\n\n/** Backoff strategy between retry attempts. */\nexport type BackoffStrategy =\n\t| \"constant\"\n\t| \"linear\"\n\t| \"exponential\"\n\t| \"exponential-jitter\";\n\n/**\n * Predicate: should we retry this error? Default: retry on any\n * non-abort error. Set to a function to filter (e.g. only retry\n * on network errors, not on 4xx HTTP responses).\n */\nexport type RetryOnPredicate = (err: unknown, attempt: number) => boolean;\n\n/** Configuration for `@Retry()` and `retry()`. */\nexport interface RetryConfig {\n\t/** Maximum number of attempts (including the first call). Default: 3. */\n\tattempts?: number;\n\t/** Initial backoff in ms. Default: 100. */\n\tinitialDelay?: number;\n\t/** Max backoff in ms (caps the exponential growth). Default: 30_000. */\n\tmaxDelay?: number;\n\t/** Backoff strategy. Default: \"exponential-jitter\". */\n\tbackoff?: BackoffStrategy;\n\t/** Multiplier for \"linear\" and \"exponential*\". Default: 2. */\n\tmultiplier?: number;\n\t/** Optional: only retry if this predicate returns true. */\n\tretryOn?: RetryOnPredicate;\n\t/**\n\t * Optional: hook called before each retry. Useful for logging\n\t * and metrics.\n\t */\n\tonRetry?: (err: unknown, attempt: number, delayMs: number) => void;\n\t/**\n\t * Optional: hard timeout for the entire retried operation, in ms.\n\t * If the operation takes longer, it is aborted.\n\t */\n\ttimeout?: number;\n}\n\n// ============================================================================\n// Circuit Breaker\n// ============================================================================\n\n/** A circuit breaker's lifecycle state. */\nexport type CircuitState = \"closed\" | \"open\" | \"half-open\";\n\n/** Configuration for `@CircuitBreaker()` and `CircuitBreaker`. */\nexport interface CircuitBreakerConfig {\n\t/**\n\t * Failure ratio (0..1) that opens the circuit. Default: 0.5.\n\t * Open when `failures / (failures + successes) >= threshold` over\n\t * the rolling window.\n\t */\n\tthreshold?: number;\n\t/** Minimum number of calls before the threshold matters. Default: 5. */\n\tminCalls?: number;\n\t/** How long the circuit stays open before going half-open. Default: 30s. */\n\ttimeout?: number;\n\t/** Calls allowed in half-open. Default: 1. */\n\thalfOpenAfter?: number;\n\t/** Predicate: should this error count as a failure? */\n\tisFailure?: (err: unknown) => boolean;\n\t/** Hook on state change. */\n\tonStateChange?: (from: CircuitState, to: CircuitState, name: string) => void;\n\t/** Hook on every call (good for metrics). */\n\tonCall?: (name: string, success: boolean, latencyMs: number) => void;\n\t/**\n\t * Rolling window length for failure ratio, in ms. Default: 60_000.\n\t */\n\twindow?: number;\n}\n\n// ============================================================================\n// Bulkhead\n// ============================================================================\n\n/** Configuration for `Bulkhead`. */\nexport interface BulkheadConfig {\n\t/** Max concurrent executions. Default: 10. */\n\tmaxConcurrent?: number;\n\t/** Max queued callers waiting for a slot. Default: 100. */\n\tmaxQueued?: number;\n\t/** Reject immediately if queue is full (vs. wait for a slot). */\n\trejectOnFull?: boolean;\n\t/** Optional name for logging / metrics. */\n\tname?: string;\n}\n\n/** Result of a bulkhead call. */\nexport type BulkheadOutcome<T> = {\n\tok: boolean;\n\tvalue?: T;\n\terror?: unknown;\n\tqueueMs?: number;\n\texecutionMs?: number;\n};\n\n// ============================================================================\n// Combined decorator: `@Resilient`\n// ============================================================================\n\n/**\n * All three primitives in one decorator. Each section is optional;\n * pass only what you need.\n *\n * @Resilient({\n * retry: { attempts: 3, backoff: \"exponential\" },\n * circuit: { threshold: 0.5, timeout: 30_000 },\n * bulkhead: { maxConcurrent: 5 },\n * })\n * async callExternal() { ... }\n */\nexport interface ResilientConfig {\n\tretry?: RetryConfig;\n\tcircuit?: CircuitBreakerConfig;\n\tbulkhead?: BulkheadConfig;\n}\n\n// ============================================================================\n// Module\n// ============================================================================\n\n/** Top-level config for `ResilienceModule.forRoot()`. */\nexport interface ResilienceConfig {\n\t/**\n\t * Default retry config — used when `@Retry()` is applied without\n\t * explicit options.\n\t */\n\tretry?: RetryConfig;\n\t/**\n\t * Default circuit breaker config — used when `@CircuitBreaker()`\n\t * is applied without explicit options, and as the template for\n\t * circuit breakers created via `getOrCreate()`.\n\t */\n\tcircuit?: CircuitBreakerConfig;\n\t/**\n\t * Default bulkhead config — same as above.\n\t */\n\tbulkhead?: BulkheadConfig;\n}\n\n// ============================================================================\n// Metrics\n// ============================================================================\n\n/** Snapshot of a circuit breaker's current state and stats. */\nexport interface CircuitMetrics {\n\tname: string;\n\tstate: CircuitState;\n\t/** Total calls recorded in the current rolling window. */\n\ttotalCalls: number;\n\t/** Failed calls in the rolling window. */\n\tfailures: number;\n\t/** Successes in the rolling window. */\n\tsuccesses: number;\n\t/** Failure ratio (0..1) in the rolling window. */\n\tfailureRatio: number;\n\t/** Timestamp when the circuit was last opened (0 if never). */\n\topenedAt: number;\n\t/** Milliseconds until the circuit transitions from open → half-open (0 if not open). */\n\tmsUntilHalfOpen: number;\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/** Internal — used by decorators to attach metadata. */\nexport const RESILIENCE_META = Symbol.for(\"nexus:Resilience:Meta\");\n",
|
|
6
6
|
"/**\n * `retry()` — pure function. The same code that powers `@Retry()`\n * — useful when you can't (or don't want to) decorate a method.\n *\n * import { retry } from \"@nexusts/resilience\";\n *\n * const user = await retry(\n * () => fetch(\"https://api.example.com/users/42\").then(r => r.json()),\n * { attempts: 3, backoff: \"exponential-jitter\" },\n * );\n *\n * Error handling:\n * - If the function throws and `retryOn(err)` returns true, the\n * call is retried up to `attempts` times.\n * - The final error is re-thrown to the caller.\n * - AbortError / CancellationError short-circuit immediately.\n */\nimport type { RetryConfig, RetryOnPredicate } from \"./types.js\";\n\nconst DEFAULTS = {\n\tattempts: 3,\n\tinitialDelay: 100,\n\tmaxDelay: 30_000,\n\tbackoff: \"exponential-jitter\" as const,\n\tmultiplier: 2,\n};\n\nconst defaultRetryOn: RetryOnPredicate = (err: unknown) => {\n\tif (err == null) return false;\n\t// Honour explicit aborts.\n\tconst name = (err as { name?: string })?.name ?? \"\";\n\tif (name === \"AbortError\" || name === \"CancellationError\") return false;\n\treturn true;\n};\n\n/** Sleep helper that respects AbortSignal. */\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(signal.reason ?? new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\treturn;\n\t\t}\n\t\tconst id = setTimeout(() => {\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(id);\n\t\t\treject(signal?.reason ?? new DOMException(\"Aborted\", \"AbortError\"));\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\n/**\n * Compute the next backoff delay. Returns ms.\n *\n * constant: initialDelay\n * linear: initialDelay * attempt * multiplier\n * exponential: initialDelay * multiplier^(attempt-1)\n * exponential-jitter: above * (0.5..1.5) random factor\n */\nexport function computeBackoff(\n\tattempt: number,\n\tcfg: Required<Pick<RetryConfig, \"initialDelay\" | \"maxDelay\" | \"backoff\" | \"multiplier\">>,\n): number {\n\tconst { initialDelay, maxDelay, backoff, multiplier } = cfg;\n\tlet raw: number;\n\tswitch (backoff) {\n\t\tcase \"constant\":\n\t\t\traw = initialDelay;\n\t\t\tbreak;\n\t\tcase \"linear\":\n\t\t\traw = initialDelay * attempt;\n\t\t\tbreak;\n\t\tcase \"exponential\":\n\t\t\traw = initialDelay * Math.pow(multiplier, attempt - 1);\n\t\t\tbreak;\n\t\tcase \"exponential-jitter\": {\n\t\t\tconst base = initialDelay * Math.pow(multiplier, attempt - 1);\n\t\t\t// ±50% jitter — full jitter (AWS-style).\n\t\t\traw = Math.random() * base;\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\traw = initialDelay;\n\t}\n\treturn Math.min(raw, maxDelay);\n}\n\n/**\n * Retry `fn` according to `cfg`. Returns the eventual value or\n * re-throws the last error.\n */\nexport async function retry<T>(\n\tfn: (signal: AbortSignal) => Promise<T> | T,\n\tcfg: RetryConfig = {},\n): Promise<T> {\n\tconst attempts = Math.max(1, cfg.attempts ?? DEFAULTS.attempts);\n\tconst initialDelay = cfg.initialDelay ?? DEFAULTS.initialDelay;\n\tconst maxDelay = cfg.maxDelay ?? DEFAULTS.maxDelay;\n\tconst backoff = cfg.backoff ?? DEFAULTS.backoff;\n\tconst multiplier = cfg.multiplier ?? DEFAULTS.multiplier;\n\tconst retryOn = cfg.retryOn ?? defaultRetryOn;\n\tconst onRetry = cfg.onRetry;\n\tconst overallTimeout = cfg.timeout;\n\n\tconst ac = new AbortController();\n\tconst overallTimer = overallTimeout\n\t\t? setTimeout(() => ac.abort(new Error(\"retry: overall timeout exceeded\")), overallTimeout)\n\t\t: undefined;\n\n\tconst normalized = { initialDelay, maxDelay, backoff, multiplier };\n\tlet lastErr: unknown;\n\tfor (let attempt = 1; attempt <= attempts; attempt++) {\n\t\tif (ac.signal.aborted) break;\n\t\ttry {\n\t\t\treturn await fn(ac.signal);\n\t\t} catch (err) {\n\t\t\tlastErr = err;\n\t\t\tif (attempt >= attempts) break;\n\t\t\tif (!retryOn(err, attempt)) break;\n\t\t\tconst delay = computeBackoff(attempt, normalized);\n\t\t\tif (onRetry) {\n\t\t\t\ttry {\n\t\t\t\t\tonRetry(err, attempt, delay);\n\t\t\t\t} catch {\n\t\t\t\t\t/* hook errors must not break the retry */\n\t\t\t\t}\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait sleep(delay, ac.signal);\n\t\t\t} catch (sleepErr) {\n\t\t\t\tlastErr = sleepErr;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (overallTimer) clearTimeout(overallTimer);\n\tthrow lastErr;\n}\n",
|
|
7
7
|
"/**\n * `CircuitBreaker` — a single named circuit. Constructed on demand\n * via `ResilienceService.getOrCreate()` (so multiple parts of your\n * app share one circuit per external dependency), or directly:\n *\n * import { CircuitBreaker } from \"@nexusts/resilience\";\n *\n * const stripe = new CircuitBreaker(\"stripe\", {\n * threshold: 0.5,\n * timeout: 30_000,\n * });\n *\n * const result = await stripe.execute(() => stripeApi.charge(...));\n *\n * State machine:\n *\n * closed ──failures ≥ threshold──▶ open\n * ▲ │\n * │ │ after `timeout` ms\n * │ ▼\n * closed ◀──success── half-open\n * │\n * └─ failure ──▶ open (reset)\n *\n * - `closed`: all calls go through. Track success/failure in a\n * rolling window.\n * - `open`: calls fail-fast with `CircuitOpenError`. After\n * `timeout` ms, transition to `half-open`.\n * - `half-open`: at most `halfOpenAfter` calls are allowed. If any\n * of them fails → back to `open`. If all succeed → back to\n * `closed`.\n */\nimport type { CircuitBreakerConfig, CircuitMetrics, CircuitState } from \"./types.js\";\n\nconst DEFAULTS = {\n\tthreshold: 0.5,\n\tminCalls: 5,\n\ttimeout: 30_000,\n\thalfOpenAfter: 1,\n\twindow: 60_000,\n};\n\nconst defaultIsFailure = (_err: unknown): boolean => true;\n\n/** Thrown when the circuit is open. Callers should treat as \"fail-fast\". */\nexport class CircuitOpenError extends Error {\n\treadonly name = \"CircuitOpenError\";\n\treadonly circuit: string;\n\treadonly nextRetryAt: number;\n\tconstructor(circuit: string, nextRetryAt: number) {\n\t\tsuper(`Circuit \"${circuit}\" is open; retry after ${nextRetryAt}ms`);\n\t\tthis.circuit = circuit;\n\t\tthis.nextRetryAt = nextRetryAt;\n\t}\n}\n\ninterface Sample {\n\tts: number;\n\tok: boolean;\n}\n\nexport class CircuitBreaker {\n\treadonly name: string;\n\treadonly config: Required<Omit<CircuitBreakerConfig, \"onStateChange\" | \"onCall\" | \"isFailure\">> & {\n\t\tisFailure: NonNullable<CircuitBreakerConfig[\"isFailure\"]>;\n\t};\n\tprivate state: CircuitState = \"closed\";\n\tprivate samples: Sample[] = [];\n\tprivate openedAt = 0;\n\tprivate halfOpenInFlight = 0;\n\tprivate halfOpenAllowed = 0;\n\n\tconstructor(name: string, config: CircuitBreakerConfig = {}) {\n\t\tthis.name = name;\n\t\tthis.config = {\n\t\t\tthreshold: config.threshold ?? DEFAULTS.threshold,\n\t\t\tminCalls: config.minCalls ?? DEFAULTS.minCalls,\n\t\t\ttimeout: config.timeout ?? DEFAULTS.timeout,\n\t\t\thalfOpenAfter: config.halfOpenAfter ?? DEFAULTS.halfOpenAfter,\n\t\t\twindow: config.window ?? DEFAULTS.window,\n\t\t\tisFailure: config.isFailure ?? defaultIsFailure,\n\t\t};\n\t}\n\n\tget currentState(): CircuitState {\n\t\t// Lazy transition: if the open timer has elapsed, flip to half-open\n\t\t// before the next call, so the consumer sees the right state.\n\t\tif (\n\t\t\tthis.state === \"open\" &&\n\t\t\tDate.now() - this.openedAt >= this.config.timeout\n\t\t) {\n\t\t\tthis.transition(\"half-open\");\n\t\t\tthis.halfOpenAllowed = this.config.halfOpenAfter;\n\t\t\tthis.halfOpenInFlight = 0;\n\t\t}\n\t\treturn this.state;\n\t}\n\n\t/** Run `fn` through the circuit. Throws `CircuitOpenError` when open. */\n\tasync execute<T>(fn: () => Promise<T> | T): Promise<T> {\n\t\tconst state = this.currentState;\n\n\t\tif (state === \"open\") {\n\t\t\tthrow new CircuitOpenError(this.name, this.openedAt + this.config.timeout);\n\t\t}\n\n\t\t// Concurrency control for half-open.\n\t\tif (state === \"half-open\") {\n\t\t\tif (this.halfOpenInFlight >= this.halfOpenAllowed) {\n\t\t\t\tthrow new CircuitOpenError(this.name, this.openedAt + this.config.timeout);\n\t\t\t}\n\t\t\tthis.halfOpenInFlight += 1;\n\t\t}\n\n\t\tconst start = Date.now();\n\t\tlet ok = false;\n\t\ttry {\n\t\t\tconst result = await fn();\n\t\t\tok = true;\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tconst latency = Date.now() - start;\n\t\t\tthis.record(ok, latency, state);\n\t\t}\n\t}\n\n\t// ===================================================================\n\t// Admin API — manual overrides & inspection\n\t// ===================================================================\n\n\t/**\n\t * Return a snapshot of the circuit's current state and metrics.\n\t * Useful for admin dashboards and monitoring.\n\t */\n\tmetrics(): CircuitMetrics {\n\t\tconst now = Date.now();\n\t\tconst cutoff = now - this.config.window;\n\t\tconst windowSamples = this.samples.filter((s) => s.ts >= cutoff);\n\t\tconst total = windowSamples.length;\n\t\tconst failures = windowSamples.filter((s) => !s.ok).length;\n\t\tconst successes = total - failures;\n\t\tconst ratio = total > 0 ? failures / total : 0;\n\t\tconst openedAt = this.openedAt;\n\t\tconst msUntilHalfOpen =\n\t\t\tthis.state === \"open\"\n\t\t\t\t? Math.max(0, openedAt + this.config.timeout - Date.now())\n\t\t\t\t: 0;\n\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tstate: this.currentState,\n\t\t\ttotalCalls: total,\n\t\t\tfailures,\n\t\t\tsuccesses,\n\t\t\tfailureRatio: ratio,\n\t\t\topenedAt,\n\t\t\tmsUntilHalfOpen,\n\t\t};\n\t}\n\n\t/** Manually open the circuit (overrides normal state machine). */\n\tforceOpen(): void {\n\t\tthis.openedAt = Date.now();\n\t\tthis.halfOpenInFlight = 0;\n\t\tthis.transition(\"open\");\n\t}\n\n\t/** Manually close the circuit (overrides normal state machine). */\n\tforceClose(): void {\n\t\tthis.openedAt = 0;\n\t\tthis.halfOpenInFlight = 0;\n\t\tthis.samples = [];\n\t\tthis.transition(\"closed\");\n\t}\n\n\t/** Reset the circuit to its initial closed state (clears all history). */\n\treset(): void {\n\t\tthis.state = \"closed\";\n\t\tthis.openedAt = 0;\n\t\tthis.halfOpenInFlight = 0;\n\t\tthis.halfOpenAllowed = 0;\n\t\tthis.samples = [];\n\t}\n\n\t// ===================================================================\n\t// Internal\n\t// ===================================================================\n\n\tprivate record(ok: boolean, latency: number, stateAtCall: CircuitState): void {\n\t\t// Fire per-call hook.\n\t\ttry {\n\t\t\tthis._onCall?.(this.name, ok, latency);\n\t\t} catch {\n\t\t\t/* ignore */\n\t\t}\n\n\t\t// Track in the rolling window.\n\t\tconst now = Date.now();\n\t\tthis.samples.push({ ts: now, ok });\n\t\tconst cutoff = now - this.config.window;\n\t\twhile (this.samples.length > 0 && this.samples[0].ts < cutoff) {\n\t\t\tthis.samples.shift();\n\t\t}\n\n\t\t// State transitions.\n\t\tif (stateAtCall === \"half-open\") {\n\t\t\tthis.halfOpenInFlight = Math.max(0, this.halfOpenInFlight - 1);\n\t\t\tif (!ok) {\n\t\t\t\tthis.openedAt = now;\n\t\t\t\tthis.transition(\"open\");\n\t\t\t} else if (this.halfOpenInFlight === 0) {\n\t\t\t\tthis.transition(\"closed\");\n\t\t\t\tthis.samples = [];\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// closed → possibly open\n\t\tif (!ok) {\n\t\t\tconst total = this.samples.length;\n\t\t\tif (total >= this.config.minCalls) {\n\t\t\t\tconst failures = this.samples.filter((s) => !s.ok).length;\n\t\t\t\tconst ratio = failures / total;\n\t\t\t\tif (ratio >= this.config.threshold) {\n\t\t\t\t\tthis.openedAt = now;\n\t\t\t\t\tthis.transition(\"open\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Reset the window on full-success periods so a long-stable\n\t\t\t// upstream doesn't carry stale failures forever.\n\t\t\tif (this.samples.length > this.config.minCalls * 4) {\n\t\t\t\tthis.samples = this.samples.slice(-this.config.minCalls);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate transition(to: CircuitState): void {\n\t\tconst from = this.state;\n\t\tif (from === to) return;\n\t\tthis.state = to;\n\t\t// Hooks are passed in `config`; we only know about them via\n\t\t// the outer constructor so we keep them on a parallel field.\n\t\t// (The hook API is set in the ResilienceService which owns\n\t\t// the onStateChange list.)\n\t\tthis.fireHook(from, to);\n\t}\n\n\t/** Set by ResilienceService — fires on each transition. */\n\t_onStateChange?: (from: CircuitState, to: CircuitState, name: string) => void;\n\t_onCall?: (name: string, success: boolean, latencyMs: number) => void;\n\tprivate fireHook(from: CircuitState, to: CircuitState): void {\n\t\ttry {\n\t\t\tthis._onStateChange?.(from, to, this.name);\n\t\t} catch {\n\t\t\t/* ignore */\n\t\t}\n\t}\n}\n",
|
|
8
8
|
"/**\n * `Bulkhead` — concurrency limiter with optional queue.\n *\n * import { Bulkhead } from \"@nexusts/resilience\";\n *\n * const api = new Bulkhead({ maxConcurrent: 5, maxQueued: 100 });\n *\n * const result = await api.execute(() => fetch(\"...\"));\n *\n * Behavior:\n * - `maxConcurrent`: how many `execute()` calls may be in-flight at once.\n * - `maxQueued`: how many additional callers may wait in the queue\n * for a free slot.\n * - `rejectOnFull` (default false): when the queue is full, reject\n * immediately with `BulkheadFullError` instead of waiting.\n *\n * The bulkhead is fair: callers are released in FIFO order. Each\n * waiter carries its own resolver; when a slot frees up we wake the\n * next waiter in the queue, who then re-enters and runs its function.\n */\nimport type { BulkheadConfig } from \"./types.js\";\n\nconst DEFAULTS = {\n\tmaxConcurrent: 10,\n\tmaxQueued: 100,\n\trejectOnFull: false,\n};\n\n/** Thrown when `rejectOnFull` is set and the queue is at capacity. */\nexport class BulkheadFullError extends Error {\n\treadonly name = \"BulkheadFullError\";\n\tconstructor(public readonly name_: string) {\n\t\tsuper(`Bulkhead \"${name_}\" is at capacity`);\n\t}\n}\n\n/** A queued caller. Resolves when this caller gets a slot. */\ninterface SlotToken {\n\t/** Acquired by the drain loop when a slot opens. */\n\tacquired: boolean;\n\t/** Cancelled before we got a slot. */\n\tcancelled: boolean;\n\tresolve: () => void;\n\treject: (e: unknown) => void;\n}\n\nexport class Bulkhead {\n\treadonly name: string;\n\treadonly config: Required<Omit<BulkheadConfig, \"name\">>;\n\n\tprivate inFlight = 0;\n\tprivate queue: SlotToken[] = [];\n\n\tconstructor(config: BulkheadConfig = {}) {\n\t\tthis.name = config.name ?? \"bulkhead\";\n\t\tthis.config = {\n\t\t\tmaxConcurrent: config.maxConcurrent ?? DEFAULTS.maxConcurrent,\n\t\t\tmaxQueued: config.maxQueued ?? DEFAULTS.maxQueued,\n\t\t\trejectOnFull: config.rejectOnFull ?? DEFAULTS.rejectOnFull,\n\t\t};\n\t}\n\n\tget stats(): { inFlight: number; queued: number } {\n\t\treturn { inFlight: this.inFlight, queued: this.queue.length };\n\t}\n\n\t/** Run `fn` through the bulkhead. */\n\tasync execute<T>(fn: () => Promise<T> | T): Promise<T> {\n\t\t// Fast path: a slot is free.\n\t\tif (this.inFlight < this.config.maxConcurrent) {\n\t\t\tthis.inFlight += 1;\n\t\t\ttry {\n\t\t\t\treturn await fn();\n\t\t\t} finally {\n\t\t\t\tthis.inFlight -= 1;\n\t\t\t\tthis.drain();\n\t\t\t}\n\t\t}\n\n\t\t// No slot — wait for one.\n\t\tif (this.queue.length >= this.config.maxQueued) {\n\t\t\tthrow new BulkheadFullError(this.name);\n\t\t}\n\n\t\tconst token = this.enqueue();\n\t\ttry {\n\t\t\tawait token.acquire();\n\t\t} catch (err) {\n\t\t\t// Cancelled or aborted — drop the token and re-throw.\n\t\t\tthrow err;\n\t\t}\n\t\t// Slot acquired. Run and release on completion.\n\t\tthis.inFlight += 1;\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} finally {\n\t\t\tthis.inFlight -= 1;\n\t\t\tthis.drain();\n\t\t}\n\t}\n\n\t/** Allocate a slot token, joining the FIFO queue. */\n\tprivate enqueue(): SlotToken & { acquire(): Promise<void> } {\n\t\tlet resolve!: () => void;\n\t\tlet reject!: (e: unknown) => void;\n\t\tconst promise = new Promise<void>((res, rej) => {\n\t\t\tresolve = res;\n\t\t\treject = rej;\n\t\t});\n\t\tconst token: SlotToken = {\n\t\t\tacquired: false,\n\t\t\tcancelled: false,\n\t\t\tresolve,\n\t\t\treject,\n\t\t};\n\t\tthis.queue.push(token);\n\t\treturn Object.assign(promise as never, {\n\t\t\tacquire: () => promise,\n\t\t\tcancel: () => {\n\t\t\t\tif (token.acquired) return;\n\t\t\t\ttoken.cancelled = true;\n\t\t\t\ttoken.reject(new DOMException(\"Cancelled\", \"AbortError\"));\n\t\t\t},\n\t\t});\n\t}\n\n\t/** Release a slot by waking the next waiter. Idempotent. */\n\tprivate drain(): void {\n\t\twhile (\n\t\t\tthis.inFlight < this.config.maxConcurrent &&\n\t\t\tthis.queue.length > 0\n\t\t) {\n\t\t\tconst next = this.queue.shift()!;\n\t\t\tif (next.cancelled) continue;\n\t\t\tnext.acquired = true;\n\t\t\tnext.resolve();\n\t\t\treturn; // Only one slot opens per drain call.\n\t\t}\n\t}\n}\n",
|
|
9
9
|
"/**\n * `ResilienceService` — owns the named circuit-breaker and bulkhead\n * registry. Exposed via DI so multiple parts of an app can share\n * the same circuit for an external dependency.\n *\n * constructor(@Inject(ResilienceService.TOKEN) private r: ResilienceService) {}\n *\n * const cb = this.r.getOrCreateCircuit(\"stripe\", { threshold: 0.5 });\n * const result = await cb.execute(() => stripeApi.charge(...));\n *\n * The service also holds the *default* config (RetryConfig,\n * CircuitBreakerConfig, BulkheadConfig) used by the decorators\n * when no per-call options are given.\n */\nimport \"reflect-metadata\";\nimport { Inject, Injectable } from \"@nexusts/core\";\nimport { CircuitBreaker } from \"./circuit-breaker.js\";\nimport { Bulkhead } from \"./bulkhead.js\";\nimport { retry } from \"./retry.js\";\nimport type {\n\tBackoffStrategy,\n\tBulkheadConfig,\n\tCircuitBreakerConfig,\n\tResilienceConfig,\n\tRetryConfig,\n} from \"./types.js\";\n\n@Injectable()\nexport class ResilienceService {\n\t/** DI token — `@Inject(ResilienceService.TOKEN)`. */\n\tstatic readonly TOKEN = Symbol.for(\"nexus:ResilienceService\");\n\n\treadonly defaults: {\n\t\tretry: Required<RetryConfig>;\n\t\tcircuit: Required<CircuitBreakerConfig>;\n\t\tbulkhead: Required<BulkheadConfig>;\n\t};\n\n\tprivate circuits = new Map<string, CircuitBreaker>();\n\tprivate bulkheads = new Map<string, Bulkhead>();\n\n\tconstructor(@Inject(\"RESILIENCE_CONFIG\") config: ResilienceConfig = {}) {\n\t\tthis.defaults = {\n\t\t\tretry: {\n\t\t\t\tattempts: 3,\n\t\t\t\tinitialDelay: 100,\n\t\t\t\tmaxDelay: 30_000,\n\t\t\t\tbackoff: \"exponential-jitter\",\n\t\t\t\tmultiplier: 2,\n\t\t\t\t...config.retry,\n\t\t\t} as Required<RetryConfig>,\n\t\t\tcircuit: {\n\t\t\t\tthreshold: 0.5,\n\t\t\t\tminCalls: 5,\n\t\t\t\ttimeout: 30_000,\n\t\t\t\thalfOpenAfter: 1,\n\t\t\t\twindow: 60_000,\n\t\t\t\t...config.circuit,\n\t\t\t} as Required<CircuitBreakerConfig>,\n\t\t\tbulkhead: {\n\t\t\t\tmaxConcurrent: 10,\n\t\t\t\tmaxQueued: 100,\n\t\t\t\trejectOnFull: false,\n\t\t\t\t...config.bulkhead,\n\t\t\t} as Required<BulkheadConfig>,\n\t\t};\n\t}\n\n\t/** Get or create a named circuit breaker. Shared across the app. */\n\tgetOrCreateCircuit(name: string, config: CircuitBreakerConfig = {}): CircuitBreaker {\n\t\tlet cb = this.circuits.get(name);\n\t\tif (!cb) {\n\t\t\tcb = new CircuitBreaker(name, { ...this.defaults.circuit, ...config });\n\t\t\tthis.circuits.set(name, cb);\n\t\t}\n\t\treturn cb;\n\t}\n\n\t/** Get or create a named bulkhead. */\n\tgetOrCreateBulkhead(name: string, config: BulkheadConfig = {}): Bulkhead {\n\t\tlet bh = this.bulkheads.get(name);\n\t\tif (!bh) {\n\t\t\t// Merge: explicit config overrides defaults, except for\n\t\t\t// `name` (always use the caller's name). Strip `name` from\n\t\t\t// the defaults before spreading to avoid a duplicate.\n\t\t\tconst { name: _ignored, ...defaultRest } = this.defaults.bulkhead as BulkheadConfig;\n\t\t\tvoid _ignored;\n\t\t\tbh = new Bulkhead({ ...defaultRest, ...config, name });\n\t\t\tthis.bulkheads.set(name, bh);\n\t\t}\n\t\treturn bh;\n\t}\n\n\t/** Look up an existing circuit (no creation). */\n\tgetCircuit(name: string): CircuitBreaker | undefined {\n\t\treturn this.circuits.get(name);\n\t}\n\n\t/** Look up an existing bulkhead. */\n\tgetBulkhead(name: string): Bulkhead | undefined {\n\t\treturn this.bulkheads.get(name);\n\t}\n\n\t/**\n\t * List all registered circuit breakers and their current metrics.\n\t * Useful for admin dashboards and monitoring.\n\t */\n\tlistCircuits(): Array<{\n\t\tname: string;\n\t\tstate: import(\"./types.js\").CircuitState;\n\t\tmetrics: import(\"./types.js\").CircuitMetrics;\n\t}> {\n\t\tconst results: Array<{\n\t\t\tname: string;\n\t\t\tstate: import(\"./types.js\").CircuitState;\n\t\t\tmetrics: import(\"./types.js\").CircuitMetrics;\n\t\t}> = [];\n\t\tfor (const [name, cb] of this.circuits) {\n\t\t\tresults.push({ name, state: cb.currentState, metrics: cb.metrics() });\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * List all registered bulkheads and their current stats.\n\t */\n\tlistBulkheads(): Array<{\n\t\tname: string;\n\t\tinFlight: number;\n\t\tqueued: number;\n\t\tmaxConcurrent: number;\n\t}> {\n\t\tconst results: Array<{\n\t\t\tname: string;\n\t\t\tinFlight: number;\n\t\t\tqueued: number;\n\t\t\tmaxConcurrent: number;\n\t\t}> = [];\n\t\tfor (const [name, bh] of this.bulkheads) {\n\t\t\tresults.push({\n\t\t\t\tname,\n\t\t\t\t...bh.stats,\n\t\t\t\tmaxConcurrent: bh.config.maxConcurrent,\n\t\t\t});\n\t\t}\n\t\treturn results;\n\t}\n\n\t/** Retry with default config. */\n\tretry<T>(fn: (signal: AbortSignal) => Promise<T> | T, cfg?: RetryConfig): Promise<T> {\n\t\treturn retry(fn, { ...this.defaults.retry, ...cfg });\n\t}\n\n\t/** Compute the backoff for a given attempt. Exposed for tests. */\n\tcomputeBackoff(attempt: number, overrides?: Partial<RetryConfig>): number {\n\t\tconst cfg = { ...this.defaults.retry, ...overrides };\n\t\t// Local copy of the same algorithm — kept here to avoid\n\t\t// importing from retry.ts just for the math.\n\t\tconst { initialDelay, maxDelay, multiplier } = cfg;\n\t\tconst backoff: BackoffStrategy = cfg.backoff;\n\t\tlet raw: number;\n\t\tswitch (backoff) {\n\t\t\tcase \"constant\":\n\t\t\t\traw = initialDelay;\n\t\t\t\tbreak;\n\t\t\tcase \"linear\":\n\t\t\t\traw = initialDelay * attempt;\n\t\t\t\tbreak;\n\t\t\tcase \"exponential\":\n\t\t\t\traw = initialDelay * Math.pow(multiplier, attempt - 1);\n\t\t\t\tbreak;\n\t\t\tcase \"exponential-jitter\":\n\t\t\t\traw = Math.random() * initialDelay * Math.pow(multiplier, attempt - 1);\n\t\t\t\tbreak;\n\t\t}\n\t\treturn Math.min(raw, maxDelay);\n\t}\n}\n",
|
|
10
|
-
"/**\n * `ResilienceModule` — drop-in DI for the resilience primitives.\n *\n * @Module({\n * imports: [\n * ResilienceModule.forRoot({\n * retry: { attempts: 3, backoff: \"exponential-jitter\" },\n * circuit: { threshold: 0.5, timeout: 30_000 },\n * }),\n * ],\n * })\n * class AppModule {}\n *\n * After boot, the service is available as `@Inject(ResilienceService.TOKEN)`\n * — controllers can call `svc.getOrCreateCircuit(\"stripe\")` to share\n * a circuit breaker with the rest of the app.\n *\n * The decorators (`@Retry`, `@CircuitBreaker`, `@Bulkhead`,\n * `@Resilient`) work without the module — they pick up the\n * service from the DI container at controller-mount time.\n */\nimport { Module } from \"@nexusts/core\";\nimport { ResilienceService } from \"./resilience.service.js\";\nimport {
|
|
11
|
-
"/**\n * Decorator barrel for `nexusjs/resilience`.\n *\n * The three method decorators (`@Retry`, `@CircuitBreaker`,\n * `@Bulkhead`) plus the combined `@Resilient` decorator are\n * implemented as **metadata-only** decorators — they write options\n * to the method's `reflect-metadata` store, and an\n * `ResilienceInterceptor` (or a runtime hook) reads and applies\n * them at call time.\n *\n * @Retry({ attempts: 3, backoff: \"exponential\" })\n * async fetchUser(id: string) { ... }\n *\n * @CircuitBreaker({ threshold: 0.5, timeout: 30_000 })\n * async callStripe() { ... }\n *\n * @Bulkhead({ maxConcurrent: 5 })\n * async callExpensive() { ... }\n *\n * @Resilient({ retry: {...}, circuit: {...}, bulkhead: {...} })\n * async criticalCall() { ... }\n */\nimport \"reflect-metadata\";\nimport type {\n\tBulkheadConfig,\n\tCircuitBreakerConfig,\n\tResilientConfig,\n\tRetryConfig,\n} from \"../types.js\";\nimport { RESILIENCE_META } from \"../types.js\";\n\n// Use `import type` for the service to avoid a circular import:\n// `resilience.service.ts` → `decorators/index.ts` → `resilience.service.ts`.\n// At runtime, the dependency is set via `setResilienceService()` so\n// only the *type* needs to be visible at type-check time.\nimport type { ResilienceService } from \"../resilience.service.js\";\n\n// Per-method metadata kinds. Each decorator stores its own\n// payload under a separate key so a method can have e.g. `@Retry`\n// and `@CircuitBreaker` simultaneously.\nconst KEY_RETRY = Symbol.for(\"nexus:Resilience:Retry\");\nconst KEY_CIRCUIT = Symbol.for(\"nexus:Resilience:Circuit\");\nconst KEY_BULKHEAD = Symbol.for(\"nexus:Resilience:Bulkhead\");\nconst KEY_RESILIENT = Symbol.for(\"nexus:Resilience:Resilient\");\n\nexport interface RetryMeta {\n\tconfig: RetryConfig;\n\t/** Captured bound `this` at call time. */\n}\nexport interface CircuitMeta {\n\tconfig: CircuitBreakerConfig;\n}\nexport interface BulkheadMeta {\n\tconfig: BulkheadConfig;\n}\nexport interface ResilientMeta {\n\tconfig: ResilientConfig;\n}\n\n/** Read the metadata for a given method. */\nexport function getMethodRetry(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n): RetryConfig | undefined {\n\treturn Reflect.getMetadata(KEY_RETRY, target, propertyKey) as RetryConfig | undefined;\n}\n\nexport function getMethodCircuit(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n): CircuitBreakerConfig | undefined {\n\treturn Reflect.getMetadata(KEY_CIRCUIT, target, propertyKey) as\n\t\t| CircuitBreakerConfig\n\t\t| undefined;\n}\n\nexport function getMethodBulkhead(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n): BulkheadConfig | undefined {\n\treturn Reflect.getMetadata(KEY_BULKHEAD, target, propertyKey) as\n\t\t| BulkheadConfig\n\t\t| undefined;\n}\n\nexport function getMethodResilient(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n): ResilientConfig | undefined {\n\treturn Reflect.getMetadata(KEY_RESILIENT, target, propertyKey) as\n\t\t| ResilientConfig\n\t\t| undefined;\n}\n\n// ============================================================================\n// Decorator factories\n// ============================================================================\n\nfunction makeMethodDecorator<TConfig>(\n\tkey: symbol,\n\textract: (config: TConfig) => unknown,\n): (config: TConfig) => MethodDecorator {\n\treturn (config: TConfig): MethodDecorator => {\n\t\treturn (\n\t\t\t_target: object,\n\t\t\tpropertyKey: string | symbol,\n\t\t\t_descriptor: TypedPropertyDescriptor<any>,\n\t\t): void => {\n\t\t\t// Metadata-only — we don't touch `descriptor.value`\n\t\t\t// here because Bun 1.3's stage-3 decorator mode (the\n\t\t\t// default) doesn't pass it. Instead, the framework\n\t\t\t// reads the metadata at controller-mount time and\n\t\t\t// calls `applyResilience()` to wrap the method.\n\t\t\tReflect.defineMetadata(key, extract(config), _target, propertyKey);\n\t\t};\n\t};\n}\n\n// Used by `applyResilience()` below (exported for users who want\n// to wire it into their own framework hook). Not invoked from the\n// decorator factories themselves — that would require reading\n// `descriptor.value` in the decorator body, which Bun's stage-3\n// decorator mode (the default in Bun 1.3+) doesn't supply.\nexport function getResilientMetadata(target: object, propertyKey: string | symbol) {\n\tconst resilient = getMethodResilient(target, propertyKey);\n\tconst retry = resilient?.retry ?? getMethodRetry(target, propertyKey);\n\tconst circuit = resilient?.circuit ?? getMethodCircuit(target, propertyKey);\n\tconst bulkhead = resilient?.bulkhead ?? getMethodBulkhead(target, propertyKey);\n\treturn { retry, circuit, bulkhead };\n}\n\n// Used by `applyResilience()` below; same rationale as above.\nexport function makeResilientWrapper(\n\toriginal: Function,\n\tresolveMeta: () => {\n\t\tretry?: RetryConfig;\n\t\tcircuit?: CircuitBreakerConfig;\n\t\tbulkhead?: BulkheadConfig;\n\t},\n): Function {\n\treturn function (this: unknown, ...args: any[]) {\n\t\tconst meta = resolveMeta();\n\t\tif (!meta.retry && !meta.circuit && !meta.bulkhead) {\n\t\t\treturn original.apply(this, args);\n\t\t}\n\t\tconst svc = getResilienceService();\n\t\tif (!svc) {\n\t\t\treturn original.apply(this, args);\n\t\t}\n\t\tconst name = original.name || \"anonymous\";\n\n\t\tconst fn = () => original.apply(this, args);\n\t\tconst runOnce = () =>\n\t\t\tmeta.bulkhead\n\t\t\t\t? svc.getOrCreateBulkhead(name, meta.bulkhead).execute(fn)\n\t\t\t\t: fn();\n\t\tconst runWithCircuit = () =>\n\t\t\tmeta.circuit\n\t\t\t\t? svc.getOrCreateCircuit(name, meta.circuit).execute(runOnce)\n\t\t\t\t: runOnce();\n\t\tconst runWithRetry = () =>\n\t\t\tmeta.retry ? svc.retry(runWithCircuit, meta.retry) : runWithCircuit();\n\n\t\treturn runWithRetry();\n\t};\n}\n\n/**\n * Module-level handle to the `ResilienceService`. Set by\n * `ResilienceModule.forRoot()` so the eager-decorator path can\n * access the registry without each method carrying the DI token.\n */\nlet _resilienceService: ResilienceService | null = null;\n\n/** Public — used by `ResilienceModule` to register the service. */\nexport function setResilienceService(svc: ResilienceService | null): void {\n\t_resilienceService = svc;\n}\n\n/** Public — used by the eager decorator path. */\nexport function getResilienceService(): ResilienceService | null {\n\treturn _resilienceService;\n}\n\n/** `@Retry(config)` — retry the method with backoff. */\nexport const Retry = makeMethodDecorator<RetryConfig>(KEY_RETRY, (c) => c);\n\n/** `@CircuitBreaker(config)` — wrap the method in a named circuit. */\nexport const CircuitBreaker = makeMethodDecorator<CircuitBreakerConfig>(\n\tKEY_CIRCUIT,\n\t(c) => c,\n);\n\n/** `@Bulkhead(config)` — limit concurrency for the method. */\nexport const Bulkhead = makeMethodDecorator<BulkheadConfig>(KEY_BULKHEAD, (c) => c);\n\n/** `@Resilient(config)` — combine retry + circuit + bulkhead. */\nexport const Resilient = makeMethodDecorator<ResilientConfig>(\n\tKEY_RESILIENT,\n\t(c) => c,\n);\n\n// ============================================================================\n// `applyResilience()` — runtime hook\n// ============================================================================\n\n/**\n * Read all `@Resilient` / `@Retry` / `@CircuitBreaker` / `@Bulkhead`\n * metadata on `target` and apply the corresponding wrappers around\n * `descriptor.value`. The framework wires this up via\n * `ResilienceService` when controllers are mounted.\n */\nexport function applyResilience(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n\tdescriptor: TypedPropertyDescriptor<any>,\n\tsvc: import(\"../resilience.service.js\").ResilienceService,\n): TypedPropertyDescriptor<any> {\n\tif (!descriptor.value || typeof descriptor.value !== \"function\") {\n\t\treturn descriptor;\n\t}\n\tconst original = descriptor.value;\n\n\tconst resilient = getMethodResilient(target, propertyKey);\n\tconst retry = resilient?.retry ?? getMethodRetry(target, propertyKey);\n\tconst circuit = resilient?.circuit ?? getMethodCircuit(target, propertyKey);\n\tconst bulkhead = resilient?.bulkhead ?? getMethodBulkhead(target, propertyKey);\n\n\tif (!retry && !circuit && !bulkhead) {\n\t\treturn descriptor; // No resilience — leave the method alone.\n\t}\n\n\tconst wrapped = async function (this: unknown, ...args: any[]) {\n\t\tconst name = String(propertyKey);\n\t\tconst fn = () => original.apply(this, args);\n\n\t\tconst runOnce = async () => {\n\t\t\tif (bulkhead) {\n\t\t\t\tconst bh = svc.getOrCreateBulkhead(name, bulkhead);\n\t\t\t\treturn bh.execute(fn);\n\t\t\t}\n\t\t\treturn fn();\n\t\t};\n\n\t\tconst runWithCircuit = async () => {\n\t\t\tif (circuit) {\n\t\t\t\tconst cb = svc.getOrCreateCircuit(name, circuit);\n\t\t\t\treturn cb.execute(runOnce);\n\t\t\t}\n\t\t\treturn runOnce();\n\t\t};\n\n\t\tconst runWithRetry = async () => {\n\t\t\tif (retry) {\n\t\t\t\treturn svc.retry(runWithCircuit, retry);\n\t\t\t}\n\t\t\treturn runWithCircuit();\n\t\t};\n\n\t\treturn runWithRetry();\n\t};\n\n\treturn {\n\t\t...descriptor,\n\t\tvalue: wrapped,\n\t};\n}\n\n// Re-export the meta key for tests.\nexport { RESILIENCE_META };\n"
|
|
10
|
+
"/**\n * `ResilienceModule` — drop-in DI for the resilience primitives.\n *\n * @Module({\n * imports: [\n * ResilienceModule.forRoot({\n * retry: { attempts: 3, backoff: \"exponential-jitter\" },\n * circuit: { threshold: 0.5, timeout: 30_000 },\n * }),\n * ],\n * })\n * class AppModule {}\n *\n * After boot, the service is available as `@Inject(ResilienceService.TOKEN)`\n * — controllers can call `svc.getOrCreateCircuit(\"stripe\")` to share\n * a circuit breaker with the rest of the app.\n *\n * The decorators (`@Retry`, `@CircuitBreaker`, `@Bulkhead`,\n * `@Resilient`) work without the module — they pick up the\n * service from the DI container at controller-mount time.\n */\nimport { Module, setControllerMethodHook } from \"@nexusts/core\";\nimport { ResilienceService } from \"./resilience.service.js\";\nimport {\n\tsetResilienceService,\n\tgetResilientMetadata,\n\tmakeResilientWrapper,\n} from \"./decorators/index.js\";\nimport type { ResilienceConfig } from \"./types.js\";\n\n@Module({\n\tproviders: [\n\t\tResilienceService,\n\t\t{ provide: ResilienceService.TOKEN, useExisting: ResilienceService },\n\t],\n\texports: [ResilienceService, ResilienceService.TOKEN],\n})\nexport class ResilienceModule {\n\tstatic forRoot(config: ResilienceConfig = {}) {\n\t\t// Eager-wrap: at controller-mount time, check each method for\n\t\t// @Retry / @CircuitBreaker / @Bulkhead / @Resilient metadata and\n\t\t// wrap it so the call goes through the resilience pipeline without\n\t\t// any explicit `svc.retry(...)` / `cb.execute(...)` boilerplate.\n\t\t// The service is resolved lazily at call time via getResilienceService().\n\t\tsetControllerMethodHook((proto, propertyKey, handler) => {\n\t\t\tconst meta = getResilientMetadata(proto, propertyKey);\n\t\t\tif (!meta.retry && !meta.circuit && !meta.bulkhead) return handler;\n\t\t\treturn makeResilientWrapper(\n\t\t\t\thandler,\n\t\t\t\t() => getResilientMetadata(proto, propertyKey),\n\t\t\t);\n\t\t});\n\n\t\t@Module({\n\t\t\tproviders: [\n\t\t\t\t{\n\t\t\t\t\tprovide: ResilienceService.TOKEN,\n\t\t\t\t\tuseFactory: () => {\n\t\t\t\t\t\tconst svc = new ResilienceService(config);\n\t\t\t\t\t\t// Register globally so the eager-decorator path\n\t\t\t\t\t\t// (in `decorators/index.ts`) can find us without\n\t\t\t\t\t\t// needing each controller method to carry an\n\t\t\t\t\t\t// `@Inject(ResilienceService.TOKEN)` argument.\n\t\t\t\t\t\tsetResilienceService(svc);\n\t\t\t\t\t\treturn svc;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tprovide: \"RESILIENCE_CONFIG\",\n\t\t\t\t\tuseValue: config,\n\t\t\t\t},\n\t\t\t],\n\t\t\texports: [ResilienceService.TOKEN, \"RESILIENCE_CONFIG\"],\n\t\t})\n\t\tclass ConfiguredResilienceModule {}\n\t\tObject.defineProperty(ConfiguredResilienceModule, \"name\", {\n\t\t\tvalue: \"ConfiguredResilienceModule\",\n\t\t});\n\t\treturn ConfiguredResilienceModule;\n\t}\n}\n",
|
|
11
|
+
"/**\n * Decorator barrel for `nexusjs/resilience`.\n *\n * The three method decorators (`@Retry`, `@CircuitBreaker`,\n * `@Bulkhead`) plus the combined `@Resilient` decorator are\n * implemented as **metadata-only** decorators — they write options\n * to the method's `reflect-metadata` store, and an\n * `ResilienceInterceptor` (or a runtime hook) reads and applies\n * them at call time.\n *\n * @Retry({ attempts: 3, backoff: \"exponential\" })\n * async fetchUser(id: string) { ... }\n *\n * @CircuitBreaker({ threshold: 0.5, timeout: 30_000 })\n * async callStripe() { ... }\n *\n * @Bulkhead({ maxConcurrent: 5 })\n * async callExpensive() { ... }\n *\n * @Resilient({ retry: {...}, circuit: {...}, bulkhead: {...} })\n * async criticalCall() { ... }\n */\nimport \"reflect-metadata\";\nimport type {\n\tBulkheadConfig,\n\tCircuitBreakerConfig,\n\tResilientConfig,\n\tRetryConfig,\n} from \"../types.js\";\nimport { RESILIENCE_META } from \"../types.js\";\n\n// Use `import type` for the service to avoid a circular import:\n// `resilience.service.ts` → `decorators/index.ts` → `resilience.service.ts`.\n// At runtime, the dependency is set via `setResilienceService()` so\n// only the *type* needs to be visible at type-check time.\nimport type { ResilienceService } from \"../resilience.service.js\";\n\n// Per-method metadata kinds. Each decorator stores its own\n// payload under a separate key so a method can have e.g. `@Retry`\n// and `@CircuitBreaker` simultaneously.\nconst KEY_RETRY = Symbol.for(\"nexus:Resilience:Retry\");\nconst KEY_CIRCUIT = Symbol.for(\"nexus:Resilience:Circuit\");\nconst KEY_BULKHEAD = Symbol.for(\"nexus:Resilience:Bulkhead\");\nconst KEY_RESILIENT = Symbol.for(\"nexus:Resilience:Resilient\");\n\nexport interface RetryMeta {\n\tconfig: RetryConfig;\n\t/** Captured bound `this` at call time. */\n}\nexport interface CircuitMeta {\n\tconfig: CircuitBreakerConfig;\n}\nexport interface BulkheadMeta {\n\tconfig: BulkheadConfig;\n}\nexport interface ResilientMeta {\n\tconfig: ResilientConfig;\n}\n\n/** Read the metadata for a given method. */\nexport function getMethodRetry(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n): RetryConfig | undefined {\n\treturn Reflect.getMetadata(KEY_RETRY, target, propertyKey) as RetryConfig | undefined;\n}\n\nexport function getMethodCircuit(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n): CircuitBreakerConfig | undefined {\n\treturn Reflect.getMetadata(KEY_CIRCUIT, target, propertyKey) as\n\t\t| CircuitBreakerConfig\n\t\t| undefined;\n}\n\nexport function getMethodBulkhead(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n): BulkheadConfig | undefined {\n\treturn Reflect.getMetadata(KEY_BULKHEAD, target, propertyKey) as\n\t\t| BulkheadConfig\n\t\t| undefined;\n}\n\nexport function getMethodResilient(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n): ResilientConfig | undefined {\n\treturn Reflect.getMetadata(KEY_RESILIENT, target, propertyKey) as\n\t\t| ResilientConfig\n\t\t| undefined;\n}\n\n// ============================================================================\n// Decorator factories\n// ============================================================================\n\nfunction makeMethodDecorator<TConfig>(\n\tkey: symbol,\n\textract: (config: TConfig) => unknown,\n): (config: TConfig) => MethodDecorator {\n\treturn (config: TConfig): MethodDecorator => {\n\t\treturn (\n\t\t\t_target: object,\n\t\t\tpropertyKey: string | symbol,\n\t\t\t_descriptor: TypedPropertyDescriptor<any>,\n\t\t): void => {\n\t\t\t// Metadata-only — we don't touch `descriptor.value`\n\t\t\t// here because Bun 1.3's stage-3 decorator mode (the\n\t\t\t// default) doesn't pass it. Instead, the framework\n\t\t\t// reads the metadata at controller-mount time and\n\t\t\t// calls `applyResilience()` to wrap the method.\n\t\t\tReflect.defineMetadata(key, extract(config), _target, propertyKey);\n\t\t};\n\t};\n}\n\n// Used by `applyResilience()` below (exported for users who want\n// to wire it into their own framework hook). Not invoked from the\n// decorator factories themselves — that would require reading\n// `descriptor.value` in the decorator body, which Bun's stage-3\n// decorator mode (the default in Bun 1.3+) doesn't supply.\nexport function getResilientMetadata(target: object, propertyKey: string | symbol) {\n\tconst resilient = getMethodResilient(target, propertyKey);\n\tconst retry = resilient?.retry ?? getMethodRetry(target, propertyKey);\n\tconst circuit = resilient?.circuit ?? getMethodCircuit(target, propertyKey);\n\tconst bulkhead = resilient?.bulkhead ?? getMethodBulkhead(target, propertyKey);\n\treturn { retry, circuit, bulkhead };\n}\n\n// Used by `applyResilience()` below; same rationale as above.\nexport function makeResilientWrapper(\n\toriginal: Function,\n\tresolveMeta: () => {\n\t\tretry?: RetryConfig;\n\t\tcircuit?: CircuitBreakerConfig;\n\t\tbulkhead?: BulkheadConfig;\n\t},\n): Function {\n\treturn function (this: unknown, ...args: any[]) {\n\t\tconst meta = resolveMeta();\n\t\tif (!meta.retry && !meta.circuit && !meta.bulkhead) {\n\t\t\treturn original.apply(this, args);\n\t\t}\n\t\tconst svc = getResilienceService();\n\t\tif (!svc) {\n\t\t\treturn original.apply(this, args);\n\t\t}\n\t\tconst name = original.name || \"anonymous\";\n\n\t\tconst fn = () => original.apply(this, args);\n\t\tconst runOnce = () =>\n\t\t\tmeta.bulkhead\n\t\t\t\t? svc.getOrCreateBulkhead(name, meta.bulkhead).execute(fn)\n\t\t\t\t: fn();\n\t\tconst runWithCircuit = () =>\n\t\t\tmeta.circuit\n\t\t\t\t? svc.getOrCreateCircuit(name, meta.circuit).execute(runOnce)\n\t\t\t\t: runOnce();\n\t\tconst runWithRetry = () =>\n\t\t\tmeta.retry ? svc.retry(runWithCircuit, meta.retry) : runWithCircuit();\n\n\t\treturn runWithRetry();\n\t};\n}\n\n/**\n * Module-level handle to the `ResilienceService`. Set by\n * `ResilienceModule.forRoot()` so the eager-decorator path can\n * access the registry without each method carrying the DI token.\n */\nlet _resilienceService: ResilienceService | null = null;\n\n/** Public — used by `ResilienceModule` to register the service. */\nexport function setResilienceService(svc: ResilienceService | null): void {\n\t_resilienceService = svc;\n}\n\n/** Public — used by the eager decorator path. */\nexport function getResilienceService(): ResilienceService | null {\n\treturn _resilienceService;\n}\n\n/** `@Retry(config)` — retry the method with backoff. */\nexport const Retry = makeMethodDecorator<RetryConfig>(KEY_RETRY, (c) => c);\n\n/** `@CircuitBreaker(config)` — wrap the method in a named circuit. */\nexport const CircuitBreaker = makeMethodDecorator<CircuitBreakerConfig>(\n\tKEY_CIRCUIT,\n\t(c) => c,\n);\n\n/** `@Bulkhead(config)` — limit concurrency for the method. */\nexport const Bulkhead = makeMethodDecorator<BulkheadConfig>(KEY_BULKHEAD, (c) => c);\n\n/** `@Resilient(config)` — combine retry + circuit + bulkhead. */\nexport const Resilient = makeMethodDecorator<ResilientConfig>(\n\tKEY_RESILIENT,\n\t(c) => c,\n);\n\n// ============================================================================\n// `applyResilience()` — runtime hook\n// ============================================================================\n\n/**\n * Read all `@Resilient` / `@Retry` / `@CircuitBreaker` / `@Bulkhead`\n * metadata on `target` and apply the corresponding wrappers around\n * `descriptor.value`. The framework wires this up via\n * `ResilienceService` when controllers are mounted.\n */\nexport function applyResilience(\n\ttarget: object,\n\tpropertyKey: string | symbol,\n\tdescriptor: TypedPropertyDescriptor<any>,\n\tsvc: import(\"../resilience.service.js\").ResilienceService,\n): TypedPropertyDescriptor<any> {\n\tif (!descriptor.value || typeof descriptor.value !== \"function\") {\n\t\treturn descriptor;\n\t}\n\tconst original = descriptor.value;\n\n\tconst resilient = getMethodResilient(target, propertyKey);\n\tconst retry = resilient?.retry ?? getMethodRetry(target, propertyKey);\n\tconst circuit = resilient?.circuit ?? getMethodCircuit(target, propertyKey);\n\tconst bulkhead = resilient?.bulkhead ?? getMethodBulkhead(target, propertyKey);\n\n\tif (!retry && !circuit && !bulkhead) {\n\t\treturn descriptor; // No resilience — leave the method alone.\n\t}\n\n\tconst wrapped = async function (this: unknown, ...args: any[]) {\n\t\tconst name = String(propertyKey);\n\t\tconst fn = () => original.apply(this, args);\n\n\t\tconst runOnce = async () => {\n\t\t\tif (bulkhead) {\n\t\t\t\tconst bh = svc.getOrCreateBulkhead(name, bulkhead);\n\t\t\t\treturn bh.execute(fn);\n\t\t\t}\n\t\t\treturn fn();\n\t\t};\n\n\t\tconst runWithCircuit = async () => {\n\t\t\tif (circuit) {\n\t\t\t\tconst cb = svc.getOrCreateCircuit(name, circuit);\n\t\t\t\treturn cb.execute(runOnce);\n\t\t\t}\n\t\t\treturn runOnce();\n\t\t};\n\n\t\tconst runWithRetry = async () => {\n\t\t\tif (retry) {\n\t\t\t\treturn svc.retry(runWithCircuit, retry);\n\t\t\t}\n\t\t\treturn runWithCircuit();\n\t\t};\n\n\t\treturn runWithRetry();\n\t};\n\n\treturn {\n\t\t...descriptor,\n\t\tvalue: wrapped,\n\t};\n}\n\n// Re-export the meta key for tests.\nexport { RESILIENCE_META };\n",
|
|
12
|
+
"/**\n * `ResilienceAdminModule` — opt-in HTTP endpoints for inspecting and\n * controlling circuit breakers and bulkheads at runtime.\n *\n * Usage:\n *\n * @Module({\n * imports: [\n * ResilienceModule.forRoot({ threshold: 0.5 }),\n * ResilienceAdminModule.forRoot({ prefix: '/admin/resilience' }),\n * ],\n * })\n * class AppModule {}\n *\n * Endpoints (relative to `prefix`, default `/resilience`):\n * GET /resilience/circuits — list all circuits\n * GET /resilience/bulkheads — list all bulkheads\n * POST /resilience/circuits/:name/force-open\n * POST /resilience/circuits/:name/force-close\n * POST /resilience/circuits/:name/reset\n *\n * Requires `ResilienceModule.forRoot()` to also be imported — the admin\n * module resolves `ResilienceService.TOKEN` through the shared DI parent\n * container that both modules register into.\n */\nimport { Controller, Get, Post, Param, Inject, Module } from \"@nexusts/core\";\nimport { ResilienceService } from \"./resilience.service.js\";\n\nexport interface ResilienceAdminConfig {\n\t/** Route prefix. Default: `\"/resilience\"`. */\n\tprefix?: string;\n}\n\nexport class ResilienceAdminModule {\n\tstatic forRoot(config: ResilienceAdminConfig = {}) {\n\t\tconst prefix = config.prefix ?? \"/resilience\";\n\n\t\t@Controller(prefix)\n\t\tclass ResilienceAdminController {\n\t\t\t_svc: ResilienceService;\n\t\t\tconstructor(@Inject(ResilienceService.TOKEN) svc: ResilienceService) {\n\t\t\t\tthis._svc = svc;\n\t\t\t}\n\n\t\t\t@Get(\"/circuits\")\n\t\t\tlistCircuits() {\n\t\t\t\treturn this._svc.listCircuits();\n\t\t\t}\n\n\t\t\t@Get(\"/bulkheads\")\n\t\t\tlistBulkheads() {\n\t\t\t\treturn this._svc.listBulkheads();\n\t\t\t}\n\n\t\t\t@Post(\"/circuits/:name/force-open\")\n\t\t\tforceOpen(@Param(\"name\") name: string) {\n\t\t\t\tconst cb = this._svc.getCircuit(name);\n\t\t\t\tif (!cb) {\n\t\t\t\t\treturn { status: 404, body: { error: `Circuit \"${name}\" not found` } };\n\t\t\t\t}\n\t\t\t\tcb.forceOpen();\n\t\t\t\treturn { name, state: \"open\" };\n\t\t\t}\n\n\t\t\t@Post(\"/circuits/:name/force-close\")\n\t\t\tforceClose(@Param(\"name\") name: string) {\n\t\t\t\tconst cb = this._svc.getCircuit(name);\n\t\t\t\tif (!cb) {\n\t\t\t\t\treturn { status: 404, body: { error: `Circuit \"${name}\" not found` } };\n\t\t\t\t}\n\t\t\t\tcb.forceClose();\n\t\t\t\treturn { name, state: \"closed\" };\n\t\t\t}\n\n\t\t\t@Post(\"/circuits/:name/reset\")\n\t\t\treset(@Param(\"name\") name: string) {\n\t\t\t\tconst cb = this._svc.getCircuit(name);\n\t\t\t\tif (!cb) {\n\t\t\t\t\treturn { status: 404, body: { error: `Circuit \"${name}\" not found` } };\n\t\t\t\t}\n\t\t\t\tcb.reset();\n\t\t\t\treturn { name, state: \"closed\" };\n\t\t\t}\n\t\t}\n\n\t\tObject.defineProperty(ResilienceAdminController, \"name\", {\n\t\t\tvalue: \"ResilienceAdminController\",\n\t\t});\n\n\t\t@Module({\n\t\t\tcontrollers: [ResilienceAdminController],\n\t\t})\n\t\tclass ConfiguredResilienceAdminModule {}\n\n\t\tObject.defineProperty(ConfiguredResilienceAdminModule, \"name\", {\n\t\t\tvalue: \"ConfiguredResilienceAdminModule\",\n\t\t});\n\n\t\treturn ConfiguredResilienceAdminModule;\n\t}\n}\n"
|
|
12
13
|
],
|
|
13
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAuLO,IAAM,kBAAkB,OAAO,IAAI,uBAAuB;;ACpKjE,IAAM,WAAW;AAAA,EAChB,UAAU;AAAA,EACV,cAAc;AAAA,EACd,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AACb;AAEA,IAAM,iBAAmC,CAAC,QAAiB;AAAA,EAC1D,IAAI,OAAO;AAAA,IAAM,OAAO;AAAA,EAExB,MAAM,OAAQ,KAA2B,QAAQ;AAAA,EACjD,IAAI,SAAS,gBAAgB,SAAS;AAAA,IAAqB,OAAO;AAAA,EAClE,OAAO;AAAA;AAIR,SAAS,KAAK,CAAC,IAAY,QAAqC;AAAA,EAC/D,OAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AAA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,QAAQ;AAAA,MACxD,OAAO;AAAA,IACR,CAAC;AAAA;AAAA,IAKD,MAAM,gCAAgC;AAAA,IAAC;AAAA,IAAjC,kCAAN;AAAA,MAHC,QAAO;AAAA,QACP,aAAa,CAAC,yBAAyB;AAAA,MACxC,CAAC;AAAA,OACK;AAAA,IAEN,OAAO,eAAe,iCAAiC,QAAQ;AAAA,MAC9D,OAAO;AAAA,IACR,CAAC;AAAA,IAED,OAAO;AAAA;AAET;",
|
|
15
|
+
"debugId": "0E90B0DDA626E48864756E2164756E21",
|
|
15
16
|
"names": []
|
|
16
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexusts/resilience",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Retry + Circuit Breaker + Bulkhead",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@nexusts/core": "^0.
|
|
29
|
+
"@nexusts/core": "^0.8.0"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|