OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package prod | 5 package prod |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "reflect" | 9 "reflect" |
10 | 10 |
11 tq "github.com/luci/gae/service/taskqueue" | 11 tq "github.com/luci/gae/service/taskqueue" |
12 "golang.org/x/net/context" | 12 "golang.org/x/net/context" |
13 "google.golang.org/appengine" | 13 "google.golang.org/appengine" |
14 "google.golang.org/appengine/taskqueue" | 14 "google.golang.org/appengine/taskqueue" |
15 ) | 15 ) |
16 | 16 |
17 // useTQ adds a gae.TaskQueue implementation to context, accessible | 17 // useTQ adds a gae.TaskQueue implementation to context, accessible |
18 // by gae.GetTQ(c) | 18 // by gae.GetTQ(c) |
19 func useTQ(c context.Context) context.Context { | 19 func useTQ(c context.Context) context.Context { |
20 » return tq.SetRawFactory(c, func(ci context.Context) tq.RawInterface { | 20 » return tq.SetRawFactory(c, func(ci context.Context, wantTxn bool) tq.Raw
Interface { |
21 » » return tqImpl{AEContext(ci)} | 21 » » if wantTxn { |
| 22 » » » return tqImpl{AEContext(ci)} |
| 23 » » } |
| 24 » » return tqImpl{AEContextNoTxn(ci)} |
22 }) | 25 }) |
23 } | 26 } |
24 | 27 |
25 type tqImpl struct { | 28 type tqImpl struct { |
26 aeCtx context.Context | 29 aeCtx context.Context |
27 } | 30 } |
28 | 31 |
29 func init() { | 32 func init() { |
30 const taskExpectedFields = 10 | 33 const taskExpectedFields = 10 |
31 // Runtime-assert that the number of fields in the Task structs match, t
o | 34 // Runtime-assert that the number of fields in the Task structs match, t
o |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 131 } |
129 for _, s := range stats { | 132 for _, s := range stats { |
130 cb((*tq.Statistics)(&s), nil) | 133 cb((*tq.Statistics)(&s), nil) |
131 } | 134 } |
132 return nil | 135 return nil |
133 } | 136 } |
134 | 137 |
135 func (t tqImpl) Testable() tq.Testable { | 138 func (t tqImpl) Testable() tq.Testable { |
136 return nil | 139 return nil |
137 } | 140 } |
OLD | NEW |