Creators to follow

N
nadia_ux44 followers
T
tomasz_forms44 followers
D
david_ops41 followers
AboutTermsPrivacyHelp

© 2026 teliprompt

DA
david_ops
7 months ago•
Backend

Circuit breaker pattern with fallback for flaky upstream services

Claude Sonnet 4.6
code output
#resilience
#circuit-breaker
#patterns
#typescript
#reliability
Views
2.7K
Copies
590
Likes
322
Comments
0
Copy rate
22.0%

Prompt

You are a resilience engineer. Implement a circuit breaker in TypeScript for a [framework] service calling a [upstream_name] upstream with [timeout_ms]ms timeout.

Requirements:
1. Three states: CLOSED, OPEN, HALF_OPEN with proper transitions
2. Failure threshold: open after N failures within a rolling window
3. Cooldown: stay OPEN for [cooldown_ms]ms before probing with HALF_OPEN
4. Fallback callback invoked when circuit is OPEN
5. Prometheus-style metrics hooks
6. Unit-testable, no global singletons

Provide a small demo usage at the bottom.

Customise this prompt

Fill in 4 variables to personalise this prompt

Preview
You are a resilience engineer. Implement a circuit breaker in TypeScript for a [framework] service calling a [upstream_name] upstream with [timeout_ms]ms timeout. Requirements: 1. Three states: CLOSED, OPEN, HALF_OPEN with proper transitions 2. Failure threshold: open after N failures within a rolling window 3. Cooldown: stay OPEN for [cooldown_ms]ms before probing with HALF_OPEN 4. Fallback callback invoked when circuit is OPEN 5. Prometheus-style metrics hooks 6. Unit-testable, no global singletons Provide a small demo usage at the bottom.

Example output

Related prompts

Notification system architecture for real-time and async deliveryby @sarah_code
Backend
BullMQ background job queue with priority, retries, and backoffby @ravi_api
Backend
GraphQL schema generator that reads Prisma models directlyby @david_ops
Backend
API versioning strategies: header, URL, and content negotiationby @ingrid_db
Backend