-
Notifications
You must be signed in to change notification settings - Fork 12
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
Conversation
nameko_grpc/client.py
Outdated
): | ||
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 |
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 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: |
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 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.
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.
You're right.
I think it should be fixed now
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.
Minor nitpick on parameter name but otherwise looks good.
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.