Documentation ¶
Overview ¶
Package runquery contains logic to query runs.
Index ¶
- Variables
- type CLQueryBuilder
- func (b CLQueryBuilder) AfterInProject(id common.RunID) CLQueryBuilder
- func (b CLQueryBuilder) BeforeInProject(id common.RunID) CLQueryBuilder
- func (b CLQueryBuilder) BuildKeysOnly(ctx context.Context) *datastore.Query
- func (b CLQueryBuilder) GetAllRunKeys(ctx context.Context) ([]*datastore.Key, error)
- func (b CLQueryBuilder) LoadRuns(ctx context.Context, checkers ...run.LoadRunChecker) ([]*run.Run, *PageToken, error)
- func (b CLQueryBuilder) PageToken(pt *PageToken) CLQueryBuilder
- type PageToken
- type ProjectQueryBuilder
- func (b ProjectQueryBuilder) After(id common.RunID) ProjectQueryBuilder
- func (b ProjectQueryBuilder) Before(id common.RunID) ProjectQueryBuilder
- func (b ProjectQueryBuilder) BuildKeysOnly(ctx context.Context) *datastore.Query
- func (b ProjectQueryBuilder) GetAllRunKeys(ctx context.Context) ([]*datastore.Key, error)
- func (b ProjectQueryBuilder) LoadRuns(ctx context.Context, checkers ...run.LoadRunChecker) ([]*run.Run, *PageToken, error)
- func (b ProjectQueryBuilder) PageToken(pt *PageToken) ProjectQueryBuilder
- type RecentQueryBuilder
Constants ¶
This section is empty.
Variables ¶
var File_go_chromium_org_luci_cv_internal_run_runquery_pagetoken_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type CLQueryBuilder ¶
type CLQueryBuilder struct { // CLID of the CL being searched for. Required. CLID common.CLID // Optional extra CLs that must be included. AdditionalCLIDs common.CLIDsSet // Project optionally restricts Runs to the given LUCI project. Project string // MaxExcl restricts query to Runs with ID lexicographically smaller. // // This means query will return union of: // * all Runs created after this Run in the same project, // * all Runs in lexicographically smaller projects, // unless .Project is set to the same project (recommended). MaxExcl common.RunID // MinExcl restricts query to Runs with ID lexicographically larger. // // This means query will return union of: // * all Runs created before this Run in the same project, // * all Runs in lexicographically larger projects, // unless .Project is set to the same project (recommended). MinExcl common.RunID // Limit limits the number of results if positive. Ignored otherwise. Limit int32 }
CLQueryBuilder builds datastore.Query for searching Runs of a given CL.
func (CLQueryBuilder) AfterInProject ¶
func (b CLQueryBuilder) AfterInProject(id common.RunID) CLQueryBuilder
AfterInProject constrains CLQueryBuilder to Runs created after this Run but belonging to the same LUCI project.
Panics if CLQueryBuilder is already constrained to a different LUCI Project.
func (CLQueryBuilder) BeforeInProject ¶
func (b CLQueryBuilder) BeforeInProject(id common.RunID) CLQueryBuilder
BeforeInProject constrains CLQueryBuilder to Runs created before this Run but belonging to the same LUCI project.
Panics if CLQueryBuilder is already constrained to a different LUCI Project.
func (CLQueryBuilder) BuildKeysOnly ¶
func (b CLQueryBuilder) BuildKeysOnly(ctx context.Context) *datastore.Query
BuildKeysOnly returns keys-only query on RunCL entities.
It's exposed primarily for debugging reasons.
func (CLQueryBuilder) GetAllRunKeys ¶
GetAllRunKeys runs the query across all matched RunCLs entities and returns Datastore keys to corresponding Run entities.
func (CLQueryBuilder) LoadRuns ¶
func (b CLQueryBuilder) LoadRuns(ctx context.Context, checkers ...run.LoadRunChecker) ([]*run.Run, *PageToken, error)
LoadRuns returns matched Runs and the page token to continue search later.
func (CLQueryBuilder) PageToken ¶
func (b CLQueryBuilder) PageToken(pt *PageToken) CLQueryBuilder
PageToken constraints CLQueryBuilder to continue searching from the prior search.
type PageToken ¶
type PageToken struct { // CV RunID. May not actually exist. Run string `protobuf:"bytes,1,opt,name=run,proto3" json:"run,omitempty"` // contains filtered or unexported fields }
PageToken is a serializable page token for listing or searching Runs.
func (*PageToken) Descriptor
deprecated
func (*PageToken) ProtoMessage ¶
func (*PageToken) ProtoMessage()
func (*PageToken) ProtoReflect ¶
func (x *PageToken) ProtoReflect() protoreflect.Message
type ProjectQueryBuilder ¶
type ProjectQueryBuilder struct { // Project is the LUCI project. Required. Project string // Status optionally restricts query to Runs with this status. Status run.Status // MaxExcl restricts query to Runs with ID lexicographically smaller. Optional. // // This means query is restricted to Runs created after this Run. // // This Run must belong to the same LUCI project. MaxExcl common.RunID // MinExcl restricts query to Runs with ID lexicographically larger. Optional. // // This means query is restricted to Runs created before this Run. // // This Run must belong to the same LUCI project. MinExcl common.RunID // Limit limits the number of results if positive. Ignored otherwise. Limit int32 }
ProjectQueryBuilder builds datastore.Query for searching Runs scoped to a LUCI project.
func (ProjectQueryBuilder) After ¶
func (b ProjectQueryBuilder) After(id common.RunID) ProjectQueryBuilder
After restricts the query to Runs created after the given Run.
Panics if ProjectQueryBuilder is already constrained to a different Project.
func (ProjectQueryBuilder) Before ¶
func (b ProjectQueryBuilder) Before(id common.RunID) ProjectQueryBuilder
Before restricts the query to Runs created before the given Run.
Panics if ProjectQueryBuilder is already constrained to a different Project.
func (ProjectQueryBuilder) BuildKeysOnly ¶
func (b ProjectQueryBuilder) BuildKeysOnly(ctx context.Context) *datastore.Query
BuildKeysOnly returns keys-only query on Run entities.
It's exposed primarily for debugging reasons.
WARNING: panics if Status is magic Status_ENDED_MASK, as it's not feasible to perform this as 1 query.
func (ProjectQueryBuilder) GetAllRunKeys ¶
GetAllRunKeys runs the query and returns Datastore keys to Run entities.
func (ProjectQueryBuilder) LoadRuns ¶
func (b ProjectQueryBuilder) LoadRuns(ctx context.Context, checkers ...run.LoadRunChecker) ([]*run.Run, *PageToken, error)
LoadRuns returns matched Runs and the page token to continue search later.
func (ProjectQueryBuilder) PageToken ¶
func (b ProjectQueryBuilder) PageToken(pt *PageToken) ProjectQueryBuilder
PageToken constraints ProjectQueryBuilder to continue searching from the prior search.
type RecentQueryBuilder ¶
type RecentQueryBuilder struct { // Status optionally restricts query to Runs with this status. Status run.Status // Limit limits the number of results if positive. Ignored otherwise. Limit int32 // CheckProjectAccess checks if the calling user has access to the LUCI // project. Optional. // // If provided, Runs from the LUCI Projects that requested user doesn't have // access to won't be returned without even querying. // If not provided, search is done across all projects. CheckProjectAccess func(context.Context, string) (bool, error) // contains filtered or unexported fields }
RecentQueryBuilder builds a VERY SLOW query for searching recent Runs across all LUCI projects.
If two runs have the same timestamp, orders Runs first by the LUCI Project name and then by the remainder of the Run's ID.
Beware: two Runs having the same timestamp is actually quite likely with Google Gerrit because it rounds updates to second granularity, which then makes its way as Run Creation time.
**WARNING**: this is the most inefficient way to be used infrequently for CV admin needs only. Behind the scenes, it issues a Datastore query per active LUCI project.
Doesn't yet support restricting search to a specific time range, but it can be easily implemented if necessary.
func (RecentQueryBuilder) GetAllRunKeys ¶
GetAllRunKeys runs the query and returns Datastore keys to Run entities.
WARNING: very slow.
Since RunID includes LUCI project, RunIDs aren't lexicographically ordered by creation time across LUCI projects. So, the brute force is to query each known to CV LUCI project for most recent Run IDs, and then merge and select the next page of resulting keys.
func (RecentQueryBuilder) LoadRuns ¶
func (b RecentQueryBuilder) LoadRuns(ctx context.Context, checkers ...run.LoadRunChecker) ([]*run.Run, *PageToken, error)
LoadRuns returns matched Runs and the page token to continue search later.
func (RecentQueryBuilder) PageToken ¶
func (b RecentQueryBuilder) PageToken(pt *PageToken) RecentQueryBuilder
PageToken constraints RecentQueryBuilder to continue searching from the prior search.