blob: 3c5ed9e7178897e111ea4052dd1edfba34fbdc9d [file] [log] [blame]
package tracestore
import (
"context"
"time"
"go.skia.org/infra/golden/go/tiling"
"go.skia.org/infra/golden/go/types"
)
// Entry is one digests and related params to be added to the TraceStore.
type Entry struct {
// Params describe the configuration that produced the digest/image.
// These params will be used to form the trace id.
Params map[string]string
// Options give extra details about this trace. These options will be stored
// tile by tile, with the most recent commit's options overwriting any
// previous options. These details do not affect the trace id and are
// largely considered to be FYI.
Options map[string]string
// Digest references the image that was generated by the test.
// If two different Puts set a digest for a given commit + Params, the one
// with the later timestamp will be kept.
Digest types.Digest
}
// TraceStore is the interface to store trace data.
type TraceStore interface {
// Put writes the given entries to the TraceStore at the given commit hash. The timestamp is
// assumed to be the time when the entries were generated and will be used for the digests.
// It is undefined behavior to have multiple entries with the exact same Params.
Put(ctx context.Context, commitHash string, entries []*Entry, ts time.Time) error
// GetTile reads the last n commits and returns them as a tile.
// The second return value is all commits that are in the tile.
GetTile(ctx context.Context, nCommits int) (*tiling.Tile, []tiling.Commit, error)
// GetDenseTile constructs a tile containing only commits that have data for at least one trace.
// The returned tile will always have length exactly nCommits unless there are fewer than
// nCommits commits with data. The second return value contains all commits starting with the
// first commit of the tile and ending with the most recent commit, in order; i.e. it includes
// all commits in the tile as well as the omitted commits.
GetDenseTile(ctx context.Context, nCommits int) (*tiling.Tile, []tiling.Commit, error)
}