Skip to content

search: break searchResolver dependency in doResults

Administrator requested to merge rvt/do-results-simple into main

Created by: rvantonder

Stacked on https://github.com/sourcegraph/sourcegraph/pull/30376.

As in description. This unlocks a major simplification: after this change the signature of doResults is:

doResults(ctx context.Context, searchInputs *run.SearchInputs, db database.DB, stream streaming.Sender, job run.Job) (res *SearchResults, err error)

You'll see this almost satisfies the job Run interface! Which is exactly what I'd like next: to turn this into a job. Conceptually, it would be:

type Job struct {
  SearchInputs
}
func (Job) Run(ctx, db, stream) error {
...
}

Amazing! Just one snag: the return type to satisfy is error. This "job" generates the exact SearchResults we need to do further processing, and we need to extract these SearchResults especially because of alert messages that get sent out over the stream.

Open Question:

  • What do you think the best way is to get this value out of a job? My first idea: can we just use a channel sent into the Job struct? Or: I think we can even change the interface to be (SearchResults, error) for all jobs since this will be our terminal/"leaf" job? @camdencheek halp!

Once we have this represented as a job, and we can extract SearchResults, we don't just represent jobs as a tree, as a thing that we pass to doResults. Instead, we would be able to create the tree, and then just Run from the root node directly! The only thing it seems we need to figure out is extracting / propagating SearchResults out of a job.

  • Minor: What do we call this kind of job? It's the one that aggregates stream results and also produces alert info.

Merge request reports

Loading