package setup import ( "time" "forge.cadoles.com/cadoles/bouncer/internal/config" "forge.cadoles.com/cadoles/bouncer/internal/proxy/director" "forge.cadoles.com/cadoles/bouncer/internal/proxy/director/layer/queue" queueRedis "forge.cadoles.com/cadoles/bouncer/internal/proxy/director/layer/queue/redis" "github.com/pkg/errors" ) func init() { RegisterLayer(queue.LayerType, setupQueueLayer, queue.RawLayerOptionsSchema) } func setupQueueLayer(conf *config.Config) (director.Layer, error) { adapter, err := newQueueAdapter(conf.Redis) if err != nil { return nil, errors.WithStack(err) } options := []queue.OptionFunc{ queue.WithTemplateDir(string(conf.Layers.Queue.TemplateDir)), } if conf.Layers.Queue.DefaultKeepAlive != nil { options = append(options, queue.WithDefaultKeepAlive(time.Duration(*conf.Layers.Queue.DefaultKeepAlive))) } return queue.New( adapter, options..., ), nil } func newQueueAdapter(redisConf config.RedisConfig) (queue.Adapter, error) { rdb := newRedisClient(redisConf) return queueRedis.NewAdapter(rdb, 2), nil }