https://github.com/rs/rest-layer-hystrix
REST Layer Hystrix storage handler wrapper
https://github.com/rs/rest-layer-hystrix
Last synced: 3 months ago
JSON representation
REST Layer Hystrix storage handler wrapper
- Host: GitHub
- URL: https://github.com/rs/rest-layer-hystrix
- Owner: rs
- License: mit
- Created: 2016-03-08T18:28:23.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-04-21T12:38:06.000Z (about 7 years ago)
- Last Synced: 2025-06-19T06:54:55.651Z (11 months ago)
- Language: Go
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# REST Layer Hystrix storage handler wrapper
[](https://godoc.org/github.com/rs/rest-layer-hystrix) [](https://raw.githubusercontent.com/rs/rest-layer-hystrix/master/LICENSE) [](https://travis-ci.org/rs/rest-layer-hystrix)
This [REST Layer](https://github.com/rs/rest-layer) resource storage wrapper uses [hystrix-go](github.com/afex/hystrix-go) to add circuit breaker support to any REST Layer resource storage handler.
## Usage
```go
import "github.com/rs/rest-layer-hystrix"
```
Wrap existing storage handler with a name that will be used to construct hystrix commands:
```go
s := restrix.Wrap("myResource", mem.NewHandler())
```
Use this handler with a resource:
```go
index.Bind("foo", foo, s, resource.DefaultConf)
```
Customize the hystrix commands:
```go
// 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:
```go
hystrixStreamHandler := hystrix.NewStreamHandler()
hystrixStreamHandler.Start()
log.Print("Serving Hystrix metrics on http://localhost:8081")
go http.ListenAndServe(net.JoinHostPort("", "8081"), hystrixStreamHandler)
```