()
| 16 | var RedisClient *redis.Client |
| 17 | |
| 18 | func (task *Task) InitQueueRedisClient() (err error) { |
| 19 | redisOpt := tools.RedisOption{ |
| 20 | Address: config.Conf.Common.CommonRedis.RedisAddress, |
| 21 | Password: config.Conf.Common.CommonRedis.RedisPassword, |
| 22 | Db: config.Conf.Common.CommonRedis.Db, |
| 23 | } |
| 24 | RedisClient = tools.GetRedisInstance(redisOpt) |
| 25 | if pong, err := RedisClient.Ping().Result(); err != nil { |
| 26 | logrus.Infof("RedisClient Ping Result pong: %s, err: %s", pong, err) |
| 27 | } |
| 28 | go func() { |
| 29 | for { |
| 30 | var result []string |
| 31 | //10s timeout |
| 32 | result, err = RedisClient.BRPop(time.Second*10, config.QueueName).Result() |
| 33 | if err != nil { |
| 34 | logrus.Infof("task queue block timeout,no msg err:%s", err.Error()) |
| 35 | } |
| 36 | if len(result) >= 2 { |
| 37 | task.Push(result[1]) |
| 38 | } |
| 39 | } |
| 40 | }() |
| 41 | return |
| 42 | } |
no test coverage detected