mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-25 23:32:17 +08:00
fix: set username in redis uri paring
This commit is contained in:
parent
c08f142b56
commit
0d79ae231e
3
asynq.go
3
asynq.go
@ -485,6 +485,7 @@ func parseRedisURI(u *url.URL) (RedisConnOpt, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
redisConnOpt.Addr = u.Host
|
redisConnOpt.Addr = u.Host
|
||||||
|
redisConnOpt.Username = u.User.Username()
|
||||||
redisConnOpt.Password = password
|
redisConnOpt.Password = password
|
||||||
redisConnOpt.DB = db
|
redisConnOpt.DB = db
|
||||||
|
|
||||||
@ -509,7 +510,7 @@ func parseRedisSocketURI(u *url.URL) (RedisConnOpt, error) {
|
|||||||
if v, ok := u.User.Password(); ok {
|
if v, ok := u.User.Password(); ok {
|
||||||
password = v
|
password = v
|
||||||
}
|
}
|
||||||
return RedisClientOpt{Network: "unix", Addr: u.Path, DB: db, Password: password}, nil
|
return RedisClientOpt{Network: "unix", Addr: u.Path, DB: db, Username: u.User.Username(), Password: password}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseRedisSentinelURI(u *url.URL) (RedisConnOpt, error) {
|
func parseRedisSentinelURI(u *url.URL) (RedisConnOpt, error) {
|
||||||
|
@ -109,22 +109,50 @@ func TestParseRedisURI(t *testing.T) {
|
|||||||
"redis://localhost:6379/3",
|
"redis://localhost:6379/3",
|
||||||
RedisClientOpt{Addr: "localhost:6379", DB: 3},
|
RedisClientOpt{Addr: "localhost:6379", DB: 3},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"redis://:@localhost:6379",
|
||||||
|
RedisClientOpt{Addr: "localhost:6379"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"redis://myusername:@localhost:6379",
|
||||||
|
RedisClientOpt{Addr: "localhost:6379", Username: "myusername"},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"redis://:mypassword@localhost:6379",
|
"redis://:mypassword@localhost:6379",
|
||||||
RedisClientOpt{Addr: "localhost:6379", Password: "mypassword"},
|
RedisClientOpt{Addr: "localhost:6379", Password: "mypassword"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"redis://myusername:mypassword@localhost:6379",
|
||||||
|
RedisClientOpt{Addr: "localhost:6379", Username: "myusername", Password: "mypassword"},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"redis://:mypassword@127.0.0.1:6379/11",
|
"redis://:mypassword@127.0.0.1:6379/11",
|
||||||
RedisClientOpt{Addr: "127.0.0.1:6379", Password: "mypassword", DB: 11},
|
RedisClientOpt{Addr: "127.0.0.1:6379", Password: "mypassword", DB: 11},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"redis://myusername:mypassword@localhost:6379/11",
|
||||||
|
RedisClientOpt{Addr: "localhost:6379", Username: "myusername", Password: "mypassword", DB: 11},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"redis-socket:///var/run/redis/redis.sock",
|
"redis-socket:///var/run/redis/redis.sock",
|
||||||
RedisClientOpt{Network: "unix", Addr: "/var/run/redis/redis.sock"},
|
RedisClientOpt{Network: "unix", Addr: "/var/run/redis/redis.sock"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"redis-socket://:@/var/run/redis/redis.sock",
|
||||||
|
RedisClientOpt{Network: "unix", Addr: "/var/run/redis/redis.sock"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"redis-socket://myusername:@/var/run/redis/redis.sock",
|
||||||
|
RedisClientOpt{Network: "unix", Addr: "/var/run/redis/redis.sock", Username: "myusername"},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"redis-socket://:mypassword@/var/run/redis/redis.sock",
|
"redis-socket://:mypassword@/var/run/redis/redis.sock",
|
||||||
RedisClientOpt{Network: "unix", Addr: "/var/run/redis/redis.sock", Password: "mypassword"},
|
RedisClientOpt{Network: "unix", Addr: "/var/run/redis/redis.sock", Password: "mypassword"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"redis-socket://myusername:mypassword@/var/run/redis/redis.sock",
|
||||||
|
RedisClientOpt{Network: "unix", Addr: "/var/run/redis/redis.sock", Username: "myusername", Password: "mypassword"},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"redis-socket:///var/run/redis/redis.sock?db=7",
|
"redis-socket:///var/run/redis/redis.sock?db=7",
|
||||||
RedisClientOpt{Network: "unix", Addr: "/var/run/redis/redis.sock", DB: 7},
|
RedisClientOpt{Network: "unix", Addr: "/var/run/redis/redis.sock", DB: 7},
|
||||||
|
Loading…
Reference in New Issue
Block a user