Documentation
¶
Overview ¶
Package server serves Blitz's API (proto/blitz/v1) over Connect: one process holding every workspace a user opens, each an engine.Workspace. Handlers translate between the protos and the engine; they hold no logic of their own.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Opener ¶
Opener opens the workspace in dir, an absolute directory. The server calls it once per workspace; each call must build its own configuration, since a workspace owns and changes it.
type Option ¶
type Option func(*Server)
Option configures a Server.
func WithConfigDir ¶
WithConfigDir is the settings directory the service loads from ("" for the usual one, ~/.blitz), as the --config flag.
func WithLogDir ¶
WithLogDir is the directory of the service's diagnostic log, which ListLogDays and ReadLog read ("": none).
func WithScheduler ¶
func WithScheduler(c SchedulerConfig) Option
WithScheduler makes the server run enabled workers on their schedules (StartScheduler) and serve WorkerService.
func WithShutdown ¶ added in v0.4.0
func WithShutdown(stop func()) Option
WithShutdown is what Shutdown calls to stop the service; without it the service can't be stopped that way.
func WithVersion ¶
WithVersion is the version GetServiceInfo reports ("dev" otherwise).
type SchedulerConfig ¶
type SchedulerConfig struct {
// Store says which workers are enabled; the Opener must give each
// workspace the same one (engine.Options.Workers).
Store *workers.Store
// Runs is where workspaces record finished runs (the same directory
// engine.Workspace uses), for looking runs up by ID.
Runs *workers.RunLog
// MaxConcurrent is how many runs may go at once (at least 1).
MaxConcurrent int
// Rescan is how often workers are rescanned, to pick up new, edited
// and removed WORKER.md files (0: a minute).
Rescan time.Duration
}
SchedulerConfig configures the service's worker scheduler.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds the open workspaces and serves the API.
func (*Server) IdleFor ¶ added in v0.3.1
IdleFor is how long the service has had nothing to do: no request in flight, no turn running in any workspace and no background run going; 0 while it has.
func (*Server) StartScheduler ¶
StartScheduler runs workers on their schedules until ctx is done, which also stops the runs going then (as Close does). It does nothing without WithScheduler.