diff --git a/internal/net/grpc/context.go b/internal/net/grpc/context.go index 2e06fb7897..90e5ee32a6 100644 --- a/internal/net/grpc/context.go +++ b/internal/net/grpc/context.go @@ -20,30 +20,30 @@ import ( type contextKey string -// GrpcMethodContextKey represents a context key for grpc method. +// GRPCMethodContextKey represents a context key for gRPC method. // This is exported only for testing. -const GrpcMethodContextKey contextKey = "grpc_method" +const GRPCMethodContextKey contextKey = "grpc_method" // WrapGRPCMethod returns a copy of parent in which the method associated with key (grpcMethodContextKey). func WrapGRPCMethod(ctx context.Context, method string) context.Context { m := FromGRPCMethod(ctx) if m == "" { - return context.WithValue(ctx, GrpcMethodContextKey, method) + return context.WithValue(ctx, GRPCMethodContextKey, method) } if strings.HasSuffix(m, method) { return ctx } - return context.WithValue(ctx, GrpcMethodContextKey, m+"/"+method) + return context.WithValue(ctx, GRPCMethodContextKey, m+"/"+method) } // WithGRPCMethod returns a copy of parent in which the method associated with key (grpcMethodContextKey). func WithGRPCMethod(ctx context.Context, method string) context.Context { - return context.WithValue(ctx, GrpcMethodContextKey, method) + return context.WithValue(ctx, GRPCMethodContextKey, method) } // FromGRPCMethod returns the value associated with this context for key (grpcMethodContextKey). func FromGRPCMethod(ctx context.Context) string { - if v := ctx.Value(GrpcMethodContextKey); v != nil { + if v := ctx.Value(GRPCMethodContextKey); v != nil { if method, ok := v.(string); ok { return method } diff --git a/pkg/index/job/correction/service/corrector_test.go b/pkg/index/job/correction/service/corrector_test.go index 0f5b7f3dd7..91a6b2fd4c 100644 --- a/pkg/index/job/correction/service/corrector_test.go +++ b/pkg/index/job/correction/service/corrector_test.go @@ -456,7 +456,7 @@ func Test_correct_correctReplica(t *testing.T) { // check if the agents which need to be corrected are called with the required method // checking calling parameter, like timestamp, is impossible because its inside of the function arg m.client.AssertCalled(tt, "Do", tmock.MatchedBy(func(ctx context.Context) bool { - method := ctx.Value(grpc.GrpcMethodContextKey) + method := ctx.Value(grpc.GRPCMethodContextKey) val, ok := method.(string) if !ok { return false