mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 07:08:02 +00:00
refactor(backend): improve Redis connection handling in async queue utilities by introducing RedisURI2AsynqOpt function
This commit is contained in:
@@ -3,9 +3,19 @@ package utils
|
||||
import "github.com/hibiken/asynq"
|
||||
|
||||
func GetQueueClient() *asynq.Client {
|
||||
return asynq.NewClient(asynq.RedisClientOpt{Addr: GetEnv("REDIS_URL")})
|
||||
opt := RedisURI2AsynqOpt(GetEnv("REDIS_URL"))
|
||||
return asynq.NewClient(opt)
|
||||
}
|
||||
|
||||
func GetQueueInspector() *asynq.Inspector {
|
||||
return asynq.NewInspector(asynq.RedisClientOpt{Addr: GetEnv("REDIS_URL")})
|
||||
opt := RedisURI2AsynqOpt(GetEnv("REDIS_URL"))
|
||||
return asynq.NewInspector(opt)
|
||||
}
|
||||
|
||||
func RedisURI2AsynqOpt(uri string) asynq.RedisConnOpt {
|
||||
opt, err := asynq.ParseRedisURI(GetEnv("REDIS_URL"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return opt
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user