ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 概述 dashboard 可视化hystrix的上报信息 ## 启动 hystrix-dashboard:latest 使用 docker 安装 ``` docker run -d -p 9002:9002 --name hystrix-dashboard \ mlabouardy/hystrix-dashboard:latest ``` ## code <details> <summary> main.go</summary> ``` package main import ( "github.com/afex/hystrix-go/hystrix" "net" "net/http" _ "net/http/pprof" ) func main() { hystrix.ConfigureCommand("my_command", hystrix.CommandConfig{ Timeout: 1000, MaxConcurrentRequests: 100, ErrorPercentThreshold: 25, }) hystrixStreamHandler := hystrix.NewStreamHandler() hystrixStreamHandler.Start() go func() { err := http.ListenAndServe(net.JoinHostPort("", "9096"), hystrixStreamHandler) if err != nil { panic(err) } }() http.HandleFunc("/test", func(resp http.ResponseWriter, req *http.Request) { output := make(chan bool, 1) errors := hystrix.Go("test", func() error { output <- true return nil }, nil) select { case <-output: resp.Write([]byte("success")) case err := <-errors: resp.Write([]byte(err.Error())) } }) err := http.ListenAndServe(":1234", nil) if err != nil { panic(err) } } ``` </details> <br /> ## 使用 浏览器访问 ``` http://127.0.0.1:9002/hystrix ``` 在框中输入 ``` http://192.168.31.20:9096/hystrix.stream ``` > 注意1: 输入的 IP 必须为局域网ip,而非 127.0.0.1 > 注意2: 直接访问 http://ip:9096/hystrix.stream 可能无法访问,需要先触发一次 http://ip:1234/test 的http 请求才行 ![](https://img.kancloud.cn/83/aa/83aa4902e6db527f871c28f929a2fb95_1210x776.png)