(req *http.Request, resp T, maxSize int)
| 86 | } |
| 87 | |
| 88 | func (c GRPCCollector[T]) sendSegmented(req *http.Request, resp T, maxSize int) error { |
| 89 | // If no max, then send as-is. |
| 90 | if maxSize <= 0 { |
| 91 | return grpcError(c.send(resp)) |
| 92 | } |
| 93 | |
| 94 | // Split the response into smaller packets and send individually. |
| 95 | grpcPackets, err := c.combiner.GRPCSegment(resp, maxSize) |
| 96 | if err != nil { |
| 97 | return grpcError(err) |
| 98 | } |
| 99 | |
| 100 | for _, packet := range grpcPackets { |
| 101 | // While sending, check and return the context errors, like ctx cancelled, etc |
| 102 | if req.Context().Err() != nil { |
| 103 | return grpcError(req.Context().Err()) |
| 104 | } |
| 105 | |
| 106 | err = c.send(packet) |
| 107 | if err != nil { |
| 108 | return grpcError(err) |
| 109 | } |
| 110 | } |
| 111 | return nil |
| 112 | } |
| 113 | |
| 114 | func grpcError(err error) error { |
| 115 | // if is already a grpc err then just return. something with more context has already created a |
no test coverage detected