finish the global lock init

This commit is contained in:
Lunny Xiao 2024-08-26 10:26:24 -07:00
parent 35daeceb04
commit fe9efa90f8
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

View File

@ -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
) )