| 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 memory | 5 package memory |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "regexp" | 8 "regexp" |
| 9 "time" |
| 9 | 10 |
| 10 "golang.org/x/net/context" | 11 "golang.org/x/net/context" |
| 11 | 12 |
| 12 tq "github.com/luci/gae/service/taskqueue" | 13 tq "github.com/luci/gae/service/taskqueue" |
| 13 | 14 |
| 14 "github.com/luci/luci-go/common/data/rand/mathrand" | 15 "github.com/luci/luci-go/common/data/rand/mathrand" |
| 15 "github.com/luci/luci-go/common/errors" | 16 "github.com/luci/luci-go/common/errors" |
| 16 ) | 17 ) |
| 17 | 18 |
| 18 /////////////////////////////// public functions /////////////////////////////// | 19 /////////////////////////////// public functions /////////////////////////////// |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 if err != nil { | 99 if err != nil { |
| 99 return err | 100 return err |
| 100 } | 101 } |
| 101 | 102 |
| 102 for _, task := range tasks { | 103 for _, task := range tasks { |
| 103 cb(t.deleteLocked(task, queueName)) | 104 cb(t.deleteLocked(task, queueName)) |
| 104 } | 105 } |
| 105 return nil | 106 return nil |
| 106 } | 107 } |
| 107 | 108 |
| 109 func (t *taskqueueImpl) Lease(maxTasks int, queueName string, leaseTime time.Dur
ation) ([]*tq.Task, error) { |
| 110 panic("not implemented yet") |
| 111 } |
| 112 |
| 113 func (t *taskqueueImpl) LeaseByTag(maxTasks int, queueName string, leaseTime tim
e.Duration, tag string) ([]*tq.Task, error) { |
| 114 panic("not implemented yet") |
| 115 } |
| 116 |
| 117 func (t *taskqueueImpl) ModifyLease(task *tq.Task, queueName string, leaseTime t
ime.Duration) error { |
| 118 panic("not implemented yet") |
| 119 } |
| 120 |
| 108 func (t *taskqueueImpl) Purge(queueName string) error { | 121 func (t *taskqueueImpl) Purge(queueName string) error { |
| 109 t.Lock() | 122 t.Lock() |
| 110 defer t.Unlock() | 123 defer t.Unlock() |
| 111 | 124 |
| 112 return t.purgeLocked(queueName) | 125 return t.purgeLocked(queueName) |
| 113 } | 126 } |
| 114 | 127 |
| 115 func (t *taskqueueImpl) Stats(queueNames []string, cb tq.RawStatsCB) error { | 128 func (t *taskqueueImpl) Stats(queueNames []string, cb tq.RawStatsCB) error { |
| 116 t.Lock() | 129 t.Lock() |
| 117 defer t.Unlock() | 130 defer t.Unlock() |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 for _, task := range tasks { | 214 for _, task := range tasks { |
| 202 cb(t.addLocked(task, queueName)) | 215 cb(t.addLocked(task, queueName)) |
| 203 } | 216 } |
| 204 return nil | 217 return nil |
| 205 } | 218 } |
| 206 | 219 |
| 207 func (t *taskqueueTxnImpl) DeleteMulti([]*tq.Task, string, tq.RawCB) error { | 220 func (t *taskqueueTxnImpl) DeleteMulti([]*tq.Task, string, tq.RawCB) error { |
| 208 return errors.New("taskqueue: cannot DeleteMulti from a transaction") | 221 return errors.New("taskqueue: cannot DeleteMulti from a transaction") |
| 209 } | 222 } |
| 210 | 223 |
| 224 func (t *taskqueueTxnImpl) Lease(maxTasks int, queueName string, leaseTime time.
Duration) ([]*tq.Task, error) { |
| 225 return nil, errors.New("taskqueue: cannot Lease from a transaction") |
| 226 } |
| 227 |
| 228 func (t *taskqueueTxnImpl) LeaseByTag(maxTasks int, queueName string, leaseTime
time.Duration, tag string) ([]*tq.Task, error) { |
| 229 return nil, errors.New("taskqueue: cannot LeaseByTag from a transaction"
) |
| 230 } |
| 231 |
| 232 func (t *taskqueueTxnImpl) ModifyLease(task *tq.Task, queueName string, leaseTim
e time.Duration) error { |
| 233 return errors.New("taskqueue: cannot ModifyLease from a transaction") |
| 234 } |
| 235 |
| 211 func (t *taskqueueTxnImpl) Purge(string) error { | 236 func (t *taskqueueTxnImpl) Purge(string) error { |
| 212 return errors.New("taskqueue: cannot Purge from a transaction") | 237 return errors.New("taskqueue: cannot Purge from a transaction") |
| 213 } | 238 } |
| 214 | 239 |
| 215 func (t *taskqueueTxnImpl) Stats([]string, tq.RawStatsCB) error { | 240 func (t *taskqueueTxnImpl) Stats([]string, tq.RawStatsCB) error { |
| 216 return errors.New("taskqueue: cannot Stats from a transaction") | 241 return errors.New("taskqueue: cannot Stats from a transaction") |
| 217 } | 242 } |
| 218 | 243 |
| 219 func (t *taskqueueTxnImpl) GetTestable() tq.Testable { return t } | 244 func (t *taskqueueTxnImpl) GetTestable() tq.Testable { return t } |
| 220 | 245 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 240 func dupQueue(q tq.QueueData) tq.QueueData { | 265 func dupQueue(q tq.QueueData) tq.QueueData { |
| 241 r := make(tq.QueueData, len(q)) | 266 r := make(tq.QueueData, len(q)) |
| 242 for k, q := range q { | 267 for k, q := range q { |
| 243 r[k] = make(map[string]*tq.Task, len(q)) | 268 r[k] = make(map[string]*tq.Task, len(q)) |
| 244 for tn, t := range q { | 269 for tn, t := range q { |
| 245 r[k][tn] = t.Duplicate() | 270 r[k][tn] = t.Duplicate() |
| 246 } | 271 } |
| 247 } | 272 } |
| 248 return r | 273 return r |
| 249 } | 274 } |
| OLD | NEW |