-
-
Notifications
You must be signed in to change notification settings - Fork 19
Sentinels: Accept options to connect to master #61
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
Conversation
| @master_name = master_name | ||
| @master_options = master_options | ||
| @role = role | ||
| @protocol = protocol |
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.
I removed the @protocol instance variable because, AFAIK, it is only used to connect to the master, and at this point we still don't know which one will be.
lib/async/redis/sentinel_client.rb
Outdated
| @ssl = !!master_options&.key?(:ssl_context) | ||
| @scheme = "redis#{@ssl ? 's' : ''}" |
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.
I don't kinda like this, any ideas?
| protected | ||
|
|
||
| def assign_default_tags(tags) | ||
| tags[:protocol] = @protocol.to_s |
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.
I'm not sure what is this for. I hope I'm not breaking anything.
| @protocol.client(stream) | ||
|
|
||
| endpoint.protocol.client(stream) |
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.
Here we use the endpoint protocol to connect to the endpoint, I think this is more correct and removes the need for the instance variable.
dde5f6e to
d7e204d
Compare
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.
Pull Request Overview
This PR extends SentinelClient to accept custom connection options (e.g., TLS, ACL credentials) for the resolved master/slave endpoints.
- Updated initializer to accept
master_optionsand infer secure scheme. - Switched endpoint creation in
resolve_master/resolve_slavetoEndpoint.forwith provided options. - Removed the old
protocolattribute and default tags in favor of per-endpoint protocol handling.
Comments suppressed due to low confidence (2)
lib/async/redis/sentinel_client.rb:24
- Add a note in the class or initializer docs explaining how
master_optionsinteract with TLS/ACL and the:rolesetting, so users understand its intended use.
# @property master_options [Hash] Connection options for master.
lib/async/redis/sentinel_client.rb:24
- There are no tests covering the new
master_optionsfunctionality (e.g., TLS or credential use when connecting to the master). Consider adding unit or integration tests to validate this behavior.
# @property master_options [Hash] Connection options for master.
Co-authored-by: Copilot <[email protected]>
|
I will try to review this next week. |
|
Will merge in #65. |
|
Let me know how you get on with the latest release. |
I tried to use
SentinelClienton my project and found I couldn't connect to Sentinels + TLS or ACL. The reason is there no way to provide connection options for the master, only for the sentinels. So sentinels can be protected with TLS and ACL andasync-rediswill connect to them, but after resolving master,SentinelClientwill only connect to master if it is not protected by TLS nor ACL.I wrote this script to test the changes:
Types of Changes
Contribution
I didn't add tests because those must involve much more than just writing the tests. It would require creating a new docker compose file, new certificates, config files, etc.