grpc-ecosystem / go-grpc-middleware

Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.
Apache License 2.0
6.29k stars 693 forks source link

Support extensibility of retry condition #686

Closed tamayika closed 9 months ago

tamayika commented 9 months ago

Currently grpc_retry supports retry condition by setting code.Codes. But it is good if retry condition is defined by error message, status details, etc...

So I propose below options.

// When returns true, it is retriable.
type RetriableFunc func(err error) bool

// WithRetriable sets which error should be retried.
// When this option is set, WithCodes is ignored.
func WithRetriable(ErrorFunc) CallOption