-
Notifications
You must be signed in to change notification settings - Fork 3
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
57 changing the cluster conn function to use domain nameshostnames instead of ips #58
base: main
Are you sure you want to change the base?
Changes from 7 commits
534723e
eff9ae8
3fd5c14
e5cfe80
377fae2
eef67b8
e65ee26
97bbe4a
0e79477
98719f6
f65ce34
f623557
427ef70
523ff53
8509151
09c969a
da45121
14580bc
ac39f29
c074f70
adbbada
670e908
af46b2b
d795189
d05f644
343f0c0
a43db2e
674c651
4c485b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
from redis.cluster import RedisCluster | ||
from redis.cluster import RedisCluster, ClusterNode | ||
from redis.retry import Retry | ||
from redis.backoff import default_backoff | ||
|
||
# detect if a connection is a sentinel | ||
def Is_Cluster(conn): | ||
|
@@ -7,12 +9,10 @@ | |
|
||
# create a cluster connection from a Redis connection | ||
def Cluster_Conn(conn, ssl): | ||
# current sentinel | ||
info = conn.execute_command("CLUSTER NODES") | ||
nodes = [ ClusterNode(v['hostname'],k.split(':')[1]) for k,v in info.items()] | ||
connection_kwargs = conn.connection_pool.connection_kwargs | ||
host = connection_kwargs['host'] | ||
port = connection_kwargs['port'] | ||
username = connection_kwargs['username'] | ||
password = connection_kwargs['password'] | ||
|
||
return RedisCluster(host=host, port=port, username=username, password=password, ssl=ssl) | ||
return RedisCluster(Retry(default_backoff(),6),cluster_error_retry_attempts=6,startup_nodes=nodes,username=username,password=password,ssl=ssl) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Significant improvements in The modifications to use the However, as indicated by static analysis tools and previous comments, these changes are not covered by unit tests. It is crucial to ensure that new functionalities work as expected and do not introduce regressions. Would you like me to help by generating the unit testing code or opening a GitHub issue to track this task? |
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Implement retry mechanism in the
Cluster_Conn
function.The addition of a retry mechanism using
Retry
with a default backoff strategy enhances the resilience of the connection process. This is a good practice for distributed systems where transient errors are common. However, ensure that the new lines of code are covered by unit tests to maintain code quality and reliability.The static analysis tool indicates that these lines are not covered by tests. Consider adding unit tests to cover these new functionalities.
Tools
GitHub Check: codecov/patch