зеркало из https://github.com/github/vitess-gh.git
Defend against a potential race condition in registering push stats providers.
Signed-off-by: David Weitzman <dweitzman@pinterest.com>
This commit is contained in:
Родитель
a3d03d418c
Коммит
05ac7222c0
|
@ -110,11 +110,14 @@ type PushBackend interface {
|
|||
}
|
||||
|
||||
var pushBackends = make(map[string]PushBackend)
|
||||
var pushBackendsLock sync.Mutex
|
||||
var once sync.Once
|
||||
|
||||
// RegisterPushBackend allows modules to register PushBackend implementations.
|
||||
// Should be called on init().
|
||||
func RegisterPushBackend(name string, backend PushBackend) {
|
||||
pushBackendsLock.Lock()
|
||||
defer pushBackendsLock.Unlock()
|
||||
if _, ok := pushBackends[name]; ok {
|
||||
log.Fatalf("PushBackend %s already exists; can't register the same name multiple times", name)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче