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

Side by Side Diff: go/src/infra/gae/libs/wrapper/gae/context.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
(Empty)
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
3 // found in the LICENSE file.
4
5 package gae
6
7 import (
8 "errors"
9 "golang.org/x/net/context"
10
11 "appengine"
12
13 "github.com/mjibson/goon"
14 )
15
16 // Use adds implementations for the following gae/wrapper interfaces to the
17 // context:
18 // * wrapper.Datastore
19 // * wrapper.TaskQueue
20 // * wrapper.Memcache
21 // * wrapper.GlobalInfo
22 //
23 // These can be retrieved with the "gae/wrapper".Get functions.
24 //
25 // The implementations are all backed by the real "appengine" SDK functionality,
26 // and by "github.com/mjibson/goon".
27 //
28 // Using this more than once per context.Context will cause a panic.
29 func Use(c context.Context, gaeCtx appengine.Context) context.Context {
30 if c.Value(goonContextKey) != nil {
31 panic(errors.New("gae.Use: called twice on the same Context"))
32 }
33 c = context.WithValue(c, goonContextKey, goon.FromContext(gaeCtx))
34 return useDS(useMC(useTQ(useGI(c))))
35 }
36
37 type key int
38
39 var goonContextKey key
40
41 func ctx(c context.Context) *goon.Goon {
42 return c.Value(goonContextKey).(*goon.Goon)
43 }
OLDNEW
« no previous file with comments | « go/src/infra/gae/libs/wrapper/gae/commonErrors/errors.go ('k') | go/src/infra/gae/libs/wrapper/gae/datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698