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

Add "lazy" connection option #58

Merged
merged 5 commits into from
Oct 3, 2023
Merged

Conversation

joechild-pace
Copy link
Contributor

Add a "lazy" option to the client/dependency provider, defaulting to False. This option means we only try to connect when a call is made rather than on startup.

This avoids cases where a dependent service won't start unless its dependency service is already running. Otherwise cascading failures might be a problem.

@joechild-pace joechild-pace marked this pull request as ready for review October 2, 2023 16:14
):
self.target = target
self.stub = stub
self.compression_algorithm = compression_algorithm
self.compression_level = compression_level # NOTE not used
self.ssl = SslConfig(ssl)
self.lazy = lazy
Copy link
Collaborator

@stephenc-pace stephenc-pace Oct 2, 2023

Choose a reason for hiding this comment

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

This could be lazy_startup or something more intentational than just lazy

self._channel = self._get_channel()

def _get_channel(self):
with self._channel_creation_lock:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is in wrong place, or there should be another self._channel is None check after the lock. Other threads at the moment would wait but still create additional channels.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right.

I think it should be fixed now

Copy link
Collaborator

@stephenc-pace stephenc-pace left a comment

Choose a reason for hiding this comment

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

Minor nitpick on parameter name but otherwise looks good.

@timbu timbu merged commit 9d6f985 into nameko:master Oct 3, 2023
6 checks passed
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.

3 participants