diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /workhorse/internal/redis/keywatcher.go | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'workhorse/internal/redis/keywatcher.go')
-rw-r--r-- | workhorse/internal/redis/keywatcher.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/workhorse/internal/redis/keywatcher.go b/workhorse/internal/redis/keywatcher.go index 8f3e61b5e9f..10d80d13d22 100644 --- a/workhorse/internal/redis/keywatcher.go +++ b/workhorse/internal/redis/keywatcher.go @@ -17,6 +17,7 @@ import ( var ( keyWatcher = make(map[string][]chan string) keyWatcherMutex sync.Mutex + shutdown = make(chan struct{}) redisReconnectTimeout = backoff.Backoff{ //These are the defaults Min: 100 * time.Millisecond, @@ -112,6 +113,20 @@ func Process() { } } +func Shutdown() { + log.Info("keywatcher: shutting down") + + keyWatcherMutex.Lock() + defer keyWatcherMutex.Unlock() + + select { + case <-shutdown: + // already closed + default: + close(shutdown) + } +} + func notifyChanWatchers(key, value string) { keyWatcherMutex.Lock() defer keyWatcherMutex.Unlock() @@ -182,6 +197,9 @@ func WatchKey(key, value string, timeout time.Duration) (WatchKeyStatus, error) } select { + case <-shutdown: + log.WithFields(log.Fields{"key": key}).Info("stopping watch due to shutdown") + return WatchKeyStatusNoChange, nil case currentValue := <-kw.Chan: if currentValue == "" { return WatchKeyStatusNoChange, fmt.Errorf("keywatcher: redis GET failed") |