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

Side by Side Diff: go/src/infra/gae/libs/gae/memory/globalinfo.go

Issue 1240573002: Reland: Refactor current GAE abstraction library to be free of the SDK* (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: expand coverage range to fit 32bit test expectations Created 5 years, 5 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 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 » "infra/gae/libs/wrapper" 8 » "golang.org/x/net/context"
9 9
10 » "golang.org/x/net/context" 10 » "infra/gae/libs/gae"
11 ) 11 )
12 12
13 type giContextKeyType int 13 type giContextKeyType int
14 14
15 var giContextKey giContextKeyType 15 var giContextKey giContextKeyType
16 16
17 func curGID(c context.Context) *globalInfoData { 17 func curGID(c context.Context) *globalInfoData {
18 return c.Value(giContextKey).(*globalInfoData) 18 return c.Value(giContextKey).(*globalInfoData)
19 } 19 }
20 20
21 // useGI adds a wrapper.GlobalInfo context, accessible 21 // useGI adds a gae.GlobalInfo context, accessible
22 // by wrapper.GetGI(c) 22 // by gae.GetGI(c)
23 func useGI(c context.Context) context.Context { 23 func useGI(c context.Context) context.Context {
24 » return wrapper.SetGIFactory(c, func(ic context.Context) wrapper.GlobalIn fo { 24 » return gae.SetGIFactory(c, func(ic context.Context) gae.GlobalInfo {
25 » » return &giImpl{wrapper.DummyGI(), curGID(ic), ic} 25 » » return &giImpl{gae.DummyGI(), curGID(ic), ic}
26 }) 26 })
27 } 27 }
28 28
29 // globalAppID is the 'AppID' of everythin returned from this memory
30 // implementation (DSKeys, GlobalInfo, etc.). There's no way to modify this
31 // value through the API, and there are a couple bits of code where it's hard to
32 // route this value through to without making the internal APIs really complex.
33 const globalAppID = "dev~app"
34
29 type globalInfoData struct{ namespace string } 35 type globalInfoData struct{ namespace string }
30 36
31 type giImpl struct { 37 type giImpl struct {
32 » wrapper.GlobalInfo 38 » gae.GlobalInfo
33 data *globalInfoData 39 data *globalInfoData
34 c context.Context 40 c context.Context
35 } 41 }
36 42
37 var _ = wrapper.GlobalInfo((*giImpl)(nil)) 43 var _ = gae.GlobalInfo((*giImpl)(nil))
38 44
39 func (gi *giImpl) Namespace(ns string) (context.Context, error) { 45 func (gi *giImpl) Namespace(ns string) (context.Context, error) {
40 return context.WithValue(gi.c, giContextKey, &globalInfoData{ns}), nil 46 return context.WithValue(gi.c, giContextKey, &globalInfoData{ns}), nil
41 } 47 }
48
49 func (gi *giImpl) AppID() string {
50 return globalAppID
51 }
OLDNEW
« no previous file with comments | « go/src/infra/gae/libs/gae/memory/gkvlite_utils_test.go ('k') | go/src/infra/gae/libs/gae/memory/memcache.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698