luci: go.chromium.org/luci/resultdb/internal/tasks Index | Files

package tasks

import "go.chromium.org/luci/resultdb/internal/tasks"

Package tasks implements asynchronous invocation processing.

Index

Package Files

finalization.go tasks.go

Variables

var AllTypes = []Type{BQExport, TryFinalizeInvocation}

AllTypes is a slice of all known types of tasks.

var ErrConflict = fmt.Errorf("the task is already leased")

ErrConflict is returned by Lease if the task does not exist or is already leased.

func Delete Uses

func Delete(ctx context.Context, typ Type, id string) error

Delete deletes a task.

func Enqueue Uses

func Enqueue(typ Type, taskID string, invID span.InvocationID, payload interface{}, processAfter time.Time) *spanner.Mutation

Enqueue inserts one row to InvocationTasks.

func EnqueueBQExport Uses

func EnqueueBQExport(invID span.InvocationID, payload *pb.BigQueryExport, processAfter time.Time) *spanner.Mutation

EnqueueBQExport inserts one row to InvocationTasks for a bq export task.

func Lease Uses

func Lease(ctx context.Context, typ Type, id string, duration time.Duration) (invID span.InvocationID, payload []byte, err error)

Lease leases an invocation task. If the task does not exist or is already leased, returns ErrConflict.

func Peek Uses

func Peek(ctx context.Context, typ Type, f func(id string) error) error

Peek calls f on available tasks of a given type.

func StartInvocationFinalization Uses

func StartInvocationFinalization(ctx context.Context, txn *spanner.ReadWriteTransaction, id span.InvocationID, interrupted bool) 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.

type Type Uses

type Type string

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.

func (Type) Key Uses

func (t Type) Key(taskID string) spanner.Key

Key returns a Spanner key for the InvocationTasks row.

Package tasks imports 11 packages (graph) and is imported by 2 packages. Updated 2020-03-30. Refresh now. Tools for package owners.