@arki/resilience
archivefor @arki/[email protected] · Tier 2: standalone libraries
Resilience primitives for ARKI — retry, circuit breaker, timeout, bulkhead, and curated presets.
Version 0.0.2 archive
Install
bun add @arki/[email protected]Other package managers
npm install @arki/[email protected]
pnpm add @arki/[email protected]
yarn add @arki/[email protected]Release health for @arki/[email protected]
Doc examples
No example report was recorded for this version.
Open gaps
6 release checks fail
- check
file-llms-txt - check
file-agents-md - check
file-agent-guide - check
readme-h2-order - check
pkg-engines - check
files-ship-dist-docs
Used by demos
No demo uses this package yet.
Runtimes
No engines field, so no runtime requirement is declared.
Benchmarks
No benchmarks are published for this version.
README
Resilience primitives for ARKI — retry, circuit breaker, timeout, bulkhead, and curated presets. Built on top of cockatiel with ergonomic factories and ready-made policies for common workloads.
Installation
npm install @arki/resilience
# or
bun add @arki/resilience
# or
pnpm add @arki/resilienceUsage
Pre-configured presets
import { externalApiPolicy, withResilience } from '@arki/resilience';
const data = await withResilience(
() => fetch('https://api.example.com/billing').then(r => r.json()),
externalApiPolicy,
);Three curated presets ship out of the box:
externalApiPolicy— retry + timeout tuned for third-party HTTP calls.databasePolicy— short timeout + retry for transient connection errors.backgroundJobPolicy— longer timeout + aggressive retry for long-running work.
Building policies
import {
createResiliencePolicy,
withResilience,
} from '@arki/resilience';
const policy = createResiliencePolicy({
retry: { maxAttempts: 3, initialDelay: 200 },
timeout: { durationMs: 5_000 },
circuitBreaker: { halfOpenAfterMs: 30_000, threshold: 5 },
});
const result = await withResilience(({ signal }) => doWork(signal), policy);Quick wrappers
For one-off calls without a long-lived policy:
import { withRetry, withTimeout, withCircuitBreaker } from '@arki/resilience';
await withRetry(() => sendEmail('[email protected]'), { maxAttempts: 3 });
await withTimeout(() => slowOperation(), { durationMs: 1_000 });Observability
import { attachPolicyLogger } from '@arki/resilience';
attachPolicyLogger(policy, {
onRetry: (event) => console.log('retry', event),
onBreak: (event) => console.warn('circuit open', event),
});API
createResiliencePolicy(options)— compose retry + timeout + circuit breaker + bulkhead.createRetryPolicy,createCircuitBreakerPolicy,createTimeoutPolicy,createBulkheadPolicy— individual primitives.externalApiPolicy,databasePolicy,backgroundJobPolicy— pre-tuned presets.withResilience,withRetry,withTimeout,withCircuitBreaker— execution helpers.attachPolicyLogger(policy, logger)— observability hooks.CircuitOpenError,TimeoutError,RetriesExhaustedError— typed errors with helpers (isResilienceError,isBrokenCircuitError,isBulkheadRejectedError).- Re-exports
IPolicy,wrap,noopfromcockatiel.
Documentation
@arki/resilience is framework-agnostic and works on its own. When you
compose it with the @arki/dot
application framework, see packages/dot/docs/ for plugin authoring,
lifecycle, and diagnostics.
License
MIT — see LICENSE.
Public imports
This version has no API index.