an api fuse realized in golang.
go get github.com/fwhezfwhez/fuse
- Know that keep aware of what kind of errors should count fs.Fail() times.
// 20s allows 5 fail times, on arriving 5 times will fall into fused state for 10s.
fs := NewFuse(5, 10, 20, 1)
var rpcName = "/get-user-info/"
if !fs.FuseOK(rpcName) {
return fmt.Errorf("'%s' is fused for breaking max times", rpcName)
}
if e:=rpcCall(); e!=nil {
fs.Fail(rpcName)
return
}http-gin
import "github.com/fwhezfwhez/fuse/middleware"
...
r:=gin.Default()
r.Use(middleware.GinHTTPFuse)