MCPcopy Create free account
hub / github.com/cortexproject/cortex / Push

Method Push

integration/grpc_server_test.go:60–73  ·  view source on GitHub ↗
(ctx context.Context, request *cortexpb.WriteRequest)

Source from the content-addressed store, hash-verified

58}
59
60func (m mockGprcServer) Push(ctx context.Context, request *cortexpb.WriteRequest) (*cortexpb.WriteResponse, error) {
61 defer request.Free()
62 time.Sleep(time.Duration(rand.Int31n(100)) * time.Millisecond)
63 md, _ := metadata.FromIncomingContext(ctx)
64 i, _ := strconv.Atoi(md["i"][0])
65 expected := createRequest(i)
66 // Need to do this so the .String method return the same value for MessageWithBufRef
67 expected.MessageWithBufRef = request.MessageWithBufRef
68
69 if expected.String() != request.String() {
70 return nil, fmt.Errorf("expected %v, got %v", expected, request)
71 }
72 return &cortexpb.WriteResponse{}, nil
73}
74
75func run(t testing.TB, cfg server.Config, register func(s *grpc.Server), validate func(t testing.TB, con *grpc.ClientConn)) {
76 savedRegistry := prometheus.DefaultRegisterer

Callers 1

PushStreamMethod · 0.95

Calls 3

FreeMethod · 0.80
createRequestFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected