MCPcopy
hub / github.com/grpc/grpc-go / setPayload

Function setPayload

benchmark/benchmark.go:47–59  ·  view source on GitHub ↗

Allows reuse of the same testpb.Payload object.

(p *testpb.Payload, t testpb.PayloadType, size int)

Source from the content-addressed store, hash-verified

45
46// Allows reuse of the same testpb.Payload object.
47func setPayload(p *testpb.Payload, t testpb.PayloadType, size int) {
48 if size < 0 {
49 logger.Fatalf("Requested a response with invalid length %d", size)
50 }
51 body := make([]byte, size)
52 switch t {
53 case testpb.PayloadType_COMPRESSABLE:
54 default:
55 logger.Fatalf("Unsupported payload type: %d", t)
56 }
57 p.Type = t
58 p.Body = body
59}
60
61// NewPayload creates a payload with the given type and size.
62func NewPayload(t testpb.PayloadType, size int) *testpb.Payload {

Callers 3

NewPayloadFunction · 0.85
StreamingCallMethod · 0.85

Calls 1

FatalfMethod · 0.65

Tested by

no test coverage detected