MCPcopy
hub / github.com/grafana/dskit / callToStreaming

Function callToStreaming

server/limits_test.go:67–91  ·  view source on GitHub ↗
(msgsPerStreamCall int)

Source from the content-addressed store, hash-verified

65}
66
67func callToStreaming(msgsPerStreamCall int) func(ctx context.Context, c FakeServerClient) error {
68 return func(ctx context.Context, c FakeServerClient) error {
69 rcvd := 0
70 s, err := c.StreamSleep(ctx, &emptypb.Empty{})
71 if err != nil {
72 return err
73 }
74
75 for {
76 _, err := s.Recv()
77 if err != nil {
78 if errors.Is(err, io.EOF) {
79 break
80 }
81 return err
82 }
83 rcvd++
84 }
85
86 if rcvd != msgsPerStreamCall {
87 return fmt.Errorf("invalid number of received messages: %d", rcvd)
88 }
89 return nil
90 }
91}
92
93func TestGrpcLimitCheckUnary(t *testing.T) {
94 const msgsPerStreamCall = 5

Callers 2

TestGrpcLimitCheckUnaryFunction · 0.85

Calls 4

IsMethod · 0.80
ErrorfMethod · 0.80
StreamSleepMethod · 0.65
RecvMethod · 0.65

Tested by

no test coverage detected