grpc.WithConnectParams.Backoff和grpc_retry.WithBackoff之间有什么区别?

huangapple go评论104阅读模式
英文:

What is the difference between grpc.WithConnectParams.Backoff and grpc_retry.WithBackoff?

问题

我正在尝试理解两种GRPC重试的方式之间的区别。

一种是grpc.WithConnectParams,例如:

grpc.Dial(address, grpc.WithConnectParams(grpc.ConnectParams{
	Backoff: backoff.Config{
		BaseDelay:   1 * time.Second,
		Multiplier:  1.6,
		MaxDelay:    15 * time.Second,
	},
}))

另一种是:

grpc.Dial(address, []grpc_retry.CallOption{
	grpc_retry.WithMax(4),
	grpc_retry.WithBackoff(grpc_retry.BackoffExponential(1 * time.Second)),
})

第一种方式的文档在这里:

https://pkg.go.dev/google.golang.org/grpc/backoff

另一种方式的文档在这里:

https://pkg.go.dev/github.com/grpc-ecosystem/go-grpc-middleware/retry

它们似乎做着相同的事情...?我不太确定。

英文:

I am trying to understand what is the difference between two GRPC ways to do a retry.

One is grpc.WithConnectParams; that is, let's say

grpc.Dial(address, grpc.WithConnectParams(grpc.ConnectParams{
	Backoff: backoff.Config{
		BaseDelay: 1 * time.Second,
		Multiplier: 1.6,
		MaxDelay: 15*time.Second,
	}))

vs

grpc.Dial(address, []grpc_retry.CallOption{
	grpc_retry.WithMax(4),
	grpc_retry.WithBackoff(grpc_retry.BackoffExponential(1*time.Second)),
})

The first one is documented here

https://pkg.go.dev/google.golang.org/grpc/backoff

The other is documented here

https://pkg.go.dev/github.com/grpc-ecosystem/go-grpc-middleware/retry

They seem like doing the same thing...? I am not exactly sure

答案1

得分: 0

grpc.WithConnectParams.Backoff在“低级别”上进行重试,即连接级别;而grpc_retry.CallOption在请求级别上进行重试。

英文:

grpc.WithConnectParams.Backoff does retries on the "low level" - the connection level; while grpc_retry.CallOption does retries on the request level.

huangapple
  • 本文由 发表于 2021年10月28日 22:18:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/69755775.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定