Skip to content

felipedmsantos95/resilience-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Resilience Lab — Circuit Breaker in Go

This project demonstrates the Circuit Breaker Design Pattern, implemented in Go, to improve the resilience of distributed systems. It simulates an unstable external service that randomly fails, showing how the circuit breaker prevents cascading system failures.


🧠 Concept

The Circuit Breaker Pattern works like an electrical switch that “opens” the circuit after detecting too many consecutive failures. This prevents the main system from continuously calling a failing service, allowing it to recover gracefully.

Circuit States:

State Description
🟢 Closed All good — requests flow normally.
🔴 Open Too many consecutive failures — block new requests for a cooldown period.
🟡 Half-Open Allow a few test requests to check if the service has recovered.

🧩 Project Structure

resilience-lab/ ├── main.go # Simulation runner ├── flaky_service.go # Unstable service simulation ├── circuit_breaker.go # Circuit Breaker implementation └── go.mod

🚀 Run the Project

# Initialize Go module
go mod init resilience-lab

# Run the simulation
go run .

About

Go lab demonstrating the Circuit Breaker design pattern for increasing the resilience of distributed systems. Includes unstable service simulation and cascading failure protection logic.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages