摘要:
使用中间件的方式包装日志输出 package Services import ( "context" "fmt" "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" "golang.org/x/time/rate" "gomicro/utils" "strconv" )... 阅读全文
摘要:
package Services import ( "context" "fmt" "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" "golang.org/x/time/rate" "gomicro/utils" "os" "strconv" ) typ... 阅读全文
摘要:
熔断器一般部署在客户端或者网关里面 封装到服务端 package main import ( "fmt" "github.com/afex/hystrix-go/hystrix" "gomicro2/util" "log" "time" ) func main() { configA := hystrix.CommandConfig{... 阅读全文
摘要:
package main import ( "fmt" "github.com/afex/hystrix-go/hystrix" "math/rand" "sync" "time" ) type Product struct { ID int Title string Price int } func getPro... 阅读全文
摘要:
熔断器控制最大并发数 package main import ( "fmt" "github.com/afex/hystrix-go/hystrix" "math/rand" "sync" "time" ) type Product struct { ID int Title string Price int } fun... 阅读全文
摘要:
异步执行和服务降级,使用hystrix.Go()函数的返回值是chan err package main import ( "fmt" "github.com/afex/hystrix-go/hystrix" "math/rand" "time" ) type Product struct { ID int Title string ... 阅读全文
摘要:
在hystrix的超时回调函数中处理超时推荐其他商品 package main import ( "errors" "fmt" "github.com/afex/hystrix-go/hystrix" "math/rand" "time" ) type Product struct { ID int Title string ... 阅读全文
摘要:
## 使用hystrix来实现监控超时 ```go package main import ( "fmt" "github.com/afex/hystrix-go/hystrix" "math/rand" "time" ) type Product struct { ID int Title string Price int... 阅读全文
摘要:
简单来说就是浏览器想要拿到最终的结果需要需要经过A,B,C三个节点,A调用B,B调用C最终返回结果,但是如果C崩溃了,我们应该怎么做呢 先模拟一个延迟调用的例子 package main import ( "fmt" "math/rand" "time" ) type Product struct { ID int Title st... 阅读全文
摘要:
自定义错误结构体 package utils type MyError struct { Code int Message string } func NewMyError(code int, msg string) error { return &MyError{Code: code, Messa 阅读全文