-
Notifications
You must be signed in to change notification settings - Fork 20
Surface transient channel errors #11
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
Conversation
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 you split this into two PRs, one for surfacing the errors and one for adding the tests? Makes it easier to review and we get a clearer history.
24adeee
to
45bc5dc
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.
This mostly looks great, left a couple of suggestions on how we can improve it a little more.
Sources/GRPCNIOTransportCore/Client/Connection/GRPCChannel.swift
Outdated
Show resolved
Hide resolved
Sources/GRPCNIOTransportCore/Client/Connection/LoadBalancers/RoundRobinLoadBalancer.swift
Outdated
Show resolved
Hide resolved
Sources/GRPCNIOTransportCore/Client/Connection/LoadBalancers/RoundRobinLoadBalancer.swift
Outdated
Show resolved
Hide resolved
@@ -282,16 +282,27 @@ extension Subchannel { | |||
} | |||
} | |||
|
|||
private func handleConnectFailedEvent(in group: inout DiscardingTaskGroup) { | |||
private func handleConnectFailedEvent(in group: inout DiscardingTaskGroup, error: any Error) { |
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.
Rather than any Error
, can we use RPCError
and propagate it back to wherever the connectFailed
event came from?
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.
Okay I had to do some gymnastics to get this done - not sure if it's compiler errors or I'm misunderstanding something about how Result deals with typed throws, but it wasn't too straightforward 😅
Sources/GRPCNIOTransportCore/Client/Connection/LoadBalancers/Subchannel.swift
Outdated
Show resolved
Hide resolved
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.
One nit but otherwise looks great!
Sources/GRPCNIOTransportCore/Client/Connection/Connection.swift
Outdated
Show resolved
Hide resolved
@@ -127,9 +127,19 @@ package final class Connection: Sendable { | |||
/// This function returns when the connection has closed. You can observe connection events | |||
/// by consuming the ``events`` sequence. | |||
package func run() async { | |||
let connectResult = await Result { | |||
try await self.http2Connector.establishConnection(to: self.address) | |||
func establishConnectionOrThrow() async throws(RPCError) -> HTTP2Connection { |
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.
These are the right gymnastics: the other way to do this is to be explicit with the types in the catching:
closure:
await Result { () async throws(RPCError) -> HTTP2Connection in
// ...
}
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.
Nice one, thanks Gus
This PR better surfaces transient errors happening deeper in the channel to provide more information to the user.
It depends on grpc/grpc-swift#2083 and grpc/grpc-swift#2084.