web

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
var ErrBadQuery = errors.New("bad query")

ErrBadQuery is the error a Source wraps for a number or week that is not there.

View Source
var ErrNoData = errors.New("nothing to report")

ErrNoData is the error a Source wraps when it holds nothing to report.

Functions

func Handler

func Handler(src Source, opt Options) http.Handler

Handler serves the page at / and the same report as JSON at /report.json.

func Link(path string, q Query) string

Link is the address of the page for a query, for a Source that writes links back to the line.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL