-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: master
Are you sure you want to change the base?
Conversation
redis/conn_test.go
Outdated
@@ -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"}, |
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.
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 /
?
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.
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
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.
@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
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?