Skip to content
Merged
Changes from 23 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
52 changes: 52 additions & 0 deletions stream_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,27 @@ package grpc
// ServerStreamingClient represents the client side of a server-streaming (one
// request, many responses) RPC. It is generic over the type of the response
// message. It is used in generated code.
//
// The error returned will be compatible to the status package.
type ServerStreamingClient[Res any] interface {
// Recv receives the next message from the server. The client can repeatedly
// call Recv to read messages from the server-to-client response stream.
// Recv returns (nil, io.EOF) once the server-to-client stream is completely
// read.
Recv() (*Res, error)
ClientStream
}

// ServerStreamingServer represents the server side of a server-streaming (one
// request, many responses) RPC. It is generic over the type of the response
// message. It is used in generated code.
//
// The error returned will be compatible to the status package.
// End-of-stream for the server-to-client stream is indicated by the return
// of the handler method.
type ServerStreamingServer[Res any] interface {
// Send can send a stream of messages to the client. Server handler may call
// Send multiple times to send multiple messages to the client.
Send(*Res) error
ServerStream
}
Expand All @@ -38,8 +50,17 @@ type ServerStreamingServer[Res any] interface {
// requests, one response) RPC. It is generic over both the type of the request
// message stream and the type of the unary response message. It is used in
// generated code.
//
// The error returned will be compatible to the status package.
type ClientStreamingClient[Req any, Res any] interface {
// Send sends a request message to the server. The client can repeatedly
// call Send to send messages as part of the client-to-server request stream.
Send(*Req) error

// CloseAndRecv closes the client-to-server request stream and waits for the
// server's unary response. This method must be called once and only once
// after sending all request messages to close the stream and receive the
// final response from the server.
CloseAndRecv() (*Res, error)
ClientStream
}
Expand All @@ -48,8 +69,18 @@ type ClientStreamingClient[Req any, Res any] interface {
// requests, one response) RPC. It is generic over both the type of the request
// message stream and the type of the unary response message. It is used in
// generated code.
//
// The error returned will be compatible to the status package.
type ClientStreamingServer[Req any, Res any] interface {
// Recv reads a request message from the client. This method can be called
// repeatedly to receive the full stream of messages from the client. Recv
// returns (nil, io.EOF) once the end of the stream is reached.
Recv() (*Req, error)

// SendAndClose sends a single response message to the client and closes the
// stream. This method must be called once and only once after all request
// messages have been processed. No further methods should be called after
// SendAndClose.
SendAndClose(*Res) error
ServerStream
}
Expand All @@ -58,8 +89,19 @@ type ClientStreamingServer[Req any, Res any] interface {
// (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.
//
// The error returned will be compatible to the status package.
// End-of-stream for the client-to-server stream can be indicated by calling
// the CloseSend method.
type BidiStreamingClient[Req any, Res any] interface {
// Send sends a message to the server. This method can be called repeatedly
// to send messages as part of the client-to-server request stream.
Send(*Req) error

// Recv receives the next message from the server's response stream. This
// method can be called repeatedly to receive all messages sent by the
// server. Recv returns (nil, io.EOF) once the server-to-client stream is
// completely read.
Recv() (*Res, error)
ClientStream
}
Expand All @@ -68,8 +110,18 @@ type BidiStreamingClient[Req any, Res any] interface {
// (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.
//
// The error returned will be compatible to the status package.
// The end of the response stream is indicated by the return of the bidi
// method handler.
type BidiStreamingServer[Req any, Res any] interface {
// Recv receives a request message from the client. The server-side handler
// can repeatedly call Recv to read the request message stream. Recv returns
// (nil, io.EOF) once the end of the client-to-server stream is reached.
Recv() (*Req, error)

// Send sends a response message to the client. The server-side handler can
// repeatedly call Send to write to the server-to-client message stream.
Send(*Res) error
ServerStream
}
Expand Down