feat: use breaker with ctx to prevent deadline exceeded (#4091)

Signed-off-by: kevin <wanjunfeng@gmail.com>
This commit is contained in:
Kevin Wan
2024-04-18 23:18:49 +08:00
committed by GitHub
parent 1b9b61f505
commit d371ab5479
8 changed files with 47 additions and 53 deletions

View File

@@ -13,7 +13,7 @@ import (
func BreakerInterceptor(ctx context.Context, method string, req, reply any,
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
breakerName := path.Join(cc.Target(), method)
return breaker.DoWithAcceptable(breakerName, func() error {
return breaker.DoWithAcceptableCtx(ctx, breakerName, func() error {
return invoker(ctx, method, req, reply, cc, opts...)
}, codes.Acceptable)
}