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

Unified Diff: service/taskqueue/task.go

Issue 1890983004: service/taskqueue: Add NewPOSTTask, remove NewTask (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Zero value. Created 4 years, 8 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 | « service/taskqueue/interface.go ('k') | service/taskqueue/taskqueue.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/taskqueue/task.go
diff --git a/service/taskqueue/types.go b/service/taskqueue/task.go
similarity index 78%
copy from service/taskqueue/types.go
copy to service/taskqueue/task.go
index 1ce2bf88dcbc6988090795cd98a91ceca2712a5c..c24c2a6ee4f8198f2f164ccda500028dd80d3d84 100644
--- a/service/taskqueue/types.go
+++ b/service/taskqueue/task.go
@@ -2,32 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This file contains types which are mirrors/duplicates of the upstream SDK
-// types. This exists so that users can depend solely on this wrapper library
-// without necessarially needing an SDK implementation present.
-//
-// This was done (instead of type-aliasing from the github version of the SDK)
-// because some of the types need to be tweaked (like Task.RetryOptions) to
-// interact well with the wrapper, and the inconsistency of having some types
-// defined by the gae package and others defined by the SDK was pretty awkward.
-
package taskqueue
import (
"net/http"
+ "net/url"
"time"
)
-// Statistics represents statistics about a single task queue.
-type Statistics struct {
- Tasks int // may be an approximation
- OldestETA time.Time // zero if there are no pending tasks
-
- Executed1Minute int // tasks executed in the last minute
- InFlight int // tasks executing now
- EnforcedRate float64 // requests per second
-}
-
// RetryOptions let you control whether to retry a task and the backoff intervals between tries.
type RetryOptions struct {
// Number of tries/leases after which the task fails permanently and is deleted.
@@ -98,6 +80,18 @@ type Task struct {
RetryOptions *RetryOptions
}
+// NewPOSTTask creates a Task that will POST to a path with URL-encoded values.
+func NewPOSTTask(path string, params url.Values) *Task {
+ h := make(http.Header)
+ h.Set("Content-Type", "application/x-www-form-urlencoded")
+ return &Task{
+ Path: path,
+ Payload: []byte(params.Encode()),
+ Header: h,
+ Method: "POST",
+ }
+}
+
// Duplicate returns a deep copy of this Task.
func (t *Task) Duplicate() *Task {
ret := *t
« no previous file with comments | « service/taskqueue/interface.go ('k') | service/taskqueue/taskqueue.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698