Documentation
¶
Overview ¶
Package endpointapi is the admin REST surface that lists every endpoint binding on the deployment with its traffic (#2208): its script and owner, its address, access and limits, and over a day or a week the requests it answered by status class, their duration, its failures, its distinct callers and the requests it refused before its handler ran.
An endpoint answers HTTP with platform data, and a public one answers anyone. The only views of a binding were one script's page and manage_script endpoint_list; an administrator could not see what the deployment exposes, under whose script, and who is calling it, without opening scripts one at a time.
Index ¶
Constants ¶
const ( RangeDay = "day" RangeWeek = "week" )
The ranges a page reads, and the chart's bucket for each.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bucket ¶
type Bucket struct {
Start time.Time `json:"start"`
StatusClasses
Refused int64 `json:"refused"`
}
Bucket is one stretch of the request chart.
type Config ¶
type Config struct {
DB *sql.DB
Bindings epbinding.Store
// Script reads a binding's script by id.
Script func(ctx context.Context, id string) (*script.Script, error)
// BaseURL is the deployment's public address, which an endpoint's URL
// is under.
BaseURL string
// Now is the clock; nil is time.Now.
Now func() time.Time
}
Config is what the routes read.
type Detail ¶
type Detail struct {
Range string `json:"range"`
Since time.Time `json:"since"`
Endpoint
// BucketSeconds is how long each chart bucket is.
BucketSeconds int64 `json:"bucket_seconds"`
Series []Bucket `json:"series"`
TopCallers []Caller `json:"top_callers"`
Failures []epbinding.Failure `json:"failures"`
}
Detail is one endpoint's page: the binding and its totals, the request chart, its busiest callers and its recent failed requests.
type Endpoint ¶
type Endpoint struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Methods []string `json:"methods"`
Path string `json:"path"`
AuthMode string `json:"auth_mode"`
OpenReads bool `json:"open_reads"`
Enabled bool `json:"enabled"`
// Limits are the binding's per-request and per-minute limits.
TimeoutSeconds int `json:"timeout_seconds"`
MaxBodyBytes int `json:"max_body_bytes"`
RateLimit int `json:"rate_limit"`
CallerRateLimit int `json:"caller_rate_limit"`
UpdatedBy string `json:"updated_by"`
UpdatedAt time.Time `json:"updated_at"`
Script Script `json:"script"`
Traffic Traffic `json:"traffic"`
// Refused is how many requests it refused before its handler ran, and
// RefusedByReason the same by reason (bot_check, rate_limit,
// caller_rate_limit, body_limit, credential, origin).
Refused int64 `json:"refused"`
RefusedByReason map[string]int64 `json:"refused_by_reason"`
}
Endpoint is one binding and its traffic over the range.
type List ¶
type List struct {
Range string `json:"range"`
Since time.Time `json:"since"`
Endpoints []Endpoint `json:"endpoints"`
}
List is the list route's answer.
type Script ¶
type Script struct {
ID string `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name,omitempty"`
Owner string `json:"owner"`
}
Script is the script an endpoint runs, as the list names it.
type StatusClasses ¶
type StatusClasses struct {
S2xx int64 `json:"2xx"`
S3xx int64 `json:"3xx"`
S4xx int64 `json:"4xx"`
S5xx int64 `json:"5xx"`
}
StatusClasses counts by status class.
type Traffic ¶
type Traffic struct {
Requests int64 `json:"requests"`
// ByStatusClass counts the requests by the class of status the handler
// answered: 2xx, 3xx, 4xx, 5xx.
ByStatusClass StatusClasses `json:"by_status_class"`
// Failures are the requests whose handler failed.
Failures int64 `json:"failures"`
// P50MS and P95MS are the requests' durations.
P50MS float64 `json:"p50_ms"`
P95MS float64 `json:"p95_ms"`
// Callers is how many distinct signed-in callers sent requests.
Callers int64 `json:"callers"`
// LastRequestAt is the newest request's time, nil when there was none.
LastRequestAt *time.Time `json:"last_request_at,omitempty"`
}
Traffic is an endpoint's answered requests over a range, read from the audit row each one writes (event_kind endpoint_request, tool_name endpoint:<name>).