Back to godoc.org

Package invocations

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 MaxNodes = 10000

MaxNodes is the maximum number of invocation nodes that ResultDB can operate on at a time.

const Shards = 100

Shards is the sharding level for the Invocations table. Column Invocations.ShardId is a value in range [0, Shards).

Variables

var ErrUnknownReach = fmt.Errorf("the reachable set is unknown")

ErrUnknownReach is returned by ReachCache.Read if the cached value is absent.

var TooManyTag = errors.BoolTag{
	Key: errors.NewTagKey("too many matching invocations matched the condition"),
}

TooManyTag set in an error indicates that too many invocations matched a condition.

func CurrentMaxShard

func CurrentMaxShard(ctx context.Context) (int, error)

CurrentMaxShard reads the highest shard id in the Invocations table. This may differ from the constant above when it has changed recently.

func InclusionKey

func InclusionKey(including, included ID) spanner.Key

InclusionKey returns a spanner key for an Inclusion row.

func IncrementTestResultCount

func IncrementTestResultCount(ctx context.Context, id ID, delta int64) error

IncrementTestResultCount increases the TestResultCount of the invocation.

func Read

func Read(ctx context.Context, id ID) (*pb.Invocation, error)

Read reads one invocation from Spanner. If the invocation does not exist, the returned error is annotated with NotFound GRPC code.

func ReadBatch

func ReadBatch(ctx context.Context, ids IDSet) (map[ID]*pb.Invocation, error)

ReadBatch reads multiple invocations from Spanner. If any of them are not found, returns an error.

func ReadColumns

func ReadColumns(ctx context.Context, id ID, ptrMap map[string]interface{}) error

ReadColumns reads the specified columns from an invocation Spanner row. If the invocation does not exist, the returned error is annotated with NotFound GRPC code. For ptrMap see ReadRow comment in span/util.go.

func ReadRealm

func ReadRealm(ctx context.Context, id ID) (string, error)

ReadRealm returns the invocation's realm.

func ReadRealms

func ReadRealms(ctx context.Context, ids IDSet) (realms map[ID]string, err error)

ReadRealms returns the invocations' realms. Makes a single RPC.

func ReadState

func ReadState(ctx context.Context, id ID) (pb.Invocation_State, error)

ReadState returns the invocation's state.

func ReadStateBatch

func ReadStateBatch(ctx context.Context, ids IDSet) (map[ID]pb.Invocation_State, error)

ReadStateBatch reads the states of multiple invocations.

func ReadTestResultCount

func ReadTestResultCount(ctx context.Context, ids IDSet) (int64, error)

ReadTestResultCount returns the total number of test results of requested invocations.

func ShardStatement

func ShardStatement(st spanner.Statement, invIDsParamName string) []spanner.Statement

ShardStatement splits the statement into multiple shards by invocation parameter. For example, if a query retrieves test results from a set of invocations, then ShardQuery splits the set of invocations into subsets, and returns a statement for each of them. The returned statements are ordered by invocation row id.

Users of this function must be careful with LIMIT and ORDER BY operator, because each statement would have its own LIMIT and order.

st must have a parameter with the name invIDsParamName, and it must have a type IDSet.

TODO(crbug.com/1113071): remove this function.

func TokenToMap

func TokenToMap(token string, dest map[string]interface{}, keys ...string) error

TokenToMap parses a page token to a map. The first component of the token is expected to be an invocation ID. Convenient to initialize Spanner statement parameters. Expects the token to be either empty or have len(keys) components. If the token is empty, sets map values to "".

type ID

type ID string

ID can convert an invocation id to various formats.

func IDFromRowID

func IDFromRowID(rowID string) ID

IDFromRowID converts a Spanner-level row ID to an ID.

func MustParseName

func MustParseName(name string) ID

MustParseName converts an invocation name to an ID. Panics if the name is invalid. Useful for situations when name was already validated.

func (*ID) FromSpanner

func (id *ID) FromSpanner(b *spanutil.Buffer) error

FromSpanner implements span.Ptr.

func (ID) Key

func (id ID) Key(suffix ...interface{}) spanner.Key

Key returns a invocation spanner key.

func (ID) Name

