exportnotifier

package
v0.0.0-...-01cd1ea Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package exportnotifier is responsible for dispatching "invocation ready for export" notifications, used to trigger low-latency exports from ResultDB. Notifications are dispatched when all of the following criteria is met:

  • The invocation is included by an export root, AND
  • The invocation is locally immutable - signified by the invocation being in FINALIZING (or FINALIZED) state, AND
  • The sources the invocation are final. This could be because the sources were specified concretely and invocation is final (see above) or the invocation is inheriting sources, and those sources are available and final.

Index

Constants

View Source
const (
	// The number of export root rows to propagate to in one transaction.
	// This should balance Spanner mutation limits, efficiency of using
	// larger transactions and the risk of contention.
	BatchSizeInExportRootRows = 1000
)

Variables

View Source
var NotifyReadyForExportPublisher = tq.RegisterTaskClass(tq.TaskClass{
	ID:        "notify-ready-for-export",
	Topic:     v1NotifyReadyForExportTopic,
	Prototype: &taskspb.NotificationInvocationReadyForExport{},
	Kind:      tq.Transactional,
	Custom: func(ctx context.Context, m proto.Message) (*tq.CustomPayload, error) {

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

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

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

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

View Source
var RunExportNotificationsTasks = tq.RegisterTaskClass(tq.TaskClass{
	ID:            "propagate-export-roots",
	Prototype:     &taskspb.RunExportNotifications{},
	Kind:          tq.Transactional,
	Queue:         "exportnotifier",
	RoutingPrefix: "/internal/tasks/exportnotifier",
})

RunExportNotificationsTasks describes how to route run export notification tasks.

Functions

func EnqueueTask

func EnqueueTask(ctx context.Context, task *taskspb.RunExportNotifications)

EnqueueTask transactionally enqueues a RunExportNotifications task.

func InitServer

func InitServer(srv *server.Server, opts Options) error

InitServer initializes a exportnotifier server.

Types

type Options

type Options struct {
	// Hostname of the luci.resultdb.v1.ResultDB service which can be
	// queried to fetch the details of invocations being exported.
	// E.g. "results.api.cr.dev".
	ResultDBHostname string
}

Jump to

Keyboard shortcuts

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