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

Support using redis urls to construct the redis client #1994

Merged
merged 5 commits into from
Oct 22, 2024

Conversation

opalmer
Copy link
Contributor

@opalmer opalmer commented Oct 16, 2024

Currently Athens only supports connecting to Redis using a hostname:port combination in addition to a password. While this works in most cases it also means that if you have other options you wish to supply Athens has to be updated to support them. As a basic example Redis clusters that require TLS currently are not supported by Athens but with this change you can simply supply a redis url to connect over TLS. It also makes it easy to override the password, set a username and more all from a single configuration option:

rediss://username:[email protected]:6379/1?protocol=3

What is the problem I am trying to address?

The redis cluster I'm using has a specific username, password and requires TLS to connect to it. Athens doesn't appear to support these options today (other than password).

How is the fix applied?

Updated the code constructing the redis client to support using a url, example here: https://github.com/redis/go-redis?tab=readme-ov-file#connecting-via-a-redis-url.

This change also ensures that if you are also setting a password but start using the new url form, and the two don't agree, an error will be returned. Didn't want someone to end up in a situation where they defined a password in the configuration but not in the redis url and expected the two to be combined.

Currently Athens only supports connecting to Redis using a hostname:port combination in addition to a password. While this works in most cases it also means that if you have other options you wish to supply Athens has to be updated to support them. As a basic example Redis clusters that require TLS currently are not supported by Athens but with this change you can simply supply a [redis url](https://github.com/redis/redis-specifications/blob/master/uri/redis.txt) to connect over TLS. It also makes it easy to override the password, set a username and more all from a single configuration option:

`rediss://username:[email protected]:6379/1?protocol=3`
@opalmer opalmer requested a review from a team as a code owner October 16, 2024 21:22
@matt0x6F
Copy link
Contributor

Overall your solution looks good, and thanks for the contribution!

@matt0x6F matt0x6F merged commit 3ba08f6 into gomods:main Oct 22, 2024
11 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.

2 participants