chore: reorg imports, format code, make MaxRetires default to 0 (#1165)
* chore: reverse the order of stopping services * chore: reverse the order of stopping services * chore: reorg imports, format code * chore: format code, and refactor * feat: change MaxRetries default to 0, disable retry
This commit is contained in:
@@ -2,16 +2,22 @@ package clientinterceptors
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/retry"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// RetryInterceptor retry interceptor
|
||||
func RetryInterceptor(enable bool) grpc.UnaryClientInterceptor {
|
||||
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
if !enable {
|
||||
if !enable {
|
||||
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
return retry.Do(ctx, func(ctx context.Context, callOpts ...grpc.CallOption) error {
|
||||
return invoker(ctx, method, req, reply, cc, callOpts...)
|
||||
}, opts...)
|
||||
|
||||
Reference in New Issue
Block a user