Documentation
¶
Overview ¶
Package web serves a factorymeter/v1 report as a local page. It reads what a Source hands it and nothing else: it holds no token, calls no host, and answers only requests that name this machine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadQuery = errors.New("bad query")
ErrBadQuery is the error a Source wraps for a number or week that is not there.
var ErrNoData = errors.New("nothing to report")
ErrNoData is the error a Source wraps when it holds nothing to report.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// Hosts are names, besides localhost and the loopback addresses, that a
// request may carry in its Host header.
Hosts []string
}
Options sets who the server answers.
type Query ¶
type Query struct {
// Weeks is the length of the window.
Weeks int
// Until ends the window. Zero means the last sync.
Until time.Time
// From, when set, starts the window on that day; the window then runs
// over whole weeks back from its end, and Weeks is not read.
From time.Time
// Repos narrows an owner to some of its repositories. Empty means
// every one.
Repos []string
}
Query is what a request asks for.
type Source ¶
type Source interface {
// Report builds the report a query asks for.
Report(q Query) (*contract.Report, error)
// Repos lists the repositories a query may name. It is empty when the
// target is one repository, and when names must stay out of the page.
Repos() ([]string, error)
// Drill lists the items one number of the report counted, over the
// window, or over one week of its charts when week is 0 or more.
Drill(q Query, metric string, week int) (*view.DrillPage, error)
}
Source builds the reports the server shows.