NewStream implements [grpc.ClientConnInterface].
(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption)
| 105 | |
| 106 | // NewStream implements [grpc.ClientConnInterface]. |
| 107 | func (conn *RPCConnection[T]) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (stream grpc.ClientStream, err error) { |
| 108 | // Make sure, this connection is established |
| 109 | err = conn.init() |
| 110 | if err != nil { |
| 111 | return |
| 112 | } |
| 113 | |
| 114 | // Then, just forward the request to the embedded client conn |
| 115 | stream, err = conn.cc.NewStream(ctx, desc, method, opts...) |
| 116 | if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) { |
| 117 | log.Debugf("Caught EOF while invoking method %s, forcing connection to reconnect on next call", method) |
| 118 | conn.ForceReconnect() |
| 119 | } |
| 120 | |
| 121 | return |
| 122 | } |
| 123 | |
| 124 | // init takes care of actually establishing the connection to the gRPC server. If the connection is already established, |
| 125 | // this is a no-op. This function is go-routine safe, because potentially multiple callers could access this at the same |
no test coverage detected