4
0

update timeout invoker

This commit is contained in:
dc.To 2025-06-27 14:37:24 +08:00
parent c680bd2d5e
commit ccf5df87e7

View File

@ -18,19 +18,18 @@ import (
* @version 20250409 * @version 20250409
*/ */
func ClientTimeoutInvokerChain(ctx context.Context, method string, req, res interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { func ClientTimeoutInvokerChain(ctx context.Context, method string, req, res interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
ctx, cancel := context.WithTimeout(ctx, 3*time.Second) ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel() defer cancel()
return invoker(ctx, method, req, res, cc, opts...) return invoker(ctx, method, req, res, cc, opts...)
} }
/** /**
* 上下文拦截 * 上下文调用
* @param void * @param void
* @author dc.To * @author dc.To
* @version 20250424 * @version 20250424
*/ */
func ClientContextInvokerChain(ctx context.Context, method string, req, res interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { func ClientContextInvokerChain(ctx context.Context, method string, req, res interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
return invoker(ctx, method, req, nil, cc, opts...) return invoker(ctx, method, req, nil, cc, opts...)
} }
@ -41,7 +40,6 @@ func ClientContextInvokerChain(ctx context.Context, method string, req, res inte
* @version 20250425 * @version 20250425
*/ */
func ClientContextUnaryChain(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { func ClientContextUnaryChain(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
return handler(ctx, req) return handler(ctx, req)
} }