mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 15:13:30 +00:00
22 lines
450 B
Go
22 lines
450 B
Go
package utils
|
|
|
|
import "github.com/hibiken/asynq"
|
|
|
|
func GetQueueClient() *asynq.Client {
|
|
opt := RedisURI2AsynqOpt(GetEnv("redis.url"))
|
|
return asynq.NewClient(opt)
|
|
}
|
|
|
|
func GetQueueInspector() *asynq.Inspector {
|
|
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
|
|
}
|