@gomani/resilience@1.2.0
npm size budget2.6 KB / 5.0 KB ✓
@gomani/resilience
Zero-dependency, isomorphic: circuitBreaker, bulkhead, pool, retry, withTimeout, withFallback, and guard (which composes them). <Degradable> renders a cached/read-only/hidden fallback when a dependency is down. All clocks and randomness are injectable for deterministic tests.
API
guard
function
guard<T>(fn: () => Promise<T>, options: GuardOptions): () => Promise<T>
Compose fallback → bulkhead → circuit breaker → retry → timeout around a function.
circuitBreaker
function
circuitBreaker<T>(fn: () => Promise<T>, options?: BreakerOptions): () => Promise<T>
A lazy open → half-open breaker with no background timer.
Degradable
function
Degradable(props: DegradableProps): VNode
Render a degraded fallback (cached/readOnly/hidden/queue) when when is true; accepts a signal for reactive client degradation.