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

Unified Diff: go/src/infra/gae/libs/wrapper/gae/context.go

Issue 1143053004: Simplify memory package interface. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: switch to blasters Created 5 years, 7 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 | « go/src/infra/gae/libs/meta/eg_test.go ('k') | go/src/infra/gae/libs/wrapper/gae/datastore.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/libs/wrapper/gae/context.go
diff --git a/go/src/infra/gae/libs/wrapper/gae/context.go b/go/src/infra/gae/libs/wrapper/gae/context.go
index be90906df6140acbb26abb6baaeeed7a9b98028c..2bf13f2a14e089975dcb869db606b475307f7baa 100644
--- a/go/src/infra/gae/libs/wrapper/gae/context.go
+++ b/go/src/infra/gae/libs/wrapper/gae/context.go
@@ -5,6 +5,7 @@
package gae
import (
+ "errors"
"golang.org/x/net/context"
"appengine"
@@ -12,15 +13,25 @@ import (
"github.com/mjibson/goon"
)
-// Enable adds the appengine Context to c.
-func Enable(c context.Context, gaeCtx appengine.Context) context.Context {
- return context.WithValue(c, goonContextKey, goon.FromContext(gaeCtx))
-}
-
-// Use calls ALL of this packages Use* methods on c. This enables all
-// gae/wrapper Get* api's.
-func Use(c context.Context) context.Context {
- return UseDS(UseMC(UseTQ(UseGI(c))))
+// Use adds implementations for the following gae/wrapper interfaces to the
+// context:
+// * wrapper.Datastore
+// * wrapper.TaskQueue
+// * wrapper.Memcache
+// * wrapper.GlobalInfo
+//
+// These can be retrieved with the "gae/wrapper".Get functions.
+//
+// The implementations are all backed by the real "appengine" SDK functionality,
+// and by "github.com/mjibson/goon".
+//
+// Using this more than once per context.Context will cause a panic.
+func Use(c context.Context, gaeCtx appengine.Context) context.Context {
+ if c.Value(goonContextKey) != nil {
+ panic(errors.New("gae.Use: called twice on the same Context"))
+ }
+ c = context.WithValue(c, goonContextKey, goon.FromContext(gaeCtx))
+ return useDS(useMC(useTQ(useGI(c))))
}
type key int
« no previous file with comments | « go/src/infra/gae/libs/meta/eg_test.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