mirror of
https://github.com/parkan/go-hauk.git
synced 2026-05-08 16:47:46 +02:00
support redis:// URLs for Railway compatibility
This commit is contained in:
@@ -24,15 +24,23 @@ type Redis struct {
|
||||
|
||||
func NewRedis(addr, password, prefix string) (*Redis, error) {
|
||||
var opts *redis.Options
|
||||
var err error
|
||||
|
||||
// unix socket detection
|
||||
if strings.HasPrefix(addr, "/") {
|
||||
// redis:// URL detection
|
||||
if strings.HasPrefix(addr, "redis://") || strings.HasPrefix(addr, "rediss://") {
|
||||
opts, err = redis.ParseURL(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if strings.HasPrefix(addr, "/") {
|
||||
// unix socket
|
||||
opts = &redis.Options{
|
||||
Network: "unix",
|
||||
Addr: addr,
|
||||
Password: password,
|
||||
}
|
||||
} else {
|
||||
// host:port
|
||||
opts = &redis.Options{
|
||||
Addr: addr,
|
||||
Password: password,
|
||||
|
||||
Reference in New Issue
Block a user