go hystrix time out

 一般使用 hystrix.Do来跟踪请求,需要传入请求名,所以正则匹配一下想要自定义配置的请求名。然后这样:

这是go-hystrix下doc.go里面的内容,vender源码到项目的好处之一是可以轻松查看框架资料!

Synchronous API


Since calling a command and immediately waiting for it to finish is a common pattern, a synchronous API is available with the Do function which returns a single error.

err := hystrix.Do("my_command", func() error {
// talk to other services
return nil
}, nil)

Configure settings

During application boot, you can call ConfigureCommand to tweak the settings for each command.

hystrix.ConfigureCommand("my_command", hystrix.CommandConfig{
Timeout: 1000,
MaxConcurrentRequests: 100,
ErrorPercentThreshold: 25,
})

You can also use Configure which accepts a map[string]CommandConfig.


 
 
 
posted @ 2020-09-03 18:11  埃姆提斯  阅读(170)  评论(0)    收藏  举报