Overview
package supervisor // import "github.com/rotari-dev/rotari/internal/supervisor"
Package supervisor performs the project work behind the background server's
requests for one base directory: starting synchronous and asynchronous runs,
and cancelling a synchronous run whose client disconnected. `cancel`, `suspend`,
and `resume` do not go through it; they call internal/jobcontrol from the
calling process.
It implements server.Operations. internal/server owns the transport, the request
protocol, and the server's lifetime; this package decides what each request
does, using internal/jobcontrol and internal/projectrun. Messages it returns are
plain text that the client colors; it must not parse flags or depend on terminal
output.
Types
type Operations struct {
BaseDir string
// Project is the only project this supervisor runs; empty accepts any,
// for tests that drive Operations directly.
Project string
Controller jobcontrol.Controller
Runner projectrun.Runner
// NewRunID returns a fresh run ID.
NewRunID func() string
// Logf receives events, such as an async run that failed, that have no
// client to report them to. Nil drops them.
Logf func(format string, args ...any)
}
Operations performs the requests of the supervisor of Project in BaseDir.
func (ops Operations) Run(request server.Request, progress func(server.Response)) (string, int, error)
Run executes a run inside the supervisor, reporting progress to the attached
client, and returns once it has finished.
func (ops Operations) StartRun(request server.Request, onDone func()) (string, string, error)
StartRun starts an async run inside the supervisor and returns at once.
onDone, if not nil, is called once the run has finished.