Saltar al contenido principal

Configuración por instancia

import trybox from "trybox";

const runner = trybox({
  circuitBreaker: {
    failureThreshold: 2,
    resetTimeout: 1000,
    halfOpenRequests: 1,
  },
});

Comportamiento

  • Abre el circuito tras failureThreshold errores consecutivos
  • Durante resetTimeout, llamadas fallan de forma inmediata
  • En half-open, limita el número de pruebas controladas

Por llamada

import { run } from "trybox";

const r = await run(async () => 1, {
  circuitBreaker: { failureThreshold: 3, resetTimeout: 1500 },
});