Back to godoc.org

Package internal

v0.0.0-...-1557bcf
Latest Go to latest

The latest major version is .

Published: Aug 13, 2020 | License: Apache-2.0 | Module: github.com/luci/luci-go

Index

Constants

const TraceContextHeader = "X-Luci-Tq-Trace-Context"

TraceContextHeader is name of a header that contains the trace context of a span that produced the task.

It is always set regardless of InheritTraceContext setting. This header is read only by tq.Dispatcher itself and exists mostly for FYI purposes.

Variables

var ErrStaleReminder = errors.New("the reminder is stale already")

ErrStaleReminder is returned by ProcessReminderPostTxn.

func ProcessReminderPostTxn

func ProcessReminderPostTxn(ctx context.Context, s Submitter, db db.DB, r *reminder.Reminder, req *taskspb.CreateTaskRequest, msg proto.Message, extra *tqpb.Extra) error

ProcessReminderPostTxn is called right after the transaction that saves the reminder.

If the reminder is fresh enough, it means the sweeper hasn't picked it up yet and we can submit the task right now. This is the "happy" path. If the reminder is sufficiently old, or if SubmitFromReminder fails, we'll let the sweeper try to submit the task. It is the "sweep" path.

Returns ErrStaleReminder if the reminder is stale and should be handled by the sweeper.

func Submit

func Submit(ctx context.Context, s Submitter, req *taskspb.CreateTaskRequest, msg proto.Message, extra *tqpb.Extra, t TxnPath) error

Submit submits the prepared request through the given submitter.

Mutates `req` by adding tracing headers to it.

Recognizes AlreadyExists as success. Annotates retriable errors with transient.Tag.

func SubmitBatch

func SubmitBatch(ctx context.Context, sub Submitter, db db.DB, batch []*reminder.Reminder) (int, error)

SubmitBatch process a batch of reminders by submitting corresponding Cloud Tasks and deleting reminders.

Reminders batch will be modified to fetch Reminders' Payload. RAM usage is equivalent to O(total Payload size of each Reminder in batch).

Logs errors inside. Returns the total number of successfully processed reminders.

func SubmitFromReminder

func SubmitFromReminder(ctx context.Context, s Submitter, db db.DB, r *reminder.Reminder, req *taskspb.CreateTaskRequest, msg proto.Message, extra *tqpb.Extra, t TxnPath) error

SubmitFromReminder submits the request and deletes the reminder on success or a fatal error.

If `req` and/or `extra` are nil, they will be deserialized from the reminder.

Mutates `req` by adding tracing headers to it.

type Submitter

type Submitter interface {
	// CreateTask creates a task, returning a gRPC status.
	CreateTask(ctx context.Context, req *taskspb.CreateTaskRequest, msg proto.Message) error
}

Submitter is used by the dispatcher and the sweeper to submit Cloud Tasks.

type TxnPath

type TxnPath string

TxnPath indicates a code path a task can take.

const (
	TxnPathNone  TxnPath = "none"  // not a transactional task
	TxnPathHappy TxnPath = "happy" // the reminder was processed right after txn landed
	TxnPathSweep TxnPath = "sweep" // the reminder was processed during a sweep
)

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier