Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msfidelis/gin-chaos-monkey
:cocktail: :cocktail: :cocktail: - Chaos Monkey assalts middleware for Gin Gonic
https://github.com/msfidelis/gin-chaos-monkey
chaos-engineering chaos-monkey gin-gonic gin-middleware
Last synced: 3 months ago
JSON representation
:cocktail: :cocktail: :cocktail: - Chaos Monkey assalts middleware for Gin Gonic
- Host: GitHub
- URL: https://github.com/msfidelis/gin-chaos-monkey
- Owner: msfidelis
- License: mit
- Created: 2020-11-04T05:19:34.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-05T14:41:29.000Z (about 3 years ago)
- Last Synced: 2024-10-01T01:01:55.857Z (4 months ago)
- Topics: chaos-engineering, chaos-monkey, gin-gonic, gin-middleware
- Language: Go
- Homepage:
- Size: 147 KB
- Stars: 20
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gin Chaos Monkey - Assault Middleware for Gin :cocktail: :cocktail: :cocktail:
## Contents
- [Gin Web Framework](https://github.com/gin-gonic/gin)
- [Installation](#installation)
- [Usage](#usage)
- [Assault types](#assault-types)
- [Environment variables configuration](#environment-variables-configuration)
- [Development](#development)## Installation
```
go get -v github.com/msfidelis/gin-chaos-monkey
```
# Usage
## Basic Usage
```go
package mainimport (
chaos "github.com/msfidelis/gin-chaos-monkey"
"github.com/gin-gonic/gin"
)func main() {
r := gin.Default()//Middlewares
r.Use(gin.Recovery())
r.Use(chaos.Load())// Healthcheck
r.GET("/healthcheck", healthcheck.Ok)r.Run()
}
```## Specific Routes
```golang
package main
import (
"net/http""github.com/gin-gonic/gin"
chaos "github.com/msfidelis/gin-chaos-monkey"
)func main() {
router := gin.Default()//Enable Chaos Monkey in Specific Route
router.GET("/healthcheck/chaos", chaos.Load(), healthcheck.Ok)router.GET("/healthcheck", healthcheck.Ok)
router.Run()
}
```# ASSAULT TYPES
### LATENCY ASSAULT
This assault increase latency on response time for web requests. You can set `CHAOS_MONKEY_LATENCY_MAX_TIMEOUT` environment variable to customize a max time to increase in requests.
### EXCEPTION ASSAULT
This assault randomly returns 5xx errors for HTTP requests. You can set `CHAOS_MONKEY_EXCEPTION_HTTP_STATUS_CODE` to customize status codes to return in HTTP exception. Default: `503`
### APP KILLER ASSAULT
This assault randomly inject an `panic` exception on application runtime
### MEMORY ASSAULT
Increases the RAM consumption of the application
### CPU ASSAULT
Increases the CPU consumption of the application
# CONFIGURATION
## Enable Chaos Monkey Assalts
```bash
export CHAOS_MONKEY_ENABLED=true
export CHAOS_MONKEY_MODE=soft
export CHAOS_MONKEY_LATENCY=true
export CHAOS_MONKEY_LATENCY_MIN_TIME=5000
export CHAOS_MONKEY_LATENCY_MAX_TIME=10000
```## Environment Variables Configuration
| VARIABLE | OPTIONS | DEFAULT |
| ----------------------------------------- | --------------------------| --------- |
| CHAOS_MONKEY_ENABLED | true/false | false |
| CHAOS_MONKEY_MODE | soft/hard/critical/hell | soft |
| CHAOS_MONKEY_LATENCY | true/false | false |
| CHAOS_MONKEY_LATENCY_MIN_TIME | miliseconds | max_time |
| CHAOS_MONKEY_LATENCY_MAX_TIME | miliseconds | 1000 |
| CHAOS_MONKEY_EXCEPTION | true/false | false |
| CHAOS_MONKEY_EXCEPTION_HTTP_STATUS_CODE | 5xx | 503 |
| CHAOS_MONKEY_APP_KILLER | true/false | false |
| CHAOS_MONKEY_MEMORY | true/false | false |
| CHAOS_MONKEY_CPU | true/false | false |## Development
### Running Tests
```
go test -v
```