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 withpnpm test:compat— it fetches their suite, points theirrequire('../')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.jsandstatus-test.jsrequire('../lib/…')directly, so they unit-test opossum's private modules rather than its public API. Caching and call coalescing are also unimplemented on purpose — passingcache,coalesceorcacheTTLthrows rather than silently doing nothing.
- 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 option | Mapping |
|---|---|
timeout | pipeline deadline; false disables |
errorThresholdPercentage | failureRate (÷100) |
resetTimeout | openForMs |
rollingCountTimeout | window.maxAgeMs |
rollingCountBuckets | accepted and ignored — our window is not bucketed |
volumeThreshold | window.minCalls |
errorFilter | wrapped into a classifier: true ⇒ not a failure |
capacity | bulkhead({ concurrency }) |
cache, coalesce, cacheTTL | throws. 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:
new CircuitBreaker(action, { slowCallMs: 3000, slowCallRate: 0.5, consecutiveBackstop: 10 });