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

Unified Diff: impl/memory/taskqueue_data.go

Issue 1550863002: impl/memory: Add "PULL" as valid taskqueue method. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Pull tasks can have data. Created 5 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/taskqueue_data.go
diff --git a/impl/memory/taskqueue_data.go b/impl/memory/taskqueue_data.go
index 3a76dc0bd2e10d37692f797eb9c4ce4a70887c7e..967547601b96cf05d75a690948b6147b56bd8650 100644
--- a/impl/memory/taskqueue_data.go
+++ b/impl/memory/taskqueue_data.go
@@ -16,7 +16,6 @@ import (
ds "github.com/luci/gae/service/datastore"
tq "github.com/luci/gae/service/taskqueue"
"github.com/luci/luci-go/common/clock"
- "github.com/luci/luci-go/common/stringset"
)
var (
@@ -128,8 +127,6 @@ func (t *taskQueueData) purgeLocked(queueName string) error {
return nil
}
-var tqOkMethods = stringset.NewFromSlice("GET", "POST", "HEAD", "PUT", "DELETE")
-
func (t *taskQueueData) prepTask(c context.Context, ns string, task *tq.Task, queueName string) (*tq.Task, error) {
toSched := task.Duplicate()
@@ -144,14 +141,20 @@ func (t *taskQueueData) prepTask(c context.Context, ns string, task *tq.Task, qu
}
toSched.Delay = 0
- if toSched.Method == "" {
+ switch toSched.Method {
+ // Methods that can have payloads.
+ case "":
toSched.Method = "POST"
- }
- if !tqOkMethods.Has(toSched.Method) {
- return nil, fmt.Errorf("taskqueue: bad method %q", toSched.Method)
- }
- if toSched.Method != "POST" && toSched.Method != "PUT" {
+ fallthrough
+ case "POST", "PUT", "PULL":
+ break
+
+ // Methods that can not have payloads.
+ case "GET", "HEAD", "DELETE":
toSched.Payload = nil
+
+ default:
+ return nil, fmt.Errorf("taskqueue: bad method %q", toSched.Method)
}
if _, ok := toSched.Header[currentNamespace]; !ok {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698