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

Side by Side Diff: go/src/infra/gae/libs/wrapper/memory/taskqueue.go

Issue 1143053004: Simplify memory package interface. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: switch to blasters Created 5 years, 6 months 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
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 memory 5 package memory
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "infra/gae/libs/wrapper" 9 "infra/gae/libs/wrapper"
10 "math/rand" 10 "math/rand"
11 "net/http" 11 "net/http"
12 "regexp" 12 "regexp"
13 "time" 13 "time"
14 14
15 "golang.org/x/net/context" 15 "golang.org/x/net/context"
16 16
17 "appengine" 17 "appengine"
18 "appengine/taskqueue" 18 "appengine/taskqueue"
19 "appengine_internal" 19 "appengine_internal"
20 dbpb "appengine_internal/datastore" 20 dbpb "appengine_internal/datastore"
21 pb "appengine_internal/taskqueue" 21 pb "appengine_internal/taskqueue"
22 ) 22 )
23 23
24 /////////////////////////////// public functions /////////////////////////////// 24 /////////////////////////////// public functions ///////////////////////////////
25 25
26 // UseTQ adds a wrapper.TaskQueue implementation to context, accessible 26 func useTQ(c context.Context) context.Context {
27 // by wrapper.GetTQ(c)
28 func UseTQ(c context.Context) context.Context {
29 return wrapper.SetTQFactory(c, func(ic context.Context) wrapper.TaskQueu e { 27 return wrapper.SetTQFactory(c, func(ic context.Context) wrapper.TaskQueu e {
30 tqd := cur(ic).Get(memContextTQIdx) 28 tqd := cur(ic).Get(memContextTQIdx)
31 var ret interface { 29 var ret interface {
32 wrapper.TQTestable 30 wrapper.TQTestable
33 wrapper.TaskQueue 31 wrapper.TaskQueue
34 } 32 }
35 switch x := tqd.(type) { 33 switch x := tqd.(type) {
36 case *taskQueueData: 34 case *taskQueueData:
37 ret = &taskqueueImpl{ 35 ret = &taskqueueImpl{
38 wrapper.DummyTQ(), 36 wrapper.DummyTQ(),
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 func dupQueue(q wrapper.QueueData) wrapper.QueueData { 298 func dupQueue(q wrapper.QueueData) wrapper.QueueData {
301 r := make(wrapper.QueueData, len(q)) 299 r := make(wrapper.QueueData, len(q))
302 for k, q := range q { 300 for k, q := range q {
303 r[k] = make(map[string]*taskqueue.Task, len(q)) 301 r[k] = make(map[string]*taskqueue.Task, len(q))
304 for tn, t := range q { 302 for tn, t := range q {
305 r[k][tn] = dupTask(t) 303 r[k][tn] = dupTask(t)
306 } 304 }
307 } 305 }
308 return r 306 return r
309 } 307 }
OLDNEW
« no previous file with comments | « go/src/infra/gae/libs/wrapper/memory/memcache_test.go ('k') | go/src/infra/gae/libs/wrapper/memory/taskqueue_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698