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

Unified Diff: filter/dscache/globalconfig.go

Issue 2302743002: Interface update, per-method Contexts. (Closed)
Patch Set: Lightning talk licenses. Created 4 years, 3 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 | « filter/dscache/dscache_test.go ('k') | filter/dscache/serialize.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/dscache/globalconfig.go
diff --git a/filter/dscache/globalconfig.go b/filter/dscache/globalconfig.go
index 2e652712965c1354de5b067caf876664e6d0e478..ec4dbefc2aec1215b91c9e82c5f3586711d023c2 100644
--- a/filter/dscache/globalconfig.go
+++ b/filter/dscache/globalconfig.go
@@ -8,10 +8,12 @@ import (
"sync"
"time"
- "github.com/luci/gae/service/datastore"
+ ds "github.com/luci/gae/service/datastore"
"github.com/luci/gae/service/info"
- "github.com/luci/gae/service/memcache"
+ mc "github.com/luci/gae/service/memcache"
+
"github.com/luci/luci-go/common/clock"
+
"golang.org/x/net/context"
)
@@ -74,12 +76,12 @@ func IsGloballyEnabled(c context.Context) bool {
}
// always go to the default namespace
- c, err := info.Get(c).Namespace("")
+ c, err := info.Namespace(c, "")
if err != nil {
return true
}
cfg := &GlobalConfig{Enable: true}
- if err := datastore.Get(c).Get(cfg); err != nil && err != datastore.ErrNoSuchEntity {
+ if err := ds.Get(c, cfg); err != nil && err != ds.ErrNoSuchEntity {
return true
}
globalEnabled = cfg.Enable
@@ -93,14 +95,13 @@ func IsGloballyEnabled(c context.Context) bool {
// functionality on or off in emergencies.
func SetGlobalEnable(c context.Context, memcacheEnabled bool) error {
// always go to the default namespace
- c, err := info.Get(c).Namespace("")
+ c, err := info.Namespace(c, "")
if err != nil {
return err
}
- return datastore.Get(c).RunInTransaction(func(c context.Context) error {
- ds := datastore.Get(c)
+ return ds.RunInTransaction(c, func(c context.Context) error {
cfg := &GlobalConfig{Enable: true}
- if err := ds.Get(cfg); err != nil && err != datastore.ErrNoSuchEntity {
+ if err := ds.Get(c, cfg); err != nil && err != ds.ErrNoSuchEntity {
return err
}
if cfg.Enable == memcacheEnabled {
@@ -109,10 +110,10 @@ func SetGlobalEnable(c context.Context, memcacheEnabled bool) error {
cfg.Enable = memcacheEnabled
if memcacheEnabled {
// when going false -> true, wipe memcache.
- if err := memcache.Get(c).Flush(); err != nil {
+ if err := mc.Flush(c); err != nil {
return err
}
}
- return ds.Put(cfg)
+ return ds.Put(c, cfg)
}, nil)
}
« no previous file with comments | « filter/dscache/dscache_test.go ('k') | filter/dscache/serialize.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698