Skip to content

search: condense global Zoekt search args

Administrator requested to merge backend-dry-run/rvt/zoekt-job-5 into main

Created by: rvantonder

Stacked on https://github.com/sourcegraph/sourcegraph/pull/25420. Semantics-preserving.

The call doZoektSearchGlobal(ctx, s.Args.Query, s.Args.Typ, s.Args.Zoekt, s.Args.FileMatchLimit, s.Args.Select, c) now becomes simply doZoektSearchGlobal(ctx, s.Args, c).

This is significant: the journey started with the above but where args depended on all of TextParameters, and the especially annoying PatternInfo, and you didn't know what mattered. You didn't know what you needed to run a Zoekt search. The function just picked stuff out of the huge args struct to get what it needed.

Now, after all the other lifting/state separation, it's reduced to just ZoektParameters:

type ZoektParameters struct {
	Query          zoektquery.Q
	Typ            IndexedRequestType
	FileMatchLimit int32
	Select         filter.SelectPath

	Zoekt zoekt.Streamer
}

This is the true "static" values that the Zoekt backend needs to compute run time values (from the Sourcegraph app perspective).

There are even ways to make this better (We shouldn't actually need Typ to be separate, FileMatch is actually used to compute another static value, which we should do earlier. Also don't need to propagate Select really. All these exist because of how our business logic works, and can be improved. But it's much, much simpler than before and gives easier ways to simplify more.)


A similar thing will happen for non-global Zoekt searches, and then it's easy/obvious how to pass down modified (i.e., optimized) Zoekt queries.

Merge request reports

Loading