hystrix-go

command module
v0.0.0-...-2f66058 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2015 License: MIT Imports: 5 Imported by: 0

README

hystrix-go

This is sample project to use hystrix-go. This repository also includes sub-system which main process tries to send request. So you can try its functionality by hand.

Install

To use hystrix-go,

$ go get github.com/afex/hystrix-go/hystrix

Usage

To run main (with hystrix circuit breaker),

$ go run main.go

To run sub system, it would takes time to response,

$ cd sub
$ go run main.go

To access to main system,

$ for i in $(seq 5); do curl -x '' localhost:8080 &; done

Circuit Breaker will open after certain number of requests (RequestVolumeThreshold) and error rate is higher ahtn threshold (ErrorPercentThreshold). While opening, all requests are failed. After some certain time (SleepWindow), breaker try to send single test request to sub system, and request is succeeded, breaker will close. You can also set request Timeout and the number fo conccurent requests.

To try above function, let's stop sub system process :) and see what main system log says,

2015/05/08 14:15:10 / GET
2015/05/08 14:15:10 failed to get response from sub-system: hystrix: circuit open

2015/05/08 14:15:15 / GET
2015/05/08 14:15:15 hystrix-go: allowing single test to possibly close circuit my_command
2015/05/08 14:15:15 failed to get response from sub-system: Get http://localhost:9090: dial tcp 127.0.0.1:9090: connection refused

2015/05/08 14:15:33 / GET
2015/05/08 14:15:33 hystrix-go: allowing single test to possibly close circuit my_command
2015/05/08 14:15:34 hystrix-go: closing circuit my_command
2015/05/08 14:15:34 success to get response from sub-system: Hello

References

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL