Chromium Code Reviews| Index: service/taskqueue/interface.go |
| diff --git a/service/taskqueue/interface.go b/service/taskqueue/interface.go |
| index ae78f2fa3cb1e08359f8f6b910b084063298e7e7..fe318d3bd0e00a616eb20d50bf15cd8bf5799c7d 100644 |
| --- a/service/taskqueue/interface.go |
| +++ b/service/taskqueue/interface.go |
| @@ -56,11 +56,10 @@ func Delete(c context.Context, queueName string, tasks ...*Task) error { |
| return err |
| } |
| -// NOTE(riannucci): No support for pull taskqueues. We're not planning on |
| -// making pull-queue clients which RUN in appengine (e.g. they'd all be |
| -// external REST consumers). If someone needs this, it will need to be added |
| -// here and in RawInterface. The theory is that a good lease API might look |
| -// like: |
| +// NOTE(riannucci): Pull task queues API can be extended to support automatic |
| +// lease management. |
| +// |
| +// The theory is that a good lease API might look like: |
| // |
| // func Lease(queueName, tag string, batchSize int, duration time.Time, cb func(*Task, error<-)) |
| // |
| @@ -75,6 +74,33 @@ func Delete(c context.Context, queueName string, tasks ...*Task) error { |
| // that each call to cb would have 'duration' amount of time to work on the |
| // task, as well as releasing as many leased tasks as it can on a failure. |
| +// Lease leases tasks from a queue. |
|
Vadim Sh.
2016/11/18 03:42:12
all docs are copy-paste from official site
|
| +// |
| +// leaseTime is in seconds. The number of tasks fetched will be at most |
|
Vadim Sh.
2016/11/18 03:53:53
actually int for leaseTime is BS, I'll convert it
|
| +// maxTasks. |
| +func Lease(c context.Context, maxTasks int, queueName string, leaseTime int) ([]*Task, error) { |
| + return Raw(c).Lease(maxTasks, queueName, leaseTime) |
| +} |
| + |
| +// LeaseByTag leases tasks from a queue, grouped by tag. |
| +// |
| +// If tag is empty, then the returned tasks are grouped by the tag of the task |
|
Vadim Sh.
2016/11/18 03:42:12
:( why they did it, I'll have to reimplement all t
|
| +// with earliest ETA. |
| +// |
| +// leaseTime is in seconds. The number of tasks fetched will be at most |
| +// maxTasks. |
| +func LeaseByTag(c context.Context, maxTasks int, queueName string, leaseTime int, tag string) ([]*Task, error) { |
| + return Raw(c).LeaseByTag(maxTasks, queueName, leaseTime, tag) |
| +} |
| + |
| +// ModifyLease modifies the lease of a task. |
| +// |
| +// Used to request more processing time, or to abandon processing. leaseTime is |
| +// in seconds and must not be negative. |
| +func ModifyLease(c context.Context, task *Task, queueName string, leaseTime int) error { |
| + return Raw(c).ModifyLease(task, queueName, leaseTime) |
| +} |
| + |
| // Purge purges all tasks form the named queue. |
| func Purge(c context.Context, queueName string) error { |
| return Raw(c).Purge(queueName) |