| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package memory | 5 package memory |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "regexp" | 9 "regexp" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 var validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`) | 21 var validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`) |
| 22 | 22 |
| 23 var defaultGlobalInfoData = globalInfoData{ | 23 var defaultGlobalInfoData = globalInfoData{ |
| 24 // versionID returns X.Y where Y is autogenerated by appengine, and X is | 24 // versionID returns X.Y where Y is autogenerated by appengine, and X is |
| 25 // whatever's in app.yaml. | 25 // whatever's in app.yaml. |
| 26 versionID: "testVersionID.1", | 26 versionID: "testVersionID.1", |
| 27 requestID: "test-request-id", | 27 requestID: "test-request-id", |
| 28 } | 28 } |
| 29 | 29 |
| 30 type globalInfoData struct { | 30 type globalInfoData struct { |
| 31 » appid string | 31 » appID string |
| 32 » fqAppID string |
| 32 namespace *string | 33 namespace *string |
| 33 versionID string | 34 versionID string |
| 34 requestID string | 35 requestID string |
| 35 } | 36 } |
| 36 | 37 |
| 37 func (gid *globalInfoData) getNamespace() (string, bool) { | 38 func (gid *globalInfoData) getNamespace() (string, bool) { |
| 38 if ns := gid.namespace; ns != nil { | 39 if ns := gid.namespace; ns != nil { |
| 39 return *ns, true | 40 return *ns, true |
| 40 } | 41 } |
| 41 return "", false | 42 return "", false |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 func (gi *giImpl) MustNamespace(ns string) context.Context { | 93 func (gi *giImpl) MustNamespace(ns string) context.Context { |
| 93 ret, err := gi.Namespace(ns) | 94 ret, err := gi.Namespace(ns) |
| 94 if err != nil { | 95 if err != nil { |
| 95 panic(err) | 96 panic(err) |
| 96 } | 97 } |
| 97 return ret | 98 return ret |
| 98 } | 99 } |
| 99 | 100 |
| 100 func (gi *giImpl) AppID() string { | 101 func (gi *giImpl) AppID() string { |
| 101 » return gi.appid | 102 » return gi.appID |
| 102 } | 103 } |
| 103 | 104 |
| 104 func (gi *giImpl) FullyQualifiedAppID() string { | 105 func (gi *giImpl) FullyQualifiedAppID() string { |
| 105 » return gi.appid | 106 » return gi.fqAppID |
| 106 } | 107 } |
| 107 | 108 |
| 108 func (gi *giImpl) IsDevAppServer() bool { | 109 func (gi *giImpl) IsDevAppServer() bool { |
| 109 return true | 110 return true |
| 110 } | 111 } |
| 111 | 112 |
| 112 func (gi *giImpl) VersionID() string { | 113 func (gi *giImpl) VersionID() string { |
| 113 return curGID(gi.c).versionID | 114 return curGID(gi.c).versionID |
| 114 } | 115 } |
| 115 | 116 |
| 116 func (gi *giImpl) RequestID() string { | 117 func (gi *giImpl) RequestID() string { |
| 117 return curGID(gi.c).requestID | 118 return curGID(gi.c).requestID |
| 118 } | 119 } |
| 119 | 120 |
| 120 func (gi *giImpl) Testable() info.Testable { | 121 func (gi *giImpl) Testable() info.Testable { |
| 121 return gi | 122 return gi |
| 122 } | 123 } |
| 123 | 124 |
| 124 func (gi *giImpl) SetVersionID(v string) context.Context { | 125 func (gi *giImpl) SetVersionID(v string) context.Context { |
| 125 return useGID(gi.c, func(mod *globalInfoData) { | 126 return useGID(gi.c, func(mod *globalInfoData) { |
| 126 mod.versionID = v | 127 mod.versionID = v |
| 127 }) | 128 }) |
| 128 } | 129 } |
| 129 | 130 |
| 130 func (gi *giImpl) SetRequestID(v string) context.Context { | 131 func (gi *giImpl) SetRequestID(v string) context.Context { |
| 131 return useGID(gi.c, func(mod *globalInfoData) { | 132 return useGID(gi.c, func(mod *globalInfoData) { |
| 132 mod.requestID = v | 133 mod.requestID = v |
| 133 }) | 134 }) |
| 134 } | 135 } |
| OLD | NEW |