// @bun
var c=Object.defineProperty;var o=(e)=>e;function n(e,r){this[e]=o.bind(null,r)}var s=(e,r)=>{for(var a in r)c(e,a,{get:r[a],enumerable:!0,configurable:!0,set:n.bind(r,a)})};var u=(e,r)=>()=>(e&&(r=e(e=0)),r);import{jsx as t,jsxs as i}from"react/jsx-runtime";function p(){return i("div",{className:"space-y-8",children:[i("div",{className:"space-y-4",children:[t("h1",{className:"font-bold text-4xl",children:"Integration Circuit Breakers"}),t("p",{className:"text-lg text-muted-foreground",children:"External APIs are the most common source of instability. Wrap every integration call in a circuit breaker to protect your system."})]}),i("div",{className:"space-y-4",children:[t("h2",{className:"font-bold text-2xl",children:"Pattern"}),t("p",{children:"Create a dedicated circuit breaker instance for each external service. This ensures that a failure in Stripe doesn't trigger the circuit breaker for Twilio."}),t("pre",{className:"rounded-lg border bg-muted p-4 text-sm",children:`// integrations/stripe.ts
import { CircuitBreaker } from '@contractspec/lib.resilience/circuit-breaker';

const stripeBreaker = new CircuitBreaker({
  failureThreshold: 10,
  resetTimeoutMs: 60000,
});

export async function createCharge(amount: number) {
  return stripeBreaker.execute(() => stripe.charges.create({ amount }));
}`})]})]})}export{p as IntegrationsCircuitBreakersPage};
