https://github.com/pazfelipe/circuit-breaker
Simple example to show how we can implement circuit breaker system
https://github.com/pazfelipe/circuit-breaker
circuit-breaker express flask nodejs python
Last synced: 3 months ago
JSON representation
Simple example to show how we can implement circuit breaker system
- Host: GitHub
- URL: https://github.com/pazfelipe/circuit-breaker
- Owner: pazfelipe
- License: mit
- Created: 2024-06-27T19:06:42.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-27T21:30:37.000Z (about 2 years ago)
- Last Synced: 2025-02-23T17:13:14.472Z (over 1 year ago)
- Topics: circuit-breaker, express, flask, nodejs, python
- Language: TypeScript
- Homepage:
- Size: 91.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Microservices with Circuit Breaker
This repository contains two APIs, one built with Python (Flask) and the other with Node.js (TypeScript and Express). Both APIs are configured with Docker Compose to restart every 10 seconds, simulating timeouts or data loss scenarios. Circuit Breaker patterns are implemented to handle failures gracefully.
## Setup
### Prerequisites
- Docker
- Docker Compose
### Installation
1. Clone the repository:
```sh
git clone https://github.com/pazfelipe/circuit-broker.git
cd circuit-broker
docker-compose up --build -d
```
2. Build and start the services:
```sh
docker-compose up --build -d
```
## Endpoints
### Python API
• /status - Returns the status of the Python API.
• /data - Returns a sample data from the Python API.
• /node-data - Fetches data from the Node.js API using a Circuit Breaker.
### Node.js API
• /status - Returns the status of the Node.js API.
• /data - Returns a sample data from the Node.js API.
• /python-data - Fetches data from the Python API using a Circuit Breaker.
## Testing
### Python API
```sh
cd python_api
pytest
```
### Node.js API
```sh
cd node_api
npm test
```
## Circuit Breaker
Both APIs implement the Circuit Breaker pattern to handle failures gracefully and prevent cascading failures across services.
**Python API**
Uses the _pybreaker_ library.
**Node.js API**
Uses the _opossum_ library.