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

Make it possible to reuse redis connections #5

Merged
merged 1 commit into from
Feb 16, 2020

Conversation

mauricioabreu
Copy link
Contributor

Sometimes we already have a connection with Redis. Since this library needs Redis settings to connect (host, port, etc) it can be a bit uncomfortable to repeat these parameters.

@mauricioabreu
Copy link
Contributor Author

@leandromoreira can you review it please?

self.redis = rediscluster.StrictRedisCluster(host=host, port=port, password=password)

if kwargs.get("redis"):
self.redis = kwargs["redis"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens when this redis is disconnected (due to timeout, lack of healthcheck) or does it "connect" every time it request something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before my commit, this lib connected once and kept a connection with redis (redis attribute of Bullock class).

Imagine that you have lots of locks:

lock_a = Bullock(**config)
lock_b = Bullock(**config)

With two locks, there will be two redis connections. My commit lets users reuse redis connections. Does it make sense?

@leandromoreira leandromoreira merged commit 51b8f17 into jbochi:master Feb 16, 2020
@mauricioabreu mauricioabreu deleted the reuse-redis-connection branch February 17, 2020 01:34
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.

2 participants