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

WIP: Reduce the amount of bootstrap async methods #2474

Merged
merged 1 commit into from Jul 21, 2023

Conversation

FranzBusch
Copy link
Contributor

Motivation

When adding new async methods for all the bootstrap we had to create 3 sets of method for every bootstrap. This resulted in lots of code and only provided little benefit for users.

Modification

This PR removes all bind/connect methods except the most generic ones. This leaves it up to the user to wrap their channels in a NIOAsyncChannel or to await the protocol negotiation result.

Result

Less code to maintain on our side.

Comment on lines 281 to 285
for try await childChannel in channel.inboundStream {
for try await negotiationResult in channel.inboundStream {
group.addTask {
switch childChannel {
switch try await negotiationResult.resolve() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part here is the important change. Instead of having a NIOAsyncChannel of negotiation results we now have a channel of futures of negotiation results. This means that users have to resolve the result and can then decide what to do with it. It doesn't look too bad from a users perspective and allows us to significantly reduce the amount of code in NIO. cc @Lukasa @glbrntt @rnro

@FranzBusch FranzBusch marked this pull request as ready for review July 14, 2023 08:15
@FranzBusch FranzBusch force-pushed the fb-reduce-bootstraps branch 2 times, most recently from 8af30cb to c4f41b9 Compare July 17, 2023 09:06
# Motivation
When adding new async methods for all the bootstrap we had to create 3 sets of method for every bootstrap. This resulted in lots of code and only provided little benefit for users.

# Modification
This PR removes all bind/connect methods except the most generic ones. This leaves it up to the user to wrap their channels in a `NIOAsyncChannel` or to await the protocol negotiation result.

# Result
Less code to maintain on our side.
@Lukasa Lukasa added the 🔼 needs-minor-version-bump For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0 label Jul 21, 2023
@Lukasa Lukasa enabled auto-merge (squash) July 21, 2023 09:30
@FranzBusch FranzBusch disabled auto-merge July 21, 2023 10:00
@FranzBusch
Copy link
Contributor Author

  • 5.9 is a known allocation regression
  • Nightly is a known crash
  • API breakage is also expected

@Lukasa Could you merge this over the failing API breakage CI please

@Lukasa Lukasa merged commit e5416f4 into apple:main Jul 21, 2023
5 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔼 needs-minor-version-bump For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants