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

Unified Diff: impl/prod/context.go

Issue 1515413002: Transfer context deadline to AEContext. (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/prod/context.go
diff --git a/impl/prod/context.go b/impl/prod/context.go
index 8b62dbe08f67d3aa4c65453526fde20cf7051d8a..e683051e86df26bb8dbcc4b350ff2ecc51720193 100644
--- a/impl/prod/context.go
+++ b/impl/prod/context.go
@@ -21,8 +21,15 @@ var (
)
// AEContext retrieves the raw "google.golang.org/appengine" compatible Context.
+//
+// It also transfers deadline of `c` to AE context, since deadline is used for
+// RPCs. Doesn't transfer cancelation ability though (since it's ignored by GAE
+// anyway).
func AEContext(c context.Context) context.Context {
aeCtx, _ := c.Value(prodContextKey).(context.Context)
+ if deadline, ok := c.Deadline(); ok {
+ aeCtx, _ = context.WithDeadline(aeCtx, deadline)
+ }
return aeCtx
}
@@ -34,6 +41,9 @@ func AEContextNoTxn(c context.Context) context.Context {
if err != nil {
panic(err)
}
+ if deadline, ok := c.Deadline(); ok {
+ aeCtx, _ = context.WithDeadline(aeCtx, deadline)
+ }
return aeCtx
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698