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

Unified Diff: impl/prod/context.go

Issue 1494223002: Add API to allow you to get the non-transactional datastore or taskqueue. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 5 years 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
Index: impl/prod/context.go
diff --git a/impl/prod/context.go b/impl/prod/context.go
index 11bd6c24e33189a6c1e815b975a15ee2ff2c7b56..48238aa5925c8b3abf7eda4459b4d96ba2c5832f 100644
--- a/impl/prod/context.go
+++ b/impl/prod/context.go
@@ -14,8 +14,9 @@ import (
type key int
var (
- prodContextKey key
- probeCacheKey key = 1
+ prodContextKey key
+ prodContextNoTxKey key = 1
+ probeCacheKey key = 2
)
// AEContext retrieves the raw "google.golang.org/appengine" compatible Context.
@@ -24,6 +25,12 @@ func AEContext(c context.Context) context.Context {
return aeCtx
}
+// AEContextNoTX retrieves the raw "google.golang.org/appengine" compatible Context.
Vadim Sh. 2015/12/04 03:22:04 document the difference between AEContextNoTX and
+func AEContextNoTX(c context.Context) context.Context {
+ aeCtx, _ := c.Value(prodContextNoTxKey).(context.Context)
+ return aeCtx
+}
+
// Use adds production implementations for all the gae services to the
// context.
//
@@ -40,5 +47,6 @@ func AEContext(c context.Context) context.Context {
func Use(c context.Context, r *http.Request) context.Context {
aeCtx := appengine.NewContext(r)
c = context.WithValue(c, prodContextKey, aeCtx)
+ c = context.WithValue(c, prodContextNoTxKey, aeCtx)
return useUser(useURLFetch(useRDS(useMC(useTQ(useGI(c))))))
}

Powered by Google App Engine
This is Rietveld 408576698