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

Unified Diff: impl/memory/taskqueue_data.go

Issue 1270063003: Make the rest of the services have a similar raw/user interface structure. (Closed) Base URL: https://github.com/luci/gae.git@add_datastore
Patch Set: Created 5 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
Index: impl/memory/taskqueue_data.go
diff --git a/impl/memory/taskqueue_data.go b/impl/memory/taskqueue_data.go
index 906da1c8fe7a9a6ef687c9a384c01436106ffecd..9d7648fc28888cdb685434a5c2c1c63667790d84 100644
--- a/impl/memory/taskqueue_data.go
+++ b/impl/memory/taskqueue_data.go
@@ -124,13 +124,8 @@ var tqOkMethods = map[string]struct{}{
"DELETE": {},
}
-func (t *taskQueueData) prepTask(c context.Context, ns string, task *tq.Task, queueName string) (*tq.Task, string, error) {
- queueName, err := t.getQueueName(queueName)
- if err != nil {
- return nil, "", err
- }
-
- toSched := dupTask(task)
+func (t *taskQueueData) prepTask(c context.Context, ns string, task *tq.Task, queueName string) (*tq.Task, error) {
+ toSched := task.Duplicate()
if toSched.Path == "" {
toSched.Path = "/_ah/queue/" + queueName
@@ -147,7 +142,7 @@ func (t *taskQueueData) prepTask(c context.Context, ns string, task *tq.Task, qu
toSched.Method = "POST"
}
if _, ok := tqOkMethods[toSched.Method]; !ok {
- return nil, "", fmt.Errorf("taskqueue: bad method %q", toSched.Method)
+ return nil, fmt.Errorf("taskqueue: bad method %q", toSched.Method)
}
if toSched.Method != "POST" && toSched.Method != "PUT" {
toSched.Payload = nil
@@ -167,11 +162,11 @@ func (t *taskQueueData) prepTask(c context.Context, ns string, task *tq.Task, qu
toSched.Name = mkName(c, "", t.named[queueName])
} else {
if !validTaskName.MatchString(toSched.Name) {
- return nil, "", errors.New("INVALID_TASK_NAME")
+ return nil, errors.New("INVALID_TASK_NAME")
}
}
- return toSched, queueName, nil
+ return toSched, nil
}
/////////////////////////////// txnTaskQueueData ///////////////////////////////
@@ -201,15 +196,6 @@ func (t *txnTaskQueueData) endTxn() {
atomic.StoreInt32(&t.closed, 1)
}
-func (t *txnTaskQueueData) run(f func() error) error {
- // Slightly different from the SDK... datastore and taskqueue each implement
- // this here, where in the SDK only datastore.transaction.Call does.
- if atomic.LoadInt32(&t.closed) == 1 {
- return fmt.Errorf("taskqueue: transaction context has expired")
- }
- return f()
-}
-
func (t *txnTaskQueueData) ResetTasks() {
t.Lock()
defer t.Unlock()
@@ -237,7 +223,7 @@ func (t *txnTaskQueueData) GetTransactionTasks() tq.AnonymousQueueData {
for k, vs := range t.anony {
ret[k] = make([]*tq.Task, len(vs))
for i, v := range vs {
- tsk := dupTask(v)
+ tsk := v.Duplicate()
tsk.Name = ""
ret[k][i] = tsk
}

Powered by Google App Engine
This is Rietveld 408576698