-
Notifications
You must be signed in to change notification settings - Fork 437
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
generated-code: update to include stream generics #1365
base: main
Are you sure you want to change the base?
Conversation
Cannot add reviewer, @purnesh42H please review |
@ejona86 can you take a look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to cross check here if we need to edit/add anything as we recently updated this https://github.com/grpc/grpc-go/blob/00b9e140ce71480ee7ecc6b85317021e0fe11fbb/stream_interfaces.go#L21
messages from the client. `Recv` returns `(nil, io.EOF)` once it has reached the end of the stream. | ||
The single response message from the server is sent by calling the `SendAndClose` method on this `<ServiceName>_FooServer` parameter. | ||
Note that `SendAndClose` must be called once and only once. | ||
The `grpc.ClientStreamingServer` has two methods `Recv()` and `SendAndClose(*MsgB)` , has an embedded `ServerStream`. The server-side handler can repeatedly call `Recv` on `<ServiceName>_FooServer` 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. The single response message from the server is sent by calling the `SendAndClose` method on this `<ServiceName>_FooServer` parameter. Note that `SendAndClose` must be called once and only once. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SendAndClose(*MsgB)
, -> SendAndClose(*MsgB)
,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
In this context, `<ServiceName>_FooClient` represents the server-to-client `stream` of `MsgB` messages. | ||
In this context, `grpc.ServerStreamClient` represents the client side of server-to-client stream of `MsgB` messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like there is extra space after grpc.ServerStreamClient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply the comments throughout, and please review your changes for correctness in light of all the typos. Thanks!
|
||
`Foo(*MsgA, <ServiceName>_FooServer) error` | ||
In this context, `MsgA` is the single request from the client, and , and `grpc.ServerStreamingServer` represents the server side of server-to-client stream of response type `MsgB`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also an extra space in the server side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
of `MsgB` messages. | ||
|
||
`<ServiceName>_FooServer` has an embedded `grpc.ServerStream` and the following interface: | ||
`<ServiceName>_FooServer` has a `grpc.SreverStreamingServer` interface that takes `MsgB` i.e. the response type as the input: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Srever -> Server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
of `MsgB` messages. | ||
|
||
`<ServiceName>_FooServer` has an embedded `grpc.ServerStream` and the following interface: | ||
`<ServiceName>_FooServer` has a `grpc.SreverStreamingServer` interface that takes `MsgB` i.e. the response type as the input: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar: please use commas:
MsgB
, i.e. the response type, as the input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
``` | ||
|
||
The server-side handler can send a stream of protobuf messages to the client through this parameter's `Send` method. End-of-stream for the server-to-client | ||
stream is caused by the `return` of the handler method. | ||
The `grpc.SreverStreamingServer` has a `Send(*MsgB)` method and has `ServerStream` embedded in it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Send(*MsgB) error | ||
grpc.ServerStream | ||
} | ||
type <ServiceName>_FooServer = grpc.ServerStreamingServer[*MsgB] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put documentation for the ServerStreamingServer
here instead and leave out this leftover type alias, which is only there for backward compatibility. We can probably rely heavily on the existing documentation, or maybe even just link it: https://pkg.go.dev/google.golang.org/grpc#ServerStreamingServer
|
||
`<ServiceName>_FooClient` has an embedded `grpc.ClientStream` and the following interface: | ||
`<ServiceName>_FooServe`r has a `grpc.ClientStreamingClient` interface that takes `MsgA` and `MsgB` as input: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Fixes task 3 : grpc-go issue #1894 - update the grpc.io docs to use generics instead of generated interfaces.