luci: go.chromium.org/luci/resultdb/internal/invocations Index | Files

package invocations

import "go.chromium.org/luci/resultdb/internal/invocations"

Index

Package Files

graph.go history.go id.go misc.go read.go

Constants

const (

    // HistoryWindow specifies how far back to query results history by
    // default.
    HistoryWindow = 2 * year

    // ClockDriftBuffer how much time to add to the current time when
    // using it as a default upper bound for the query window.
    ClockDriftBuffer = 5 * time.Minute
)
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 ByTimestamp Uses

func ByTimestamp(ctx context.Context, realm string, timeRange *pb.TimeRange, callback func(inv ID, ts *timestamp.Timestamp) error) error

ByTimestamp queries indexed invocations in a given time range. It executes the callback once for each row, starting with the most recent.

func CurrentMaxShard Uses

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 Uses

func InclusionKey(including, included ID) spanner.Key

InclusionKey returns a spanner key for an Inclusion row.

func Read Uses

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 Uses

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 Uses

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 Uses

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

ReadRealm returns the invocation's realm.

func ReadRealms Uses

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

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

func ReadState Uses

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

ReadState returns the invocation's state.

func ReadStateBatch Uses

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

ReadStateBatch reads the states of multiple invocations.

func ReadTestResultCount Uses

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

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

func ShardStatement Uses

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 Uses

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 Uses

type ID string

ID can convert an invocation id to various formats.

func IDFromRowID Uses

func IDFromRowID(rowID string) ID

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

func MustParseName Uses

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 Uses

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

FromSpanner implements span.Ptr.

func (ID) Key Uses

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

Key returns a invocation spanner key.

func (ID) Name Uses

func (id ID) Name() string

Name returns an invocation name.

func (ID) RowID Uses

func (id ID) RowID() string

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

func (*ID) SpannerPtr Uses

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

SpannerPtr implements span.Ptr.

func (ID) ToSpanner Uses

func (id ID) ToSpanner() interface{}

ToSpanner implements span.Value.

type IDSet Uses

type IDSet map[ID]struct{}

IDSet is an unordered set of invocation ids.

func MustParseNames Uses

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 Uses

func NewIDSet(ids ...ID) IDSet

NewIDSet creates an IDSet from members.

func ParseNames Uses

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

ParseNames converts invocation names to IDSet.

func Reachable Uses

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 Uses

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 Uses

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

ReadIncluded reads ids of included invocations.

func (IDSet) Add Uses

func (s IDSet) Add(id ID)

Add adds id to the set.

func (IDSet) Batches Uses

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 Uses

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

FromSpanner implements span.Ptr.

func (IDSet) Has Uses

func (s IDSet) Has(id ID) bool

Has returns true if id is in the set.

func (IDSet) Keys Uses

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

Keys returns a spanner.KeySet.

func (IDSet) Names Uses

func (s IDSet) Names() []string

Names returns a sorted slice of invocation names.

func (IDSet) Remove Uses

func (s IDSet) Remove(id ID)

Remove removes id from the set if it was present.

func (IDSet) SortByRowID Uses

func (s IDSet) SortByRowID() []ID

SortByRowID returns IDs in the set sorted by row id.

func (*IDSet) SpannerPtr Uses

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

SpannerPtr implements span.Ptr.

func (IDSet) String Uses

func (s IDSet) String() string

String implements fmt.Stringer.

func (IDSet) ToSpanner Uses

func (s IDSet) ToSpanner() interface{}

ToSpanner implements span.Value.

func (IDSet) Union Uses

func (s IDSet) Union(other IDSet)

Union adds other ids.

type ReachCache Uses

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 Uses

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 Uses

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

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

func (ReachCache) Write Uses

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 invocations imports 28 packages (graph) and is imported by 19 packages. Updated 2020-10-28. Refresh now. Tools for package owners.