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

Side by Side Diff: filter/featureBreaker/tq.go

Issue 2512093002: Add support for Pull Queues to prod implementation. (Closed)
Patch Set: Created 4 years, 1 month 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 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 featureBreaker 5 package featureBreaker
6 6
7 import ( 7 import (
8 "golang.org/x/net/context" 8 "golang.org/x/net/context"
9 9
10 tq "github.com/luci/gae/service/taskqueue" 10 tq "github.com/luci/gae/service/taskqueue"
11 ) 11 )
12 12
13 type tqState struct { 13 type tqState struct {
14 *state 14 *state
15 15
16 tq tq.RawInterface 16 tq tq.RawInterface
17 } 17 }
18 18
19 var _ tq.RawInterface = (*tqState)(nil) 19 var _ tq.RawInterface = (*tqState)(nil)
20 20
21 func (t *tqState) AddMulti(tasks []*tq.Task, queueName string, cb tq.RawTaskCB) error { 21 func (t *tqState) AddMulti(tasks []*tq.Task, queueName string, cb tq.RawTaskCB) error {
22 return t.run(func() (err error) { return t.tq.AddMulti(tasks, queueName, cb) }) 22 return t.run(func() (err error) { return t.tq.AddMulti(tasks, queueName, cb) })
23 } 23 }
24 24
25 func (t *tqState) DeleteMulti(tasks []*tq.Task, queueName string, cb tq.RawCB) e rror { 25 func (t *tqState) DeleteMulti(tasks []*tq.Task, queueName string, cb tq.RawCB) e rror {
26 return t.run(func() error { return t.tq.DeleteMulti(tasks, queueName, cb ) }) 26 return t.run(func() error { return t.tq.DeleteMulti(tasks, queueName, cb ) })
27 } 27 }
28 28
29 func (t *tqState) Lease(maxTasks int, queueName string, leaseTime int) (tasks [] *tq.Task, err error) {
30 err = t.run(func() (err error) {
31 tasks, err = t.tq.Lease(maxTasks, queueName, leaseTime)
32 return
33 })
34 if err != nil {
35 tasks = nil
36 }
37 return
38 }
39
40 func (t *tqState) LeaseByTag(maxTasks int, queueName string, leaseTime int, tag string) (tasks []*tq.Task, err error) {
41 err = t.run(func() (err error) {
42 tasks, err = t.tq.LeaseByTag(maxTasks, queueName, leaseTime, tag )
43 return
44 })
45 if err != nil {
46 tasks = nil
47 }
48 return
49 }
50
51 func (t *tqState) ModifyLease(task *tq.Task, queueName string, leaseTime int) er ror {
52 return t.run(func() error { return t.tq.ModifyLease(task, queueName, lea seTime) })
53 }
54
29 func (t *tqState) Purge(queueName string) error { 55 func (t *tqState) Purge(queueName string) error {
30 return t.run(func() error { return t.tq.Purge(queueName) }) 56 return t.run(func() error { return t.tq.Purge(queueName) })
31 } 57 }
32 58
33 func (t *tqState) Stats(queueNames []string, cb tq.RawStatsCB) error { 59 func (t *tqState) Stats(queueNames []string, cb tq.RawStatsCB) error {
34 return t.run(func() error { return t.tq.Stats(queueNames, cb) }) 60 return t.run(func() error { return t.tq.Stats(queueNames, cb) })
35 } 61 }
36 62
37 func (t *tqState) GetTestable() tq.Testable { 63 func (t *tqState) GetTestable() tq.Testable {
38 return t.tq.GetTestable() 64 return t.tq.GetTestable()
39 } 65 }
40 66
41 // FilterTQ installs a featureBreaker TaskQueue filter in the context. 67 // FilterTQ installs a featureBreaker TaskQueue filter in the context.
42 func FilterTQ(c context.Context, defaultError error) (context.Context, FeatureBr eaker) { 68 func FilterTQ(c context.Context, defaultError error) (context.Context, FeatureBr eaker) {
43 state := newState(defaultError) 69 state := newState(defaultError)
44 return tq.AddRawFilters(c, func(ic context.Context, tq tq.RawInterface) tq.RawInterface { 70 return tq.AddRawFilters(c, func(ic context.Context, tq tq.RawInterface) tq.RawInterface {
45 return &tqState{state, tq} 71 return &tqState{state, tq}
46 }), state 72 }), state
47 } 73 }
OLDNEW
« no previous file with comments | « filter/count/tq.go ('k') | impl/dummy/dummy.go » ('j') | service/taskqueue/interface.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698