MCPcopy Index your code
hub / github.com/fullstorydev/grpcurl / invokeClientStream

Function invokeClientStream

invoke.go:193–245  ·  view source on GitHub ↗
(ctx context.Context, stub grpcdynamic.Stub, md *desc.MethodDescriptor, handler InvocationEventHandler,
	requestData RequestSupplier, req proto.Message)

Source from the content-addressed store, hash-verified

191}
192
193func invokeClientStream(ctx context.Context, stub grpcdynamic.Stub, md *desc.MethodDescriptor, handler InvocationEventHandler,
194 requestData RequestSupplier, req proto.Message) error {
195
196 // invoke the RPC!
197 str, err := stub.InvokeRpcClientStream(ctx, md)
198
199 // Upload each request message in the stream
200 var resp proto.Message
201 for err == nil {
202 err = requestData(req)
203 if err == io.EOF {
204 resp, err = str.CloseAndReceive()
205 break
206 }
207 if err != nil {
208 return fmt.Errorf("error getting request data: %v", err)
209 }
210
211 err = str.SendMsg(req)
212 if err == io.EOF {
213 // We get EOF on send if the server says "go away"
214 // We have to use CloseAndReceive to get the actual code
215 resp, err = str.CloseAndReceive()
216 break
217 }
218
219 req.Reset()
220 }
221
222 // finally, process response data
223 stat, ok := status.FromError(err)
224 if !ok {
225 // Error codes sent from the server will get printed differently below.
226 // So just bail for other kinds of errors here.
227 return fmt.Errorf("grpc call for %q failed: %v", md.GetFullyQualifiedName(), err)
228 }
229
230 if str != nil {
231 if respHeaders, err := str.Header(); err == nil {
232 handler.OnReceiveHeaders(respHeaders)
233 }
234 }
235
236 if stat.Code() == codes.OK {
237 handler.OnReceiveResponse(resp)
238 }
239
240 if str != nil {
241 handler.OnReceiveTrailers(stat, str.Trailer())
242 }
243
244 return nil
245}
246
247func invokeServerStream(ctx context.Context, stub grpcdynamic.Stub, md *desc.MethodDescriptor, handler InvocationEventHandler,
248 requestData RequestSupplier, req proto.Message) error {

Callers 1

InvokeRPCFunction · 0.85

Calls 5

SendMsgMethod · 0.80
OnReceiveHeadersMethod · 0.65
OnReceiveResponseMethod · 0.65
OnReceiveTrailersMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…