mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Use global lock instead of NewExclusivePool to allow distributed lock between multiple Gitea instances (#31813)
Replace #26486 Fix #19620 --------- Co-authored-by: Jason Song <i@wolfogre.com>
This commit is contained in:
@@ -6,14 +6,22 @@ package globallock
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultLocker Locker
|
||||
initOnce sync.Once
|
||||
initFunc = func() {
|
||||
// TODO: read the setting and initialize the default locker.
|
||||
// Before implementing this, don't use it.
|
||||
switch setting.GlobalLock.ServiceType {
|
||||
case "redis":
|
||||
defaultLocker = NewRedisLocker(setting.GlobalLock.ServiceConnStr)
|
||||
case "memory":
|
||||
fallthrough
|
||||
default:
|
||||
defaultLocker = NewMemoryLocker()
|
||||
}
|
||||
} // define initFunc as a variable to make it possible to change it in tests
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user