Skip to content

Add Endpoint::eager_connect_errors to surface lazy-channel connection failures immediately - #2841

Open
hermeGarcia wants to merge 2 commits into
grpc:masterfrom
hermeGarcia:master
Open

Add Endpoint::eager_connect_errors to surface lazy-channel connection failures immediately#2841
hermeGarcia wants to merge 2 commits into
grpc:masterfrom
hermeGarcia:master

Conversation

@hermeGarcia

Copy link
Copy Markdown
Contributor

Fixes #2839.

Adds Endpoint::eager_connect_errors(bool). When enabled, a lazily-connecting channel (Endpoint::connect_lazy / connect_with_connector_lazy) reports a failed connection attempt to the caller right away, instead of waiting till a call is made. This allows load balancers like tower's p2c to identify healthy endpoints before making an actual call.

A new fail_early field/parameter on the internal Reconnect service, set from endpoint.eager_connect_errors at construction time in Connection::new.

Comment on lines +130 to 131
if self.return_connection_errors_on_poll() {
return Poll::Ready(Err(e.into()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this might cause problems, such as iirc tower will remove this connection from the readycache and make it never available again. I don't think that is the behavior you want right?

@hermeGarcia hermeGarcia Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, we definitely don't want that.
Thanks for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tonic: Reconnect::poll_ready returns Ok(()) on connection error, breaking tower's p2c Balance failover

2 participants