-
Notifications
You must be signed in to change notification settings - Fork 414
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
Allow to write a sequence of requests/responses #1499
Conversation
@inlinable | ||
public func send<S: Sequence>( | ||
contentsOf requests: S | ||
) async throws where S.Element == (Request, Compression) { | ||
try await self.asyncWriter.yield(contentsOf: requests) | ||
} |
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.
@Lukasa @fabianfett What do you think about using the tuple here? Do you prefer creating a new type like MessageWithCompression
?
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.
I'm almost always in opposition to tuples: nominal types FTW.
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.
Fine either way. But generally structs are the better choice for evolving types and APIs. Name should probably be MessageAndCompression
? With sounds like the message was already compressed.
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.
Actually I changed the API a bit for now where you can write a sequence of requests/responses and set the compression for all of them. If users ever want to write a sequence with different compression per request/response we can still add that API. WDYT?
70c5afe
to
a56ff4c
Compare
# Motivation We recently adopted the `NIOAsyncWriter` to back the `GRPCAsyncRequestStreamWriter` and the `GRPCAsyncResponseStreamWriter`; however, we did not expose the functionality to write a sequence of the elements that the `NIOAsyncWriter` offers. This can be useful in cases where you want to write a batch of requests/responses since it reduces the amount of locks and thread hops. # Modification Expose new methods on the `GRPCAsyncRequestStreamWriter` and the `GRPCAsyncResponseStreamWriter` to enable to write a sequence. I also fixed up the comments for the `GRPCAsyncRequestStreamWriter` since they were outdated. # Result Users can write a batch of requests/responses.
a56ff4c
to
2633ad2
Compare
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.
Can we get a unit test to prove this works?
* Allow to write a sequence of requests/responses # Motivation We recently adopted the `NIOAsyncWriter` to back the `GRPCAsyncRequestStreamWriter` and the `GRPCAsyncResponseStreamWriter`; however, we did not expose the functionality to write a sequence of the elements that the `NIOAsyncWriter` offers. This can be useful in cases where you want to write a batch of requests/responses since it reduces the amount of locks and thread hops. # Modification Expose new methods on the `GRPCAsyncRequestStreamWriter` and the `GRPCAsyncResponseStreamWriter` to enable to write a sequence. I also fixed up the comments for the `GRPCAsyncRequestStreamWriter` since they were outdated. # Result Users can write a batch of requests/responses. * Update tests
* Allow to write a sequence of requests/responses # Motivation We recently adopted the `NIOAsyncWriter` to back the `GRPCAsyncRequestStreamWriter` and the `GRPCAsyncResponseStreamWriter`; however, we did not expose the functionality to write a sequence of the elements that the `NIOAsyncWriter` offers. This can be useful in cases where you want to write a batch of requests/responses since it reduces the amount of locks and thread hops. # Modification Expose new methods on the `GRPCAsyncRequestStreamWriter` and the `GRPCAsyncResponseStreamWriter` to enable to write a sequence. I also fixed up the comments for the `GRPCAsyncRequestStreamWriter` since they were outdated. # Result Users can write a batch of requests/responses. * Update tests
Motivation
We recently adopted the
NIOAsyncWriter
to back theGRPCAsyncRequestStreamWriter
and theGRPCAsyncResponseStreamWriter
; however, we did not expose the functionality to write a sequence of the elements that theNIOAsyncWriter
offers. This can be useful in cases where you want to write a batch of requests/responses since it reduces the amount of locks and thread hops.Modification
Expose new methods on the
GRPCAsyncRequestStreamWriter
and theGRPCAsyncResponseStreamWriter
to enable to write a sequence. I also fixed up the comments for theGRPCAsyncRequestStreamWriter
since they were outdated.Result
Users can write a batch of requests/responses.