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

Side by Side Diff: impl/prod/taskqueue.go

Issue 1494223002: Add API to allow you to get the non-transactional datastore or taskqueue. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix doc and naming 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 unified diff | Download patch
« no previous file with comments | « impl/prod/raw_datastore.go ('k') | service/datastore/context.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « impl/prod/raw_datastore.go ('k') | service/datastore/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698