mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-25 13:17:42 +00:00
make connections to the correct redis url envs
This commit is contained in:
parent
11f5f4df51
commit
70f48c87da
4 changed files with 21 additions and 7 deletions
|
@ -39,7 +39,7 @@ func APICmd(ctx context.Context) *cobra.Command {
|
||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
redis, err := cmdutil.NewRedisClient(ctx, 16)
|
redis, err := cmdutil.NewRedisLocksClient(ctx, 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,13 +46,19 @@ func SchedulerCmd(ctx context.Context) *cobra.Command {
|
||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
redis, err := cmdutil.NewRedisClient(ctx, 16)
|
redis, err := cmdutil.NewRedisLocksClient(ctx, 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer redis.Close()
|
defer redis.Close()
|
||||||
|
|
||||||
queue, err := cmdutil.NewQueueClient(logger, redis, "worker")
|
qredis, err := cmdutil.NewRedisQueueClient(ctx, 16)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer qredis.Close()
|
||||||
|
|
||||||
|
queue, err := cmdutil.NewQueueClient(logger, qredis, "worker")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,13 +60,13 @@ func WorkerCmd(ctx context.Context) *cobra.Command {
|
||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
redis, err := cmdutil.NewRedisClient(ctx, consumers)
|
redis, err := cmdutil.NewRedisLocksClient(ctx, consumers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer redis.Close()
|
defer redis.Close()
|
||||||
|
|
||||||
qredis, err := cmdutil.NewRedisClient(ctx, poolSize)
|
qredis, err := cmdutil.NewRedisQueueClient(ctx, poolSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,16 @@ func NewStatsdClient(tags ...string) (*statsd.Client, error) {
|
||||||
return statsd.New(os.Getenv("STATSD_URL"), statsd.WithTags(tags))
|
return statsd.New(os.Getenv("STATSD_URL"), statsd.WithTags(tags))
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRedisClient(ctx context.Context, maxConns int) (*redis.Client, error) {
|
func NewRedisLocksClient(ctx context.Context, maxConns int) (*redis.Client, error) {
|
||||||
opt, err := redis.ParseURL(os.Getenv("REDIS_URL"))
|
return newRedisClient(ctx, "REDIS_LOCKS_URL", maxConns)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRedisQueueClient(ctx context.Context, maxConns int) (*redis.Client, error) {
|
||||||
|
return newRedisClient(ctx, "REDIS_QUEUE_URL", maxConns)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRedisClient(ctx context.Context, env string, maxConns int) (*redis.Client, error) {
|
||||||
|
opt, err := redis.ParseURL(os.Getenv(env))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue