go get -v github.com/msfidelis/gin-chaos-monkey
package main
import (
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()
}
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()
}
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.
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
This assault randomly inject an panic
exception on application runtime
Increases the RAM consumption of the application
Increases the CPU consumption of the application
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
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 |
go test -v