Skip to content

Commit

Permalink
fix possible race condition in rmq initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
nicmue committed Jul 6, 2020
1 parent 3f73bc7 commit c095beb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/queue/rmq.go
Expand Up @@ -14,12 +14,18 @@ import (
var (
rmqConnection rmq.Connection
queueHealthLimits sync.Map

initMutex sync.Mutex
)

func initDefault() {
initMutex.Lock()
defer initMutex.Unlock()

if rmqConnection != nil {
return
}

rmqConnection = rmq.OpenConnectionWithRedisClient("default", redis.Client())
gatherMetrics(rmqConnection)
servicehealthcheck.RegisterHealthCheck("rmq", &HealthCheck{})
Expand Down

0 comments on commit c095beb

Please sign in to comment.