api

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package api defines the wire contract between the edge and the central.

Index

Constants

View Source
const (
	PathHealth      = "/healthz"
	PathAssignments = "/v1/assignments"
	PathResults     = "/v1/results"
)

Paths of the edge API, served by the central.

View Source
const (
	KindTCP      = "tcp"        // a connection opens
	KindHTTP     = "http"       // an HTTP request answers as expected
	KindDNS      = "dns"        // a name resolves
	KindTLS      = "tls"        // a certificate is valid, and for long enough
	KindICMP     = "icmp"       // ICMP echo (ping), and how many are lost
	KindNTP      = "ntp"        // a time server answers, and the clock is right
	KindBanner   = "banner"     // a service greets as expected: SSH, SMTP, FTP, ...
	KindClosed   = "closed"     // a port that must not be reachable is not
	KindDownload = "download"   // a file comes down fast enough
	KindRoute    = "traceroute" // the path to a host, and where it ends
	KindDomain   = "domain"     // a domain name that is not about to expire
)

Kinds of check.

View Source
const (
	MaxResultsPerBatch = 1000
	MaxErrorLength     = 512
	MaxTargetLength    = 512
	MaxExpectLength    = 256
	MaxCheckEdges      = 64

	// MaxResultAge and MaxResultSkew bound the time of a result: an old one is
	// a stale queue or a bad clock, a future one a bad clock, and either would
	// make the database open a chunk for a time nobody asked about.
	MaxResultAge  = 7 * 24 * time.Hour
	MaxResultSkew = 5 * time.Minute
)

Limits shared by both sides.

Variables

Kinds lists every kind of check.

Functions

This section is empty.

Types

type Assignments

type Assignments struct {
	Checks []Check `json:"checks"`
}

Assignments is what the central answers to an edge poll.

type Check

type Check struct {
	ID     string `json:"id"`
	Kind   string `json:"kind"`
	Target string `json:"target"`
	// Expect refines what a good answer is; each kind says how.
	Expect          string `json:"expect,omitempty"`
	IntervalSeconds int    `json:"interval_seconds"`
	// Edges names the edges that run the check; empty means every edge.
	Edges []string `json:"edges,omitempty"`
}

Check is one measurement an edge runs on a schedule.

func (Check) AppliesTo added in v1.2.0

func (c Check) AppliesTo(edge string) bool

AppliesTo reports whether the edge of that name runs the check.

func (Check) Equal added in v1.2.0

func (c Check) Equal(o Check) bool

Equal reports whether two checks ask for the same measurement.

func (Check) Validate

func (c Check) Validate() error

Validate reports why a check cannot be created. It is stricter than ValidateShape, which also reads the checks of older centrals.

func (Check) ValidateShape

func (c Check) ValidateShape() error

ValidateShape is Validate for a check of a kind that may be newer than the reader: an edge keeps such a check, and reports it as unsupported, rather than refusing the whole list.

type Result

type Result struct {
	CheckID   string    `json:"check_id"`
	At        time.Time `json:"at"`
	OK        bool      `json:"ok"`
	RTTMillis float64   `json:"rtt_millis"`
	Error     string    `json:"error,omitempty"`
}

Result is the outcome of one run of a check.

func (Result) InWindow added in v1.2.0

func (r Result) InWindow(now time.Time) bool

InWindow reports whether the time of the result is plausible at now.

func (Result) Validate

func (r Result) Validate() error

Validate reports why a result must be refused.

type ResultsRequest

type ResultsRequest struct {
	Results []Result `json:"results"`
}

ResultsRequest is a batch of results posted by an edge.

func (ResultsRequest) Validate

func (r ResultsRequest) Validate() error

Validate reports why a batch must be refused.

Jump to

Keyboard shortcuts

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