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 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 Loading... |
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 } |
OLD | NEW |