Skip to content

Commit

Permalink
api: worker: fix asynq connection to actually pass credentials
Browse files Browse the repository at this point in the history
presently, asynq doesn't connect to redis with credentials
this commit should fix that by switching to asynq's redis uri parser
and use it as input for the connection
  • Loading branch information
Drakonis authored and otavio committed Aug 25, 2022
1 parent 2b24d15 commit d049f03
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions api/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"net/url"
"runtime"
"time"

Expand Down Expand Up @@ -137,13 +136,13 @@ func sessionRecordCleanup() error {
}

func startWorker(cfg *config) error {
addr, err := url.Parse(cfg.RedisURI)
addr, err := asynq.ParseRedisURI(cfg.RedisURI)
if err != nil {
return err
}

srv := asynq.NewServer(
asynq.RedisClientOpt{Addr: addr.Host},
addr,
asynq.Config{
Concurrency: runtime.NumCPU(),
},
Expand All @@ -166,7 +165,7 @@ func startWorker(cfg *config) error {
}
}()

scheduler := asynq.NewScheduler(asynq.RedisClientOpt{Addr: addr.Host}, nil)
scheduler := asynq.NewScheduler(addr, nil)

// Schedule session_record:cleanup to run once a day
if _, err := scheduler.Register(cfg.SessionRecordCleanupSchedule,
Expand Down

0 comments on commit d049f03

Please sign in to comment.