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

Unified Diff: impl/memory/context.go

Issue 1929423002: filter/txnBuf: Use fully-qualified App ID. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Use public methods for defining Info service in tests. Created 4 years, 8 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/txnBuf/state.go ('k') | impl/memory/datastore.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/context.go
diff --git a/impl/memory/context.go b/impl/memory/context.go
index 4fc2eb200877f6fc21c05a00940f1f5dbdfea016..01f9e8029c861f1285827de81ab006dda5acfee2 100644
--- a/impl/memory/context.go
+++ b/impl/memory/context.go
@@ -6,6 +6,7 @@ package memory
import (
"errors"
+ "strings"
"sync"
ds "github.com/luci/gae/service/datastore"
@@ -89,7 +90,7 @@ func (m *memContext) applyTxn(c context.Context, txnCtxObj memContextObj) {
}
}
-// Use calls UseWithAppID with the appid of "dev~app"
+// Use calls UseWithAppID with the appid of "app"
func Use(c context.Context) context.Context {
return UseWithAppID(c, "dev~app")
}
@@ -105,7 +106,8 @@ func Use(c context.Context) context.Context {
// * github.com/luci/luci-go/common/logger (using memlogger)
//
// The application id wil be set to 'aid', and will not be modifiable in this
-// context.
+// context. If 'aid' contains a "~" character, it will be treated as the
+// fully-qualified App ID and the AppID will be the string following the "~".
//
// These can be retrieved with the gae.Get functions.
//
@@ -119,11 +121,17 @@ func UseWithAppID(c context.Context, aid string) context.Context {
}
c = memlogger.Use(c)
- memctx := newMemContext(aid)
+ fqAppID := aid
+ if parts := strings.SplitN(fqAppID, "~", 2); len(parts) == 2 {
+ aid = parts[1]
+ }
+
+ memctx := newMemContext(fqAppID)
c = context.WithValue(c, memContextKey, memctx)
c = context.WithValue(c, memContextNoTxnKey, memctx)
c = useGID(c, func(mod *globalInfoData) {
- mod.appid = aid
+ mod.appID = aid
+ mod.fqAppID = fqAppID
})
return useMod(useMail(useUser(useTQ(useRDS(useMC(useGI(c)))))))
}
« no previous file with comments | « filter/txnBuf/state.go ('k') | impl/memory/datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698