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

Unified Diff: impl/memory/taskqueue.go

Issue 2995493002: [impl/memory] Enforce named tasks during txn. (Closed)
Patch Set: Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | impl/memory/taskqueue_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/taskqueue.go
diff --git a/impl/memory/taskqueue.go b/impl/memory/taskqueue.go
index ce705e13e0312cf8b6780d3c8c7015cae4e9f41b..eb0ee9ed78be02ed8fe33d174e0a426bccb7dbab 100644
--- a/impl/memory/taskqueue.go
+++ b/impl/memory/taskqueue.go
@@ -64,7 +64,7 @@ func (t *taskqueueImpl) AddMulti(tasks []*tq.Task, queueName string, cb tq.RawTa
}
for _, task := range tasks {
- task, err := prepTask(t.ctx, task, q, t.ns)
+ task, err := prepTask(t.ctx, task, q, t.ns, false)
if err == nil {
err = q.addTask(task)
}
@@ -169,7 +169,7 @@ type taskqueueTxnImpl struct {
var _ tq.RawInterface = (*taskqueueTxnImpl)(nil)
func (t *taskqueueTxnImpl) addLocked(task *tq.Task, q *sortedQueue) (*tq.Task, error) {
- toSched, err := prepTask(t.ctx, task, q, t.ns)
+ toSched, err := prepTask(t.ctx, task, q, t.ns, true)
if err != nil {
return nil, err
}
@@ -263,9 +263,13 @@ func (t *taskqueueTxnImpl) GetTestable() tq.Testable { return &taskQueueTestable
////////////////////////// private functions ///////////////////////////////////
-func prepTask(c context.Context, task *tq.Task, q *sortedQueue, ns string) (*tq.Task, error) {
+func prepTask(c context.Context, task *tq.Task, q *sortedQueue, ns string, inTxn bool) (*tq.Task, error) {
toSched := task.Duplicate()
+ if inTxn && task.Name != "" {
+ return nil, fmt.Errorf("taskqueue: INVALID_TASK_NAME: cannot add named task %q in transaction", task.Name)
+ }
+
if toSched.ETA.IsZero() {
toSched.ETA = clock.Now(c).Add(toSched.Delay)
} else if toSched.Delay != 0 {
« no previous file with comments | « PRESUBMIT.py ('k') | impl/memory/taskqueue_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698