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

Construct a Client that will lazily establish a connection #167

Closed
bmwill opened this issue Dec 6, 2019 · 6 comments · Fixed by #187 or #392
Closed

Construct a Client that will lazily establish a connection #167

bmwill opened this issue Dec 6, 2019 · 6 comments · Fixed by #187 or #392

Comments

@bmwill
Copy link
Contributor

bmwill commented Dec 6, 2019

Feature Request

Construct a Client that will lazily establish a connection

Motivation

Sometimes it would be useful to be able to construct a client and defer establishing a connection with a server until you make a request.

Proposal

Today when creating a client the connection with the server must be established before a client struct is returned from the ::connect() function. Perhaps another constructor could be added which lazily connects and defers actually establishing the connection until a request is made.

Its expected (at least to me) that a client already needs to know and understand how to reconnect to a server in the event of a broken connection so this shouldn't be much more difficult than handling that case.

cc: @LucioFranco

@LucioFranco
Copy link
Member

Sorry, this was closed wrong, the issue for reestablishing connections is fixed but to support lazy connections, the idea I have is to provide a method on Channel that is similar to connect but connect_lazy that will lazily connect.

@LucioFranco LucioFranco reopened this Dec 14, 2019
rabbitinspace pushed a commit to satelit-project/tonic that referenced this issue Jan 1, 2020
@LucioFranco LucioFranco removed this from the 0.1 milestone Jan 11, 2020
@LucioFranco
Copy link
Member

Removing this from 0.1 release, we should support this but I want to think about it some more, but it doesn't seem to be blocking @bmwill anymore.

@bmwill
Copy link
Contributor Author

bmwill commented Jan 13, 2020

Yeah this isn't blocking me currently as I'm handling this by having a light wrapper around a tonic client atm.

@LucioFranco
Copy link
Member

@bmwill got a link to that wrapper by chance?

@bmwill
Copy link
Contributor Author

bmwill commented Jan 13, 2020

Yeah sure! Here's one example.

@joelgallant
Copy link

We did a naive but simple implementation of this, found here.

danburkert added a commit to danburkert/tonic that referenced this issue Jul 9, 2020
Adds a 'lazy' constructor which will not attempt to connect to the
endpoint until first use. This is useful in situations where the
connection is created when the remote service may temporarily not be
responding, such as server startup.

Fixes hyperium#167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants