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 redis+socket scheme in url #669

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

corpix
Copy link

@corpix corpix commented Apr 24, 2024

I've seen similar topic was mentioned in:

I see this package used by https://github.com/gocelery/gocelery which is used by one of the services I maintain. I think it is good to be able to pass Redis URL pointing to UNIX socket (from config file) even if IANA specification draft doesn't mention this particular URI scheme.

What do you think about this changeset?

@@ -680,6 +680,8 @@ var dialURLTests = []struct {
{"database 3", "redis://localhost/3", "+OK\r\n", "*2\r\n$6\r\nSELECT\r\n$1\r\n3\r\n"},
{"database 99", "redis://localhost/99", "+OK\r\n", "*2\r\n$6\r\nSELECT\r\n$2\r\n99\r\n"},
{"no database", "redis://localhost/", "+OK\r\n", ""},
{"database 99", "redis+socket://./server.sock?db=99", "+OK\r\n", "*2\r\n$6\r\nSELECT\r\n$2\r\n99\r\n"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we actually need to differentiate with a different prefix here or could we simplify by requiring all sock paths to be relative or absolute?

Relative must start with . and absolute must start with /?

Copy link
Author

Choose a reason for hiding this comment

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

This is a good question. Original idea was to make url format similar to what other libraries have, but now I see there is no significant sense to have separate redis+socket scheme. Determining socket type by prefix is probably fine

Copy link
Author

Choose a reason for hiding this comment

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

@stevenh I have tried to implement this, but there are tests like TestDialURL/password_no_host_db0 which logic collides with matching rules for absolute and relative paths (I've «stashed» code where tests was failing in de86cf4). So, now I think it is simpler to have a separate scheme for unix socket path, but maybe redis+unix is more obvious for a random user, idk

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