exportroots

package
v0.0.0-...-ecc8568 Latest Latest
Warning

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

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

Documentation

Overview

Package exportroots contains methods for reading and writing export root records in Spanner. Export roots are stored for each invocation and are used to facilitate low-latency exports of invocations inside each root.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(root ExportRoot) *spanner.Mutation

Create returns a mutation to create the given ExportRoot row. The specified NotifiedTime is ignored and set to the commit timestamp if IsNotified is set.

func ReadForInvocations

func ReadForInvocations(ctx context.Context, invocationIDs invocations.IDSet, rootInvocationIDs invocations.IDSet) (map[invocations.ID]map[invocations.ID]ExportRoot, error)

ReadForInvocations reads given export roots for the given invocations, limited to the export roots in the given root invocation IDs. Results are grouped by invocation ID and then root invocation ID.

func SetForTesting

func SetForTesting(ctx context.Context, exportRoots []ExportRoot) error

SetForTesting replaces the set of stored export roots to match the given set.

func SetInheritedSources

func SetInheritedSources(root ExportRoot) *spanner.Mutation

SetInheritedSources creates a mutation to set the given export root's inherited sources.

Before calling this method, the caller *must* confirm that the export root's inherited sources are not already set, in the same Read/Write transaction as this update.

func SetNotified

func SetNotified(root ExportRoot) *spanner.Mutation

SetNotified creates a mutation to set the given export root as notified.

Before calling this method, the caller *must* confirm that the export root was NOT already notified, in the same Read/Write transaction as this update.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(uniqifier int) *Builder

NewBuilder starts building a new export root.

func (*Builder) Build

func (b *Builder) Build() ExportRoot

Build builds the export root.

func (*Builder) WithInheritedSources

func (b *Builder) WithInheritedSources(inheritedSources *pb.Sources) *Builder

WithInheritedSources sets the inherited sources.

func (*Builder) WithInvocation

func (b *Builder) WithInvocation(invocation invocations.ID) *Builder

WithInvocation sets the invocation ID.

func (*Builder) WithNotified

func (b *Builder) WithNotified(notifiedTime time.Time) *Builder

WithNotified sets that the export root was notified to pub/sub at the given time.

func (*Builder) WithRootInvocation

func (b *Builder) WithRootInvocation(rootInvocation invocations.ID) *Builder

WithRootInvocation sets the root invocation ID.

func (*Builder) WithoutInheritedSources

func (b *Builder) WithoutInheritedSources() *Builder

WithoutInheritedSources clears the inherited sources.

func (*Builder) WithoutNotified

func (b *Builder) WithoutNotified() *Builder

WithoutNotified clears the notified flag and time.

type ExportRoot

type ExportRoot struct {
	// The identity of the invocation.
	Invocation invocations.ID
	// The identity of the invocation that is the export root.
	RootInvocation invocations.ID
	// Whether inherited sources for this invocation have been resolved.
	// The value is then stored in InheritedSources.
	IsInheritedSourcesSet bool
	// The sources this invocation is eligible to inherit for its inclusion
	// (directly or indirectly) from RootInvocationId.
	// This may to a concrete luci.resultdb.v1.Sources value (if concrete
	// sources are eligible to be inherited) or to a nil value (if empty
	// sources are eligible to be inherited).
	// To be able to distinguish inheriting empty/nil sources and the inherited
	// sources not being resolved yet, see HasInheritedSourcesResolved.
	InheritedSources *pb.Sources
	// Whether an `invocation-ready-for-export` pub/sub notification was
	// sent for this row.
	IsNotified bool
	// The timestamp a `invocation-ready-for-export` pub/sub notification was
	// sent for this row. Used for debugging and to avoid triggering
	// pub/sub notifications that were already sent.
	NotifiedTime time.Time
}

func ReadAllForTesting

func ReadAllForTesting(ctx context.Context) ([]ExportRoot, error)

ReadAllForTesting reads all export roots. Useful for unit testing. Do not use in production, will not scale.

func ReadForInvocation

func ReadForInvocation(ctx context.Context, invocationID invocations.ID, rootRestriction RootRestriction) ([]ExportRoot, error)

ReadForInvocation reads export roots for the given invocation. rootRestriction restricts which export roots are returned.

type RootRestriction

type RootRestriction struct {
	// Whether to restrict the root invocations returned.
	UseRestriction bool
	// The root invocations to return. Used if UseRestriction is set.
	InvocationIDs invocations.IDSet
}

Jump to

Keyboard shortcuts

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