Documentation
¶
Overview ¶
Package joblist lists recent job attempts across a base directory's projects: running jobs of active runs and jobs that finished within a time window.
`rotari jobs` and the Web UI's jobs page share it. Row status comes from internal/jobstatus; this package decides which attempts are listed and in what order, and how their times read. Column selection and table layout belong to the callers.
Index ¶
- Constants
- func FormatElapsed(value time.Duration) string
- func FormatLocalTimestamp(value time.Time) string
- func FormatRunTime(runTime jobstatus.RunTime) string
- func FormatTimestamp(value time.Time) string
- func ParseSince(value string) (time.Duration, error)
- func Projects(baseDir, requested string) ([]string, error)
- func ShortenText(value string, maxLength int) string
- func Sort(rows []Row)
- type Interval
- type Row
Constants ¶
const ( // DefaultSince is the listing window when none is given. DefaultSince = 24 * time.Hour // DefaultSinceText is DefaultSince as users write it. DefaultSinceText = "1d" )
Variables ¶
This section is empty.
Functions ¶
func FormatElapsed ¶
FormatElapsed formats a duration as "42s", "3m 05s", or "2h 07m", and a negative one as "-".
func FormatLocalTimestamp ¶
FormatLocalTimestamp is FormatTimestamp without the time zone.
func FormatRunTime ¶
FormatRunTime formats a job's elapsed time and, while it runs, how long ago it last wrote output: "12m 03s, quiet 11m 58s", or "12m 03s, no output" when it has written none.
func FormatTimestamp ¶
FormatTimestamp formats a listing time in time.Local with the zone name, matching the other web pages.
func ParseSince ¶
ParseSince parses a listing window: a Go duration such as "24h" or "90m", or a whole number of days such as "7d", which Go durations lack. Empty means DefaultSince.
func Projects ¶
Projects returns requested, or every project in baseDir sorted by name, or the default project when baseDir has none.
func ShortenText ¶
ShortenText cuts value to maxLength bytes, ending with "..." when maxLength leaves room for it.
Types ¶
type Interval ¶ added in v0.1.21
Interval is a span of finish times from Start up to, but not including, End. A zero End leaves the span open.
type Row ¶
type Row struct {
State string
BaseDir string
Project string
RunID string
JobID string
AttemptID string
JobName string
Command string
FullCommand string
StartedAt time.Time
FinishedAt time.Time
jobstatus.RunTime
}
Row is one job in the listing: an unfinished attempt of an active or interrupted run, a job of such a run that has not started (with no AttemptID), or a job that finished inside the window.
func Collect ¶
func Collect(store state.Store, baseDir string, projects []string, now time.Time, window time.Duration) ([]Row, error)
Collect lists unfinished attempts and jobs of projects in baseDir that finished within window before now. Each job's status follows the internal/jobstatus fallback chain.
func CollectFinishedIn ¶ added in v0.1.21
func CollectFinishedIn(store state.Store, baseDir string, projects []string, now time.Time, spans []Interval) ([]Row, error)
CollectFinishedIn is Collect for jobs that finished inside any of spans rather than one window before now. Unfinished jobs are listed regardless.