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

Side by Side Diff: impl/memory/info.go

Issue 2062613002: Add TrimmedAppID to info service. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 clone := *cur 58 clone := *cur
59 f(&clone) 59 f(&clone)
60 return context.WithValue(c, giContextKey, &clone) 60 return context.WithValue(c, giContextKey, &clone)
61 } 61 }
62 62
63 // useGI adds a gae.GlobalInfo context, accessible 63 // useGI adds a gae.GlobalInfo context, accessible
64 // by gae.GetGI(c) 64 // by gae.GetGI(c)
65 func useGI(c context.Context) context.Context { 65 func useGI(c context.Context) context.Context {
66 » return info.SetFactory(c, func(ic context.Context) info.Interface { 66 » return info.SetFactory(c, func(ic context.Context) info.RawInterface {
67 return &giImpl{dummy.Info(), curGID(ic), ic} 67 return &giImpl{dummy.Info(), curGID(ic), ic}
68 }) 68 })
69 } 69 }
70 70
71 type giImpl struct { 71 type giImpl struct {
72 » info.Interface 72 » info.RawInterface
73 *globalInfoData 73 *globalInfoData
74 c context.Context 74 c context.Context
75 } 75 }
76 76
77 var _ = info.Interface((*giImpl)(nil)) 77 var _ = info.RawInterface((*giImpl)(nil))
78 78
79 func (gi *giImpl) GetNamespace() (string, bool) { 79 func (gi *giImpl) GetNamespace() (string, bool) {
80 return gi.getNamespace() 80 return gi.getNamespace()
81 } 81 }
82 82
83 func (gi *giImpl) Namespace(ns string) (ret context.Context, err error) { 83 func (gi *giImpl) Namespace(ns string) (ret context.Context, err error) {
84 if !validNamespace.MatchString(ns) { 84 if !validNamespace.MatchString(ns) {
85 return nil, fmt.Errorf("appengine: namespace %q does not match / %s/", ns, validNamespace) 85 return nil, fmt.Errorf("appengine: namespace %q does not match / %s/", ns, validNamespace)
86 } 86 }
87 87
88 return useGID(gi.c, func(mod *globalInfoData) { 88 return useGID(gi.c, func(mod *globalInfoData) {
89 mod.namespace = &ns 89 mod.namespace = &ns
90 }), nil 90 }), nil
91 } 91 }
92 92
93 func (gi *giImpl) MustNamespace(ns string) context.Context {
94 ret, err := gi.Namespace(ns)
95 if err != nil {
96 panic(err)
97 }
98 return ret
99 }
100
101 func (gi *giImpl) AppID() string { 93 func (gi *giImpl) AppID() string {
102 return gi.appID 94 return gi.appID
103 } 95 }
104 96
105 func (gi *giImpl) FullyQualifiedAppID() string { 97 func (gi *giImpl) FullyQualifiedAppID() string {
106 return gi.fqAppID 98 return gi.fqAppID
107 } 99 }
108 100
109 func (gi *giImpl) IsDevAppServer() bool { 101 func (gi *giImpl) IsDevAppServer() bool {
110 return true 102 return true
(...skipping 15 matching lines...) Expand all
126 return useGID(gi.c, func(mod *globalInfoData) { 118 return useGID(gi.c, func(mod *globalInfoData) {
127 mod.versionID = v 119 mod.versionID = v
128 }) 120 })
129 } 121 }
130 122
131 func (gi *giImpl) SetRequestID(v string) context.Context { 123 func (gi *giImpl) SetRequestID(v string) context.Context {
132 return useGID(gi.c, func(mod *globalInfoData) { 124 return useGID(gi.c, func(mod *globalInfoData) {
133 mod.requestID = v 125 mod.requestID = v
134 }) 126 })
135 } 127 }
OLDNEW
« no previous file with comments | « impl/dummy/dummy.go ('k') | impl/memory/info_test.go » ('j') | service/info/wrapper.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698