| 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, wantTxn bool) tq.Raw
Interface { | 20 » return tq.SetRawFactory(c, func(ci context.Context) tq.RawInterface { |
| 21 » » if wantTxn { | 21 » » return tqImpl{AEContext(ci)} |
| 22 » » » return tqImpl{AEContext(ci)} | |
| 23 » » } | |
| 24 » » return tqImpl{AEContextNoTxn(ci)} | |
| 25 }) | 22 }) |
| 26 } | 23 } |
| 27 | 24 |
| 28 type tqImpl struct { | 25 type tqImpl struct { |
| 29 aeCtx context.Context | 26 aeCtx context.Context |
| 30 } | 27 } |
| 31 | 28 |
| 32 func init() { | 29 func init() { |
| 33 const taskExpectedFields = 10 | 30 const taskExpectedFields = 10 |
| 34 // 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 stats, err := taskqueue.QueueStats(t.aeCtx, queueNames) | 125 stats, err := taskqueue.QueueStats(t.aeCtx, queueNames) |
| 129 if err != nil { | 126 if err != nil { |
| 130 return err | 127 return err |
| 131 } | 128 } |
| 132 for _, s := range stats { | 129 for _, s := range stats { |
| 133 cb((*tq.Statistics)(&s), nil) | 130 cb((*tq.Statistics)(&s), nil) |
| 134 } | 131 } |
| 135 return nil | 132 return nil |
| 136 } | 133 } |
| 137 | 134 |
| 138 func (t tqImpl) Testable() tq.Testable { | 135 func (t tqImpl) GetTestable() tq.Testable { |
| 139 return nil | 136 return nil |
| 140 } | 137 } |
| OLD | NEW |