Skip to content

Search backend: unify job self-descriptions

Administrator requested to merge backend-integration/cc/pull-pretty into main

Created by: camdencheek

This PR unifies the concept of a self-describing job around the Describer interface.

type Describer interface {
	Name() string
	Children() []Describer
	Fields(Verbosity) []otlog.Field
}

Name and Fields (formerly Tags) both already existed, but Children() is new.

With these three methods, we can implement all the pretty printers we currently use (JSON, Sexp, Mermaid) without them needing to unwrap the interface. This means we can move the pretty-printing code out of the catch-all job package that necessarily lists every possible job. This is a big deal because, with the current setup, any dependency on the pretty printers means a dependency on every package that defines a job, which is a big pain because of circular dependencies.

Additionally, since this unifies how we expose information about jobs, we can get richer information in S-expressions and mermaid diagrams than we previously could.

Screen Shot 2022-07-06 at 20 05 24

Sorry for the massive PR. I figured since this is shouldn't change any user-facing behavior, it's probably best to just get it out of the way rather than split it up.

Test plan

This is a low-risk change since it only affects pretty printers, which are only used for tests/debugging. The format of the output for each of the pretty printers changed slightly since we have different information than we used to, but I've checked that the changes to the output are expected and are easily readable.

Merge request reports

Loading