3 Star 0 Fork 0

Gitee 极速下载 / logging-interceptor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/grpc-ecosystem/go-grpc-middleware
克隆/下载
backoff.go 608 Bytes
一键复制 编辑 原始数据 按行查看 历史
feliksik 提交于 2017-05-02 10:11 . Fix/jitter (#34)
// Copyright 2016 Michal Witkowski. All Rights Reserved.
// See LICENSE for licensing terms.
/*
Backoff Helper Utilities
Implements common backoff features.
*/
package backoffutils
import (
"math/rand"
"time"
)
// JitterUp adds random jitter to the duration.
//
// This adds or substracts time from the duration within a given jitter fraction.
// For example for 10s and jitter 0.1, it will returna time within [9s, 11s])
func JitterUp(duration time.Duration, jitter float64) time.Duration {
multiplier := jitter * (rand.Float64()*2 - 1)
return time.Duration(float64(duration) * (1 + multiplier))
}
1
https://gitee.com/mirrors/go-grpc-middleware.git
git@gitee.com:mirrors/go-grpc-middleware.git
mirrors
go-grpc-middleware
logging-interceptor
v1.0.0

搜索帮助