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 |
} |