Skip to content

Migrating from opossum

Migrating from opossum (resilix/compat/opossum)

Scope of the claim, measured: the shim passes 362 of 362 of opossum's own test suite, run unmodified against resilix/compat/opossum. Reproduce it yourself with pnpm test:compat — it fetches their suite, points their require('../') at our build, and fails if this README's number is out of date.

Three of their test files are excluded because no compatibility layer can ever satisfy them: cache.js, semaphore-test.js and status-test.js require('../lib/…') directly, so they unit-test opossum's private modules rather than its public API. Caching and call coalescing are also unimplemented on purpose — passing cache, coalesce or cacheTTL throws rather than silently doing nothing.

diff
- const CircuitBreaker = require('opossum');
+ const CircuitBreaker = require('resilix/compat/opossum');

Default behaviour is opossum's, not resilix's — a compat layer must not change what your service does on the day you swap the import. slowCallRate defaults to 1 (disabled) and consecutiveBackstop to 0 (disabled), because opossum has neither concept.

opossum optionMapping
timeoutpipeline deadline; false disables
errorThresholdPercentagefailureRate (÷100)
resetTimeoutopenForMs
rollingCountTimeoutwindow.maxAgeMs
rollingCountBucketsaccepted and ignored — our window is not bucketed
volumeThresholdwindow.minCalls
errorFilterwrapped into a classifier: true ⇒ not a failure
capacitybulkhead({ concurrency })
cache, coalesce, cacheTTLthrows. Out of scope — silently accepting them would be worse

Supported: fire, fallback, on/off/removeAllListeners, open/close, enable/disable, opened/closed/halfOpen/pendingClose, stats, status, isOurError, and the fire/success/failure/timeout/reject/open/close/halfOpen/ fallback/semaphoreLocked events.

Opt back into the resilix behaviour when you're ready:

js
new CircuitBreaker(action, { slowCallMs: 3000, slowCallRate: 0.5, consecutiveBackstop: 10 });

MIT licensed. Zero runtime dependencies.