代码拉取完成,页面将自动刷新
package config
import (
"gitee.com/sansaniot/ssiot-core/storage"
"gitee.com/sansaniot/ssiot-core/storage/queue"
"github.com/go-redis/redis/v7"
"github.com/robinjoseph08/redisqueue/v2"
"time"
)
type Queue struct {
Redis *QueueRedis
Memory *QueueMemory
NSQ *QueueNSQ `json:"nsq" yaml:"nsq"`
}
type QueueRedis struct {
RedisConnectOptions
Producer *redisqueue.ProducerOptions
Consumer *redisqueue.ConsumerOptions
}
type QueueMemory struct {
PoolSize uint
}
type QueueNSQ struct {
NSQOptions
ChannelPrefix string
}
var QueueConfig = new(Queue)
// Empty 空设置
func (e Queue) Empty() bool {
return e.Memory == nil && e.Redis == nil && e.NSQ == nil
}
// Setup 启用顺序 redis > 其他 > memory
func (e Queue) Setup() (storage.AdapterQueue, error) {
if e.Redis != nil {
e.Redis.Consumer.ReclaimInterval = e.Redis.Consumer.ReclaimInterval * time.Second
e.Redis.Consumer.BlockingTimeout = e.Redis.Consumer.BlockingTimeout * time.Second
e.Redis.Consumer.VisibilityTimeout = e.Redis.Consumer.VisibilityTimeout * time.Second
client := GetRedisClient()
if client == nil {
options, err := e.Redis.RedisConnectOptions.GetRedisOptions()
if err != nil {
return nil, err
}
client = redis.NewClient(options)
_redis = client
}
e.Redis.Producer.RedisClient = client
e.Redis.Consumer.RedisClient = client
return queue.NewRedis(e.Redis.Producer, e.Redis.Consumer)
}
if e.NSQ != nil {
cfg, err := e.NSQ.GetNSQOptions()
if err != nil {
return nil, err
}
return queue.NewNSQ(e.NSQ.Addresses, cfg, e.NSQ.ChannelPrefix)
}
return queue.NewMemory(e.Memory.PoolSize), nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。