22 lines
548 B
Go
22 lines
548 B
Go
package tasks
|
|
|
|
import "github.com/redis/go-redis/v9"
|
|
|
|
// RedisClientConnector 是一个适配器,它包装了现有的 redis.Client
|
|
// 并实现了 asynq.RedisConnOpt 接口。
|
|
type RedisClientConnector struct {
|
|
Client *redis.Client
|
|
}
|
|
|
|
func NewRedisClientConnector(c *redis.Client) *RedisClientConnector {
|
|
return &RedisClientConnector{
|
|
Client: c,
|
|
}
|
|
}
|
|
|
|
// MakeRedisClient 实现了 asynq.RedisConnOpt 接口。
|
|
// 它直接返回已存在的客户端实例。
|
|
func (c *RedisClientConnector) MakeRedisClient() interface{} {
|
|
return c.Client
|
|
}
|