-
Notifications
You must be signed in to change notification settings - Fork 428
[async-await] Support for sending response headers via context #1262
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
[async-await] Support for sending response headers via context #1262
Conversation
Signed-off-by: Si Beaumont <[email protected]>
Signed-off-by: Si Beaumont <[email protected]>
Signed-off-by: Si Beaumont <[email protected]>
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.
@glbrntt I guess it's obvious but this changes the semantics as seen from the client. It used to be they would get an instant "reply" with the initial metadata. Now they don't get anything until the first response which means that, in the event that the user handler doesn't return anything before the deadline, the client will timeout.
Just wanted to call this out and confirm we expect, and are happy with, these semantics?
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.
@glbrntt I guess it's obvious but this changes the semantics as seen from the client. It used to be they would get an instant "reply" with the initial metadata. Now they don't get anything until the first response which means that, in the event that the user handler doesn't return anything before the deadline, the client will timeout.
Just wanted to call this out and confirm we expect, and are happy with, these semantics?
I think so, yes. This is what the C# and Go implementations do. Go also has a function to send headers directly.
As a follow up, I think we should add a note to initial metadata on the client to explain that it's not always the case that we'll receive them right away.
Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerCallContext.swift
Outdated
Show resolved
Hide resolved
Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerCallContext.swift
Outdated
Show resolved
Hide resolved
Signed-off-by: Si Beaumont <[email protected]>
Signed-off-by: Si Beaumont <[email protected]>
Signed-off-by: Si Beaumont <[email protected]>
Signed-off-by: Si Beaumont <[email protected]>
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, thanks Si!
…1262) The adopter may wish to set the response headers (aka "initial metadata") from their user handler. Until now this was not possible, even in the existing non–async-await API, and it was only possible for an adopter to set the trailers. This introduces a new mutable property to the context passed to the user handler that allows them to set the headers that should be sent back to the client before the first response message. * `let GRPCAsyncServerCallContext.headers` has been renamed to `requestHeaders` to disambiguate from newly introduced property. * `var GRPCAsyncServerCallContext.trailers` has been renamed to `responseTrailers` to better align with newly introduced property. * `var GRPCAsyncServerCallContext.responseHeaders` has been introduced.
…1262) The adopter may wish to set the response headers (aka "initial metadata") from their user handler. Until now this was not possible, even in the existing non–async-await API, and it was only possible for an adopter to set the trailers. This introduces a new mutable property to the context passed to the user handler that allows them to set the headers that should be sent back to the client before the first response message. * `let GRPCAsyncServerCallContext.headers` has been renamed to `requestHeaders` to disambiguate from newly introduced property. * `var GRPCAsyncServerCallContext.trailers` has been renamed to `responseTrailers` to better align with newly introduced property. * `var GRPCAsyncServerCallContext.responseHeaders` has been introduced.
The adopter may wish to set the response headers (aka "initial metadata") from their user handler. Until now this was not possible, even in the existing non–async-await API, and it was only possible for an adopter to set the trailers. This introduces a new mutable property to the context passed to the user handler that allows them to set the headers that should be sent back to the client before the first response message. * `let GRPCAsyncServerCallContext.headers` has been renamed to `requestHeaders` to disambiguate from newly introduced property. * `var GRPCAsyncServerCallContext.trailers` has been renamed to `responseTrailers` to better align with newly introduced property. * `var GRPCAsyncServerCallContext.responseHeaders` has been introduced.
The adopter may wish to set the response headers (aka "initial metadata") from their user handler. Until now this was not possible, even in the existing non–async-await API, and it was only possible for an adopter to set the trailers. This introduces a new mutable property to the context passed to the user handler that allows them to set the headers that should be sent back to the client before the first response message. * `let GRPCAsyncServerCallContext.headers` has been renamed to `requestHeaders` to disambiguate from newly introduced property. * `var GRPCAsyncServerCallContext.trailers` has been renamed to `responseTrailers` to better align with newly introduced property. * `var GRPCAsyncServerCallContext.responseHeaders` has been introduced.
The adopter may wish to set the response headers (aka "initial metadata") from their user handler. Until now this was not possible, even in the existing non–async-await API, and it was only possible for an adopter to set the trailers.
This introduces a new mutable property to the context passed to the user handler that allows them to set the headers that should be sent back to the client before the first response message.
let GRPCAsyncServerCallContext.headers
has been renamed torequestHeaders
to disambiguate from newly introduced property.var GRPCAsyncServerCallContext.trailers
has been renamed toresponseTrailers
to better align with newly introduced property.var GRPCAsyncServerCallContext.responseHeaders
has been introduced.