flowtoken
所属分类:WEB开发
开发工具:GO
文件大小:4KB
下载次数:0
上传日期:2018-09-30 03:32:41
上 传 者:
sh-1993
说明: 与大多数断路器一样,flowtoken是请求流控制器。
(flowtoken is a request flow controller, like most circuit breaker.)
文件列表:
flowtoken.go (7877, 2018-09-30)
flowtoken_test.go (5187, 2018-09-30)
# flowtoken
flowtoken is a request flow controller, it can adjust flow threshold automatically based on success rate per second.
# usage
```
conf := &flowtoken.Config{
InitCwnd: 10000,
MinCwnd: 10,
},
// New flowtoken
ft := flowtoken.NewFlowToken("192.168.1.10:10000", conf)
// Get token from flowtoken
token, err := ft.GetToken()
_, ok := IsTokenExhaustedError(err)
if ok {
// token exhausted, it may reach the traffic threshold.
...
return
}
// request service
err = call(...)
if err == nil{
//Report succ to flowtoken
token.Succ()
} else{
//Report fail to flowtoken
token.Fail()
}
```
近期下载者:
相关文件:
收藏者: