improve code quality

This commit is contained in:
Astone 2019-12-03 15:25:58 +08:00 committed by Vasiliy Tolstov
parent 4cba1b3ec9
commit e13e329abc

View File

@ -222,7 +222,9 @@ func (g *grpcServer) handler(srv interface{}, stream grpc.ServerStream) error {
// set the timeout if we have it // set the timeout if we have it
if len(to) > 0 { if len(to) > 0 {
if n, err := strconv.ParseUint(to, 10, 64); err == nil { if n, err := strconv.ParseUint(to, 10, 64); err == nil {
ctx, _ = context.WithTimeout(ctx, time.Duration(n)) var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, time.Duration(n))
defer cancel()
} }
} }