Documentation ¶
Index ¶
- Variables
- func AddRawFilters(c context.Context, filts ...RawFilter) context.Context
- func SetRaw(c context.Context, tq RawInterface) context.Context
- func SetRawFactory(c context.Context, tqf RawFactory) context.Context
- type AnonymousQueueData
- type Interface
- type QueueData
- type RawCB
- type RawFactory
- type RawFilter
- type RawInterface
- type RawStatsCB
- type RawTaskCB
- type RetryOptions
- type Statistics
- type Task
- type Testable
Constants ¶
This section is empty.
Variables ¶
var ErrTaskAlreadyAdded = taskqueue.ErrTaskAlreadyAdded
ErrTaskAlreadyAdded is the error returned when a named task is added to a task queue more than once.
Functions ¶
func AddRawFilters ¶
AddRawFilters adds RawInterface filters to the context.
func SetRaw ¶
func SetRaw(c context.Context, tq RawInterface) context.Context
SetRaw sets the current RawInterface object in the context. Useful for testing with a quick mock. This is just a shorthand SetRawFactory invocation to SetRaw a RawFactory which always returns the same object.
func SetRawFactory ¶
func SetRawFactory(c context.Context, tqf RawFactory) context.Context
SetRawFactory sets the function to produce RawInterface instances, as returned by the GetRaw method.
Types ¶
type AnonymousQueueData ¶
AnonymousQueueData is {queueName: [*TQTask]}
type Interface ¶
type Interface interface { // NewTask simply creates a new Task object with the Path field populated. // The path parameter may be blank, if you want to use the default task path // ("/_ah/queue/<queuename>"). NewTask(path string) *Task Add(task *Task, queueName string) error Delete(task *Task, queueName string) error AddMulti(tasks []*Task, queueName string) error DeleteMulti(tasks []*Task, queueName string) error Purge(queueName string) error Stats(queueNames ...string) ([]Statistics, error) Testable() Testable Raw() RawInterface }
Interface is the full interface to the Task Queue service.
type RawCB ¶
type RawCB func(error)
RawCB is a simple callback for RawInterface.DeleteMulti, getting the error for the attempted deletion.
type RawFactory ¶
type RawFactory func(c context.Context, wantTxn bool) RawInterface
RawFactory is the function signature for RawFactory methods compatible with SetRawFactory. wantTxn is true if the Factory should return the taskqueue in the current transaction, and false if the Factory should return the non-transactional (root) taskqueue service.
type RawFilter ¶
type RawFilter func(context.Context, RawInterface) RawInterface
RawFilter is the function signature for a RawFilter TQ implementation. It gets the current TQ implementation, and returns a new TQ implementation backed by the one passed in.
type RawInterface ¶
type RawInterface interface { // AddMulti adds multiple tasks to the given queue, calling cb for each item. // // The task passed to the callback function will have all the default values // filled in, and will have the Name field populated, if the input task was // anonymous (e.g. the Name field was blank). AddMulti(tasks []*Task, queueName string, cb RawTaskCB) error DeleteMulti(tasks []*Task, queueName string, cb RawCB) error Purge(queueName string) error Stats(queueNames []string, cb RawStatsCB) error Testable() Testable }
RawInterface is the full interface to the Task Queue service.
func GetRaw ¶
func GetRaw(c context.Context) RawInterface
GetRaw gets the RawInterface implementation from context.
func GetRawNoTxn ¶
func GetRawNoTxn(c context.Context) RawInterface
GetRawNoTxn gets the RawInterface implementation from context. If there's a currently active transaction, this will return a non-transactional connection to the taskqueue, otherwise this is the same as GetRaw.
type RawStatsCB ¶
type RawStatsCB func(*Statistics, error)
RawStatsCB is the callback for RawInterface.Stats. It takes the statistics object, as well as an error (e.g. in case the queue doesn't exist).
type RawTaskCB ¶
RawTaskCB is the callback for RawInterface.AddMulti, getting the added task and an error.
type RetryOptions ¶
type RetryOptions struct { // Number of tries/leases after which the task fails permanently and is deleted. // If AgeLimit is also set, both limits must be exceeded for the task to fail permanently. RetryLimit int32 // Maximum time allowed since the task's first try before the task fails permanently and is deleted (only for push tasks). // If RetryLimit is also set, both limits must be exceeded for the task to fail permanently. AgeLimit time.Duration // Minimum time between successive tries (only for push tasks). MinBackoff time.Duration // Maximum time between successive tries (only for push tasks). MaxBackoff time.Duration // Maximum number of times to double the interval between successive tries before the intervals increase linearly (only for push tasks). MaxDoublings int32 // If MaxDoublings is zero, set ApplyZeroMaxDoublings to true to override the default non-zero value. // Otherwise a zero MaxDoublings is ignored and the default is used. ApplyZeroMaxDoublings bool }
RetryOptions let you control whether to retry a task and the backoff intervals between tries.
type Statistics ¶
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 }
Statistics represents statistics about a single task queue.
type Task ¶
type Task struct { // Path is the worker URL for the task. // If unset, it will default to /_ah/queue/<queue_name>. Path string // Payload is the data for the task. // This will be delivered as the HTTP request body. // It is only used when Method is POST, PUT or PULL. // url.Values' Encode method may be used to generate this for POST requests. Payload []byte // Additional HTTP headers to pass at the task's execution time. // To schedule the task to be run with an alternate app version // or backend, set the "Host" header. Header http.Header // Method is the HTTP method for the task ("GET", "POST", etc.), // or "PULL" if this is task is destined for a pull-based queue. // If empty, this defaults to "POST". Method string // A name for the task. // If empty, a name will be chosen. Name string // Delay specifies the duration the task queue service must wait // before executing the task. // Either Delay or ETA may be set, but not both. Delay time.Duration // ETA specifies the earliest time a task may be executed (push queues) // or leased (pull queues). // Either Delay or ETA may be set, but not both. ETA time.Time // The number of times the task has been dispatched or leased. RetryCount int32 // Tag for the task. Only used when Method is PULL. Tag string // Retry options for this task. May be nil. RetryOptions *RetryOptions }
Task represents a taskqueue task to be executed.