Awesome
REST Layer Hystrix storage handler wrapper
This REST Layer resource storage wrapper uses hystrix-go to add circuit breaker support to any REST Layer resource storage handler.
Usage
import "github.com/rs/rest-layer-hystrix"
Wrap existing storage handler with a name that will be used to construct hystrix commands:
s := restrix.Wrap("myResource", mem.NewHandler())
Use this handler with a resource:
index.Bind("foo", foo, s, resource.DefaultConf)
Customize the hystrix commands:
// Configure hystrix commands
hystrix.Configure(map[string]hystrix.CommandConfig{
"posts.Find": {
Timeout: 1000,
MaxConcurrentRequests: 100,
ErrorPercentThreshold: 25,
},
"posts.Insert": {
Timeout: 1000,
MaxConcurrentRequests: 50,
ErrorPercentThreshold: 25,
},
...
})
Start the metrics stream handler:
hystrixStreamHandler := hystrix.NewStreamHandler()
hystrixStreamHandler.Start()
log.Print("Serving Hystrix metrics on http://localhost:8081")
go http.ListenAndServe(net.JoinHostPort("", "8081"), hystrixStreamHandler)