断路器的相关原理可参考:https://skaygo.blog.youkuaiyun.com/article/details/110442898
hystrix-go的源码地址:https://github.com/afex/hystrix-go
下载:go get github.com/afex/hystrix-go/hystrix
开启一个简单的http服务svc
请求 /hello 会返回 hello,world
相关代码如下(svc.go):
package main
import (
"io"
"log"
"net/http"
)
func main() {
http.HandleFunc("/hello",helloServer)
log.Fatal(http.ListenAndServe(":18080",nil))
}
func helloServer(w http.ResponseWriter, req *http.Request) {
log.Println("request remote addr",req.RemoteAddr)
io.Writ