MCPcopy Create free account
hub / github.com/clouditor/clouditor / NewStream

Method NewStream

api/connection.go:107–122  ·  view source on GitHub ↗

NewStream implements [grpc.ClientConnInterface].

(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption)

Source from the content-addressed store, hash-verified

105
106// NewStream implements [grpc.ClientConnInterface].
107func (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

Callers 4

AssessEvidencesMethod · 0.80
StoreEvidencesMethod · 0.80

Calls 2

initMethod · 0.95
ForceReconnectMethod · 0.95

Tested by

no test coverage detected