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

Unified Diff: impl/prod/info.go

Issue 1916463004: impl/memory: Disallow empty namespace. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Rbase. 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 | « impl/prod/context.go ('k') | impl/prod/raw_datastore.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/prod/info.go
diff --git a/impl/prod/info.go b/impl/prod/info.go
index 344012621752afa9285f45ffdb83bff8a8599b1d..3fe006880c9730ae9c07b841a8ceaed4bea288a5 100644
--- a/impl/prod/info.go
+++ b/impl/prod/info.go
@@ -40,8 +40,12 @@ func (g giImpl) AppID() string {
func (g giImpl) FullyQualifiedAppID() string {
return getProbeCache(g.usrCtx).fqaid
}
-func (g giImpl) GetNamespace() string {
- return getProbeCache(g.usrCtx).namespace
+func (g giImpl) GetNamespace() (string, bool) {
+ pc := getProbeCache(g.usrCtx)
+ if ns := pc.namespace; ns != nil {
+ return *ns, true
+ }
+ return "", false
}
func (g giImpl) Datacenter() string {
return appengine.Datacenter(g.aeCtx)
@@ -74,7 +78,7 @@ func (g giImpl) Namespace(namespace string) (context.Context, error) {
}
usrCtx := context.WithValue(g.usrCtx, prodContextKey, aeCtx)
pc := *getProbeCache(usrCtx)
- pc.namespace = namespace
+ pc.namespace = &namespace
return withProbeCache(usrCtx, &pc), nil
}
func (g giImpl) MustNamespace(ns string) context.Context {
@@ -116,16 +120,20 @@ func (g giImpl) Testable() info.Testable {
}
type infoProbeCache struct {
- namespace string
+ namespace *string
fqaid string
}
func probe(aeCtx context.Context) *infoProbeCache {
probeKey := datastore.NewKey(aeCtx, "Kind", "id", 0, nil)
- return &infoProbeCache{
- namespace: probeKey.Namespace(),
- fqaid: probeKey.AppID(),
+ namespace := probeKey.Namespace()
+ ipb := infoProbeCache{
+ fqaid: probeKey.AppID(),
+ }
+ if namespace != "" {
+ ipb.namespace = &namespace
}
+ return &ipb
}
func getProbeCache(c context.Context) *infoProbeCache {
« no previous file with comments | « impl/prod/context.go ('k') | impl/prod/raw_datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698