func (id ID) Name() string

Name returns an invocation name.

func (ID) RowID

func (id ID) RowID() string

RowID returns an invocation ID used in spanner rows. If id is empty, returns "".

func (*ID) SpannerPtr

func (id *ID) SpannerPtr(b *spanutil.Buffer) interface{}

SpannerPtr implements span.Ptr.

func (ID) ToSpanner

func (id ID) ToSpanner() interface{}

ToSpanner implements span.Value.

type IDSet

type IDSet map[ID]struct{}

IDSet is an unordered set of invocation ids.

func MustParseNames

func MustParseNames(names []string) IDSet

MustParseNames converts invocation names to IDSet. Panics if a name is invalid. Useful for situations when names were already validated.

func NewIDSet

func NewIDSet(ids ...ID) IDSet

NewIDSet creates an IDSet from members.

func ParseNames

func ParseNames(names []string) (IDSet, error)

ParseNames converts invocation names to IDSet.

func Reachable

func Reachable(ctx context.Context, roots IDSet) (IDSet, error)

Reachable returns all invocations reachable from roots along the inclusion edges. May return an appstatus-annotated error.

func ReachableSkipRootCache

func ReachableSkipRootCache(ctx context.Context, roots IDSet) (IDSet, error)

ReachableSkipRootCache is similar to Reachable, but it ignores cache for the roots.

Useful to keep cache-hit stats high in cases where the roots are known not to have cache.

func ReadIncluded

func ReadIncluded(ctx context.Context, id ID) (IDSet, error)

ReadIncluded reads ids of included invocations.

func (IDSet) Add

func (s IDSet) Add(id ID)

Add adds id to the set.

func (IDSet) Batches

func (s IDSet) Batches() []IDSet

Batches splits s into batches. The batches are sorted by RowID(), such that interval (minRowID, maxRowID) of each batch does not overlap with any other batch.

The size of batch is hardcoded 50, because that's the maximum parallelism we get from Cloud Spanner.

func (*IDSet) FromSpanner

func (s *IDSet) FromSpanner(b *spanutil.Buffer) error

FromSpanner implements span.Ptr.

func (IDSet) Has

func (s IDSet) Has(id ID) bool

Has returns true if id is in the set.

func (IDSet) Keys

func (s IDSet) Keys(suffix ...interface{}) spanner.KeySet

Keys returns a spanner.KeySet.

func (IDSet) Names

func (s IDSet) Names() []string

Names returns a sorted slice of invocation names.

func (IDSet) Remove

func (s IDSet) Remove(id ID)

Remove removes id from the set if it was present.

func (IDSet) SortByRowID

func (s IDSet) SortByRowID() []ID

SortByRowID returns IDs in the set sorted by row id.

func (*IDSet) SpannerPtr

func (s *IDSet) SpannerPtr(b *spanutil.Buffer) interface{}

SpannerPtr implements span.Ptr.

func (IDSet) String

func (s IDSet) String() string

String implements fmt.Stringer.

func (IDSet) ToSpanner

func (s IDSet) ToSpanner() interface{}

ToSpanner implements span.Value.

func (IDSet) Union

func (s IDSet) Union(other IDSet)

Union adds other ids.

type ReachCache

type ReachCache ID

ReachCache is a cache of all invocations reachable from the given invocation, stored in Redis. The cached set is either correct or absent.

The cache must be written only after the set of reachable invocations becomes immutable, i.e. when the including invocation is finalized. This is important to be able to tolerate transient Redis failures and avoid a situation where we failed to update the currently stored set, ignored the failure and then, after Redis came back online, read the stale set.

func (ReachCache) Read

func (c ReachCache) Read(ctx context.Context) (ids IDSet, err error)

Read reads the current value. Returns ErrUnknownReach if the value is absent.

If err is nil, ids includes c, even if it was not passed in Write().

func (ReachCache) TryWrite

func (c ReachCache) TryWrite(ctx context.Context, value IDSet)

TryWrite tries to write the new value. On failure, logs it.

func (ReachCache) Write

func (c ReachCache) Write(ctx context.Context, value IDSet) (err error)

Write writes the new value. The value does not have to include c, this is implied.

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