mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-01 14:56:30 +00:00
finish the global lock init
This commit is contained in:
parent
35daeceb04
commit
fe9efa90f8
@ -6,14 +6,22 @@ package globallock
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
defaultLocker Locker
|
defaultLocker Locker
|
||||||
initOnce sync.Once
|
initOnce sync.Once
|
||||||
initFunc = func() {
|
initFunc = func() {
|
||||||
// TODO: read the setting and initialize the default locker.
|
switch setting.GlobalLock.ServiceType {
|
||||||
// Before implementing this, don't use it.
|
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
|
} // define initFunc as a variable to make it possible to change it in tests
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user