Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc: add docs for generic stream interfaces #7470

Merged
merged 26 commits into from
Aug 29, 2024
Merged
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
def75b6
Adding Inline comments for stream interfaces in stream_interfaces.go
janardhanvissa Aug 1, 2024
19dcd9b
Updating the Inline comments for stream interface in detail
janardhanvissa Aug 1, 2024
9795302
Removing Inline comments for parent interfaces(ClientStream,ServerStr…
janardhanvissa Aug 2, 2024
d56889f
Updating the description of stream interfaces in stream_interfaces.go…
janardhanvissa Aug 7, 2024
5b08be9
Updated the description as per the comments
janardhanvissa Aug 8, 2024
fc8da54
Updating the description as per the comments addressed
janardhanvissa Aug 9, 2024
8309894
Updating the description as per the comments addressed
janardhanvissa Aug 11, 2024
2403e3c
Reverting generated code line
janardhanvissa Aug 12, 2024
3874b04
Removing extra space in generated code line
janardhanvissa Aug 12, 2024
5eb8eda
Updated the stream interfaces description as per the documentation an…
janardhanvissa Aug 13, 2024
49eb9d2
Moving error and end of stream to interface docstring
janardhanvissa Aug 14, 2024
1db4de7
dummy commit for re-trigger
janardhanvissa Aug 14, 2024
921241a
Moved bidi handler line to interface docstring, updated the send in s…
janardhanvissa Aug 14, 2024
ed434dc
Fixed linter issues for superfluous-else, increment-decrement, indent…
janardhanvissa Aug 14, 2024
3ea5488
Reverting context-as-argument in server.go
janardhanvissa Aug 14, 2024
7beda74
Merge pull request #1 from janardhanvissa/linter-godoc
janardhanvissa Aug 18, 2024
bd44787
Revert "Optimising the code by fixing var-declaration, indent-error-f…
janardhanvissa Aug 18, 2024
c3dfaaf
Merge pull request #4 from janardhanvissa/revert-1-linter-godoc
janardhanvissa Aug 18, 2024
76cbb5c
Merge branch 'master' of https://github.com/janardhanvissa/grpc-go in…
janardhanvissa Aug 22, 2024
7b41ccd
Formatting comments and updating the docstring
janardhanvissa Aug 22, 2024
a009b7c
Formatting comments
janardhanvissa Aug 22, 2024
ea1eabd
Updated the description by adding newline before the sentence.
janardhanvissa Aug 22, 2024
10122ac
updating file for format description
janardhanvissa Aug 22, 2024
2d54e07
Doc updates
dfawley Aug 28, 2024
335eaee
Remove leading spaces
dfawley Aug 28, 2024
6649fa6
Add comment to explain how to close streams from Servers
dfawley Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions stream_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ package grpc
// request, many responses) RPC. It is generic over the type of the response
// message. It is used in generated code.
purnesh42H marked this conversation as resolved.
Show resolved Hide resolved
type ServerStreamingClient[Res any] interface {
// Recv receives the next message from the server in the stream. The type of
// message is determined by the Res type parameter of the ServerStreamingClient.
// The client can repeatedly call the Recv method on the returned ServerStreamingClient
// stream in order to read the server-to-client response stream. This Recv method returns
// (nil, io.EOF) once the server-to-client stream has been completely read through.
janardhanvissa marked this conversation as resolved.
Show resolved Hide resolved
Recv() (*Res, error)
ClientStream
}
Expand All @@ -30,6 +35,12 @@ type ServerStreamingClient[Res any] interface {
// request, many responses) RPC. It is generic over the type of the response
// message. It is used in generated code.
type ServerStreamingServer[Res any] interface {
// Send sends a response message to the client. This method is called to
// send each individual message as part of the server's response stream.
// It takes a pointer to the response message of type Res and returns an error if
// there was an issue sending the message. The server-side handler can send a
// stream of protobuf messages to the client through this parameter’s Send method.
janardhanvissa marked this conversation as resolved.
Show resolved Hide resolved
// End-of-stream for the server-to-client stream is caused by the return of the handler method.
janardhanvissa marked this conversation as resolved.
Show resolved Hide resolved
Send(*Res) error
ServerStream
}
Expand All @@ -39,7 +50,21 @@ type ServerStreamingServer[Res any] interface {
// message stream and the type of the unary response message. It is used in
// generated code.
type ClientStreamingClient[Req any, Res any] interface {
// Send sends a request message to the server. This method is called repeatedly to
// send all messages as part of the client’s request stream. The type of message is
// determined by the Req type parameter of the ClientStreamingClient. The client can
// repeatedly call the Send method on the returned ClientStreamingClient stream in
// order to send the client-to-server message stream. It returns an error if the
// message could not be sent.
Send(*Req) error

// CloseAndRecv closes the sending side of the request stream and waits for the server
// to send a unary response message. This method is typically called after sending all
// request messages to signal the end of the stream and to receive the final response
// from the server. The response message type is determined by the Res type parameter
// of the ClientStreamingClient. The CloseAndRecv method on this stream must be called
// once and only once, in order to both close the client-to-server stream and receive
// the single response message from the server.
CloseAndRecv() (*Res, error)
ClientStream
}
Expand All @@ -49,7 +74,20 @@ type ClientStreamingClient[Req any, Res any] interface {
// message stream and the type of the unary response message. It is used in
// generated code.
type ClientStreamingServer[Req any, Res any] interface {
// Recv reads a request message from the client. This method is called repeatedly
// to receive all messages sent by the client as part of the request stream.
// by the Req type parameter of the ClientStreamingServer. The server-side handler
// can repeatedly call Recv on this parameter in order to receive the full stream
// of messages from the client. Recv returns (nil, io.EOF) once it has reached
// the end of the stream.
Recv() (*Req, error)

// SendAndClose sends the unary response message to the client and closes the stream.
// This method is typically called after processing all request messages from the client
// to send the final response and close the stream. The single response message from
// the server is sent by calling the SendAndClose method on this ClientStreamingServer
purnesh42H marked this conversation as resolved.
Show resolved Hide resolved
// parameter. It returns an error if the response could not be sent. SendAndClose must
// be called once and only once to complete the RPC.
SendAndClose(*Res) error
ServerStream
}
Expand All @@ -59,7 +97,22 @@ type ClientStreamingServer[Req any, Res any] interface {
// 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 single message to the server. This method is called repeatedly
// to send all messages as part of the client’s request stream. The type of message
// is determined by the Req type parameter of the BidiStreamingClient. The client
// can repeatedly call the Send method on the returned BidiStreamingClient stream
// in order to send the client-to-server message stream. It returns an error
// if the message could not be sent.
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 type of
// message is determined by the Res type parameter of the BidiStreamingClient.
// The client can repeatedly call Recv on this stream in order to receive the
// full server-to-client message stream. End-of-stream for the server-to-client
// stream is indicated by a return value of (nil, io.EOF) on the Recv method of
// the stream. 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
}
Expand All @@ -69,7 +122,18 @@ type BidiStreamingClient[Req any, Res any] interface {
// 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. The type of message is determined by the Req type parameter
// of the BidiStreamingServer. 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 type of message is determined by the
// Res type parameter of the BidiStreamingServer. It returns an error if the message could not
// be sent. The response server-to-client message stream is sent by repeatedly calling
// the Send method of on this BidiStreamingServer parameter. The end-of-stream for the
// server-to-client stream is indicated by the return of the bidi streaming method handler.
Send(*Res) error
ServerStream
}
Expand Down
Loading