Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Unified Diff: luci_config/appengine/backend/datastore/ds.go

Issue 2645763002: datastorecache: Add Locker field, public settings. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/datastorecache/util_test.go ('k') | luci_config/appengine/gaeconfig/default.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: luci_config/appengine/backend/datastore/ds.go
diff --git a/luci_config/appengine/backend/datastore/ds.go b/luci_config/appengine/backend/datastore/ds.go
index d1f99b4ddb6e670656ba3e6d85c54d9cd4886bfa..9fef8b8e9d2daffd07b9f1f0ea8d56a22ab4a7be 100644
--- a/luci_config/appengine/backend/datastore/ds.go
+++ b/luci_config/appengine/backend/datastore/ds.go
@@ -63,6 +63,9 @@ type Config struct {
// through to the underlying cache.
FailOpen bool
+ // LockerFunc returns the Locker intance to use.
+ LockerFunc func(context.Context) datastorecache.Locker
+
// userProjAccess is cache of the current user's project access lookups.
userProjAccess map[string]bool
// anonProjAccess is cache of the current user's project access lookups.
@@ -92,6 +95,7 @@ func (dc *Config) WithHandler(c context.Context, l caching.Loader, timeout time.
handler := dsCacheHandler{
refreshInterval: dc.RefreshInterval,
failOpen: dc.FailOpen,
+ lockerFunc: dc.LockerFunc,
loader: l,
loaderTimeout: timeout,
}
@@ -233,6 +237,7 @@ type dsCacheHandler struct {
failOpen bool
refreshInterval time.Duration
loader caching.Loader
+ lockerFunc func(context.Context) datastorecache.Locker
// loaderTimeout, if >0, will be applied prior to performing the loader
// operation. This is used for cron operations.
@@ -241,7 +246,6 @@ type dsCacheHandler struct {
func (dch *dsCacheHandler) FailOpen() bool { return dch.failOpen }
func (dch *dsCacheHandler) RefreshInterval([]byte) time.Duration { return dch.refreshInterval }
-
func (dch *dsCacheHandler) Refresh(c context.Context, key []byte, v datastorecache.Value) (datastorecache.Value, error) {
// Decode the key into our caching key.
var ck caching.Key
@@ -280,6 +284,13 @@ func (dch *dsCacheHandler) Refresh(c context.Context, key []byte, v datastorecac
return v, nil
}
+func (dch *dsCacheHandler) Locker(c context.Context) datastorecache.Locker {
+ if dch.lockerFunc != nil {
+ return dch.lockerFunc(c)
+ }
+ return nil
+}
+
// CronLoader returns a caching.Loader implementation to be used
// by the Cron task.
func CronLoader(b backend.B) caching.Loader {
« no previous file with comments | « appengine/datastorecache/util_test.go ('k') | luci_config/appengine/gaeconfig/default.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698