该cloud.google.com/go/pubsub
库最近发布(在 v1.5.0 中,参见https://github.com/googleapis/google-cloud-go/releases/tag/pubsub%2Fv1.5.0)支持新的RetryPolicy
服务器端功能。当前的文档(https://godoc.org/cloud.google.com/go/pubsub#RetryPolicy)为
我读过维基百科的文章,虽然它描述了离散时间的指数退避,但我看不出这篇文章与MinimumBackoff和MaximumBackoff参数的具体关系。有关这方面的指导,我参考了github.com/cenkalti/backoffhttps://pkg.go.dev/github.com/cenkalti/backoff/v4?tab=doc#ExponentialBackOff的文档。该库定义ExponentialBackoff为
type ExponentialBackOff struct {
InitialInterval time.Duration
RandomizationFactor float64
Multiplier float64
MaxInterval time.Duration
// After MaxElapsedTime the ExponentialBackOff returns Stop.
// It never stops if MaxElapsedTime == 0.
MaxElapsedTime time.Duration
Stop time.Duration
Clock Clock
// contains filtered or unexported fields
}
其中每个随机间隔计算为
randomized interval =
RetryInterval * (random value in range [1 - RandomizationFactor, 1 + RandomizationFactor])
RetryInterval当前的重试间隔在哪里,据我所知,它从 的值开始并以InitialInterval为上限MaxInterval。
我是否正确理解MinimumBackoffandMaximumBackoff对应于InitialIntervaland MaxIntervalin github.com/cenkalti/backoff?也就是说,MinimumBackoff是初始等待时间,MaximumBackoff是重试之间允许的最大时间量?
忽然笑
相关分类