tasks

package
v0.0.0-...-4d0e586 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package tasks contains task class definitions for ResultDB.

Index

Constants

This section is empty.

Variables

View Source
var FinalizationTasks = tq.RegisterTaskClass(tq.TaskClass{
	ID:            "try-finalize-inv",
	Prototype:     &taskspb.TryFinalizeInvocation{},
	Kind:          tq.Transactional,
	Queue:         "finalizer",
	RoutingPrefix: "/internal/tasks/finalizer",
})

FinalizationTasks describes how to route finalization tasks.

The handler is implemented in internal/services/finalizer.

View Source
var NotifyFinalizedPublisher = tq.RegisterTaskClass(tq.TaskClass{
	ID:        "notify-finalized",
	Topic:     v1NotifyFinalizedTopic,
	Prototype: &taskspb.NotifyInvocationFinalized{},
	Kind:      tq.Transactional,
	Custom: func(ctx context.Context, m proto.Message) (*tq.CustomPayload, error) {

		t := m.(*taskspb.NotifyInvocationFinalized)
		notification := t.Message
		blob, err := (protojson.MarshalOptions{Indent: "\t"}).Marshal(notification)
		if err != nil {
			return nil, err
		}

		if err := realms.ValidateRealmName(notification.Realm, realms.GlobalScope); err != nil {
			return nil, err
		}
		project, _ := realms.Split(notification.Realm)
		attrs := map[string]string{
			"luci_project": project,
		}

		return &tq.CustomPayload{
			Meta: attrs,
			Body: blob,
		}, nil
	},
})

NotifyFinalizedPublisher describes how to publish to cloud pub/sub notifications that an invocation has been finalized.

Functions

func NotifyInvocationFinalized

func NotifyInvocationFinalized(ctx context.Context, message *pb.InvocationFinalizedNotification)

NotifyInvocationFinalized transactionally enqueues a task to publish that the given invocation has been finalized.

func StartInvocationFinalization

func StartInvocationFinalization(ctx context.Context, id invocations.ID, updateInv bool)

StartInvocationFinalization changes invocation state to FINALIZING if updateInv is set, and enqueues a TryFinalizeInvocation task.

The caller is responsible for ensuring that the invocation was previously active (except in case of new invocations being created in the FINALIZING state).

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.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL