search: add Required method to jobs
Created by: rvantonder
Stacked on https://github.com/sourcegraph/sourcegraph/pull/29168. This is in support of removing args
from doResults
. We currently depend on args.resultTypes
, which we further use to decide whether a job is required or optional in. This PR adds scaffolding for jobs to say whether they are required or optional instead, so we don't need resultTypes
. Note that an interface is needed (to check Required()
in doResults
, but this value is not static per job: a job is not always either required or optional on its own, but depends on whether other jobs exist (e.g., if a symbol search is exclusively run, it is required, but it might otherwise be included as part of other jobs, but optionally). Ergo, this decision must be made in toSearchInputs
and sets the value appropriately.
Camden and I talked a while back about whether we really need to make this distinction between optional and required, now that we have streaming. Historically, I think this distinction mattered more for GQL, but even then it's dubious. The fact is, I think we don't (just keep streaming until we see enough results and then cancel), but I'm going to pretend we need to keep it for now and just mechanically migrate this logic to toSearchInputs
, because my goal is to get rid of args
, not substantially rewrite this logic. Hopefully later we can remove the Required()
method on jobs entirely.