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

Expose listening address on HTTP2 server transport #1933

Merged
merged 6 commits into from
Jun 18, 2024

Conversation

gjcairo
Copy link
Collaborator

@gjcairo gjcairo commented Jun 14, 2024

Motivation

We should expose the listening address on the H2 server transports so that our client can connect to it.

Modifications

Exposed a listeningAddress async property. It will block until we bind or error, return the listening address while it's bound and listening, and throw an error when it's not listening anymore.

Result

We can now know what address our server transport's listening on for requests.

@gjcairo gjcairo requested a review from glbrntt June 14, 2024 11:20
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
public struct Posix: ServerTransport {
private let address: GRPCHTTP2Core.SocketAddress
private let config: Config
private let eventLoopGroup: MultiThreadedEventLoopGroup
private let serverQuiescingHelper: ServerQuiescingHelper

private let listeningAddressPromise:
_LockedValueBox<EventLoopPromise<GRPCHTTP2Core.SocketAddress>>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is slightly annoying, but I backed this by a box containing the promise because I didn't want to make listen a mutating func, and I need to mutate the promise when we exit listen's scope.

@gjcairo gjcairo force-pushed the server-transport-expose-listening-addr branch from f129b33 to 13de732 Compare June 14, 2024 13:12
@gjcairo gjcairo requested a review from glbrntt June 14, 2024 13:12
@gjcairo gjcairo added the v2 A change for v2 label Jun 17, 2024
@gjcairo gjcairo requested a review from glbrntt June 17, 2024 15:10
@gjcairo gjcairo force-pushed the server-transport-expose-listening-addr branch from 2d45390 to 092dbd3 Compare June 18, 2024 12:10
@gjcairo gjcairo requested a review from glbrntt June 18, 2024 12:12
@gjcairo gjcairo force-pushed the server-transport-expose-listening-addr branch from 092dbd3 to 0e2203a Compare June 18, 2024 12:25
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Gus!

@glbrntt glbrntt enabled auto-merge (squash) June 18, 2024 12:58
@glbrntt glbrntt merged commit 468a519 into grpc:main Jun 18, 2024
17 checks passed
@gjcairo gjcairo deleted the server-transport-expose-listening-addr branch June 18, 2024 13:30
clintonpi pushed a commit to clintonpi/grpc-swift that referenced this pull request Jun 18, 2024
Motivation:

We should expose the listening address on the H2 server transports so that our client can connect to it.

Modifications:

Exposed a `listeningAddress` async property. It will block until we bind or error, return the listening address while it's bound and listening, and throw an error when it's not listening anymore.

Result:

We can now know what address our server transport's listening on for requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 A change for v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants