Package tasks implements asynchronous invocation processing.
AllTypes is a slice of all known types of tasks.
ErrConflict is returned by Lease if the task does not exist or is already leased.
PermanentFailure set in an error indicates that the err is not resolvable by a retry. Such task is doomed.
Delete deletes a task.
Enqueue inserts one row to InvocationTasks.
func EnqueueBQExport(invID invocations.ID, payload *pb.BigQueryExport, processAfter time.Time) *spanner.Mutation
EnqueueBQExport inserts one row to InvocationTasks for a bq export task.
Lease leases an invocation task. If the task does not exist or is already leased, returns ErrConflict.
Peek calls f on available tasks of a given type.
func StartInvocationFinalization(ctx context.Context, txn *spanner.ReadWriteTransaction, id invocations.ID) error
StartInvocationFinalization changes invocation state to FINALIZING and enqueues a TryFinalizeInvocation task.
The caller is responsible for ensuring that the invocation is active.
TODO(nodir): this package is not a great place for this function, but there is no better package at the moment. Keep it here for now, but consider a new package as the code base grows.
Dispatcher queries for available tasks and dispatches them to goroutines.
Run queries tasks and dispatches them to goroutines until ctx is canceled. Logs errors.
TaskFunc can execute a task. If the returned error is tagged with PermanentFailure, then the failed task is deleted.
Type is a value for InvocationTasks.TaskType column. It defines what a task does.
const ( // BQExport is a type of task that exports an invocation to BigQuery. // The task payload is binary-encoded BigQueryExport message. BQExport Type = "bq_export" // TryFinalizeInvocation is a type of task that tries to finalize an // invocation. No payload. TryFinalizeInvocation Type = "finalize" )
Types of invocation tasks. Used as InvocationTasks.TaskType column value.
Key returns a Spanner key for the InvocationTasks row.