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

Unified Diff: impl/memory/info.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 | « impl/memory/datastore_test.go ('k') | impl/memory/info_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/info.go
diff --git a/impl/memory/info.go b/impl/memory/info.go
index 89c2f440285a364537c9df245e686827f26f0482..9a63ba847935aa00f24cc52216c2309e629779fd 100644
--- a/impl/memory/info.go
+++ b/impl/memory/info.go
@@ -6,10 +6,11 @@ package memory
import (
"fmt"
- "regexp"
"github.com/luci/gae/impl/dummy"
"github.com/luci/gae/service/info"
+ "github.com/luci/gae/service/info/support"
+
"golang.org/x/net/context"
)
@@ -17,9 +18,6 @@ type giContextKeyType int
var giContextKey giContextKeyType
-// validNamespace matches valid namespace names.
-var validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`)
-
var defaultGlobalInfoData = globalInfoData{
// versionID returns X.Y where Y is autogenerated by appengine, and X is
// whatever's in app.yaml.
@@ -30,18 +28,11 @@ var defaultGlobalInfoData = globalInfoData{
type globalInfoData struct {
appID string
fqAppID string
- namespace *string
+ namespace string
versionID string
requestID string
}
-func (gid *globalInfoData) getNamespace() (string, bool) {
- if ns := gid.namespace; ns != nil {
- return *ns, true
- }
- return "", false
-}
-
func curGID(c context.Context) *globalInfoData {
if gid, ok := c.Value(giContextKey).(*globalInfoData); ok {
return gid
@@ -76,17 +67,15 @@ type giImpl struct {
var _ = info.RawInterface((*giImpl)(nil))
-func (gi *giImpl) GetNamespace() (string, bool) {
- return gi.getNamespace()
-}
+func (gi *giImpl) GetNamespace() string { return gi.namespace }
-func (gi *giImpl) Namespace(ns string) (ret context.Context, err error) {
- if !validNamespace.MatchString(ns) {
- return nil, fmt.Errorf("appengine: namespace %q does not match /%s/", ns, validNamespace)
+func (gi *giImpl) Namespace(ns string) (context.Context, error) {
+ if err := support.ValidNamespace(ns); err != nil {
+ return gi.c, err
}
return useGID(gi.c, func(mod *globalInfoData) {
- mod.namespace = &ns
+ mod.namespace = ns
}), nil
}
@@ -114,7 +103,7 @@ func (gi *giImpl) RequestID() string {
return curGID(gi.c).requestID
}
-func (gi *giImpl) Testable() info.Testable {
+func (gi *giImpl) GetTestable() info.Testable {
return gi
}
« no previous file with comments | « impl/memory/datastore_test.go ('k') | impl/memory/info_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698