OLD | NEW |
1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be 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) tq.RawInterface { |
21 » » return tqImpl{AEContext(ci)} | 21 » » return tqImpl{getAEContext(ci)} |
22 }) | 22 }) |
23 } | 23 } |
24 | 24 |
25 type tqImpl struct { | 25 type tqImpl struct { |
26 aeCtx context.Context | 26 aeCtx context.Context |
27 } | 27 } |
28 | 28 |
29 func init() { | 29 func init() { |
30 const taskExpectedFields = 10 | 30 const taskExpectedFields = 10 |
31 // Runtime-assert that the number of fields in the Task structs match, t
o | 31 // 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 } | 128 } |
129 for _, s := range stats { | 129 for _, s := range stats { |
130 cb((*tq.Statistics)(&s), nil) | 130 cb((*tq.Statistics)(&s), nil) |
131 } | 131 } |
132 return nil | 132 return nil |
133 } | 133 } |
134 | 134 |
135 func (t tqImpl) GetTestable() tq.Testable { | 135 func (t tqImpl) GetTestable() tq.Testable { |
136 return nil | 136 return nil |
137 } | 137 } |
OLD | NEW |