Repository: grpc/grpc-go
File: stream_interfaces.go (Go)

Code before:
	// occurs on the stream, it will be returned as an instance of the 'status'
	// package. Refer to the 'status' package documentation for more details.
	Send(*Req) error

	// Recv receives the next message from the server's response stream. This method
	// is called repeatedly to receive all messages sent by the server. The client can
	// repeatedly call Recv on this stream in order to receive the full server-to-client
	// message stream. If an error occurs on the stream, it will be returned as an instance
	// of the 'status' package. Refer to the 'status' package documentation for more details.
	// End-of-stream for the client-to-server stream can be indicated from the client by
	// calling the CloseSend method on the stream.
	Recv() (*Res, error)
	ClientStream
}

// BidiStreamingServer represents the server side of a bidirectional-streaming
// (many requests, many responses) RPC. It is generic over both the type of the
// request message stream and the type of the response message stream. It is
// used in generated code.
type BidiStreamingServer[Req any, Res any] interface {
	// Recv receives a request message from the client. The server-side handler can
	// repeatedly call Recv on this parameter in order to read the client-to-server
	// message stream. If an error occurs on the stream, it will be returned as an
	// instance of the 'status' package. Refer to the 'status' package documentation
	// for more details.Recv returns (nil, io.EOF) once it has reached the end of the
	// client-to-server stream. when the client has finished sending messages.
	Recv() (*Req, error)

	// Send sends a response message to the client. The response server-to-client
	// message stream is sent by repeatedly calling the Send method of on this
	// BidiStreamingServer parameter. If an error occurs on the stream, it will be
	// returned as an instance of the 'status' package. Refer to the 'status' package
	// documentation for more details. No further methods on this interface should be
	// called afterward.
	Send(*Res) error
	ServerStream
}

// GenericClientStream implements the ServerStreamingClient, ClientStreamingClient,
// and BidiStreamingClient interfaces.
type GenericClientStream[Req any, Res any] struct {
	ClientStream
}

var _ ServerStreamingClient[string] = (*GenericClientStream[int, string])(nil)
var _ ClientStreamingClient[int, string] = (*GenericClientStream[int, string])(nil)
var _ BidiStreamingClient[int, string] = (*GenericClientStream[int, string])(nil)

// Send pushes one message into the stream of requests to be consumed by the
// server. The type of message which can be sent is determined by the Req type
// parameter of the GenericClientStream receiver.

Review comment (suggestion):
no need to say `client-to-server`. Interface documentation clarifies it is a server side stream.

Also, what is the purpose of `when the client has finished sending messages` sentence? Seems incomplete

Code after:
}

// BidiStreamingClient represents the client side of a bidirectional-streaming
// (many requests, many responses) RPC. It is generic over both the type of the
// request message stream and the type of the response message stream. It is
// used in generated code.
type BidiStreamingClient[Req any, Res any] interface {
	// Send sends a request message to the server.  The client may call Send
	// multiple times to send multiple messages to the server.  On error, Send
	// aborts the stream.  If the error was generated by the client, the status
	// is returned directly.  Otherwise, io.EOF is returned, and the status of
	// the stream may be discovered using Recv().
	Send(*Req) error

	// Recv receives the next response message from the server. The client may
	// repeatedly call Recv to read messages from the response stream.  If
	// io.EOF is returned, the stream has terminated with an OK status.  Any
	// other error is compatible with the status package and indicates the
	// RPC's status code and message.
	Recv() (*Res, error)

	// ClientStream is embedded to provide Context, Header, Trailer, and
	// CloseSend functionality.  No other methods in the ClientStream should be
	// called directly.
	ClientStream
}

// BidiStreamingServer represents the server side of a bidirectional-streaming
// (many requests, many responses) RPC. It is generic over both the type of the
// request message stream and the type of the response message stream. It is
// used in generated code.
//
// To terminate the stream, return from the handler method and return
// an error from the status package, or use nil to indicate an OK status code.
type BidiStreamingServer[Req any, Res any] interface {
	// Recv receives the next request message from the client.  The server may
	// repeatedly call Recv to read messages from the request stream.  If
	// io.EOF is returned, it indicates the client called CloseSend on its
	// BidiStreamingClient.  Any other error indicates the stream was
	// terminated unexpectedly, and the handler method should return, as the
	// stream is no longer usable.
	Recv() (*Req, error)

	// Send sends a response message to the client.  The server handler may
	// call Send multiple times to send multiple messages to the client.  An
	// error is returned if the stream was terminated unexpectedly, and the
	// handler method should return, as the stream is no longer usable.
	Send(*Res) error

	// ServerStream is embedded to provide Context, SetHeader, SendHeader, and
	// SetTrailer functionality.  No other methods in the ServerStream should