endpoint

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package endpoint implements the HTTP endpoints of Ayd such as status page.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthzEndpoint

func HealthzEndpoint(s Store) http.HandlerFunc

HealthzEndpoint is the http.HandlerFunc for /healthz page.

func IncidentsCSVEndpoint added in v0.14.0

func IncidentsCSVEndpoint(s Store) http.HandlerFunc

func IncidentsHTMLEndpoint added in v0.14.0

func IncidentsHTMLEndpoint(s Store) http.HandlerFunc

func IncidentsJSONEndpoint added in v0.14.0

func IncidentsJSONEndpoint(s Store) http.HandlerFunc

func IncidentsRSSEndpoint added in v0.14.0

func IncidentsRSSEndpoint(s Store) http.HandlerFunc

func LogCSVEndpoint

func LogCSVEndpoint(s Store) http.HandlerFunc

func LogHTMLEndpoint added in v0.14.0

func LogHTMLEndpoint(s Store) http.HandlerFunc

func LogJsonEndpoint

func LogJsonEndpoint(s Store) http.HandlerFunc

func LogLTSVEndpoint added in v0.16.0

func LogLTSVEndpoint(s Store) http.HandlerFunc

func LogXlsxEndpoint added in v0.16.0

func LogXlsxEndpoint(s Store) http.HandlerFunc

func MCPHandler added in v0.18.0

func MCPHandler(s Store) http.Handler

func MCPServer added in v0.18.0

func MCPServer(s Store) *mcp.Server

func MetricsEndpoint

func MetricsEndpoint(s Store) http.HandlerFunc

MetricsEndpoint implements Prometheus metrics endpoint. This endpoint follows both of Prometheus specification and OpenMetrics specification.

func New

func New(s Store) http.Handler

New makes new http.Handler

func StatusHTMLEndpoint

func StatusHTMLEndpoint(s Store) http.HandlerFunc

func StatusJSONEndpoint

func StatusJSONEndpoint(s Store) http.HandlerFunc

func StatusTextEndpoint

func StatusTextEndpoint(s Store) http.HandlerFunc

func TargetsJSONEndpoint added in v0.12.0

func TargetsJSONEndpoint(s Store) http.HandlerFunc

TargetsJSONEndpoint replies target list in json format.

func TargetsTextEndpoint added in v0.12.0

func TargetsTextEndpoint(s Store) http.HandlerFunc

TargetsTextEndpoint replies target list in text.

func WithBasicAuth added in v0.12.0

func WithBasicAuth(handler http.Handler, userinfo string) http.Handler

WithBasicAuth wraps http.Handler with a BasicAuth.

Types

type BasicAuth

type BasicAuth struct {
	Handler            http.Handler
	Username, Password string
}

BasicAuth is a http.Handler wrapper that handles Basic Authorization. It supports only one pair of username and password.

func (BasicAuth) ServeHTTP

func (a BasicAuth) ServeHTTP(w http.ResponseWriter, r *http.Request)

type CommonHeader added in v0.13.3

type CommonHeader struct {
	Upstream http.Handler
}

func (CommonHeader) ServeHTTP added in v0.13.3

func (ch CommonHeader) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ContextScanner added in v0.16.1

type ContextScanner struct {
	// contains filtered or unexported fields
}

func NewContextScanner added in v0.16.1

func NewContextScanner(ctx context.Context, s api.LogScanner) ContextScanner

func (ContextScanner) Close added in v0.16.1

func (cs ContextScanner) Close() error

func (ContextScanner) Record added in v0.16.1

func (cs ContextScanner) Record() api.Record

func (ContextScanner) Scan added in v0.16.1

func (cs ContextScanner) Scan() bool

type FilterScanner added in v0.16.0

type FilterScanner struct {
	Scanner api.LogScanner
	Query   query.Query
}

func (FilterScanner) Close added in v0.16.0

func (f FilterScanner) Close() error

func (FilterScanner) Record added in v0.16.0

func (f FilterScanner) Record() api.Record

func (FilterScanner) Scan added in v0.16.0

func (f FilterScanner) Scan() bool

type JQQuery added in v0.18.0

type JQQuery struct {
	Code *gojq.Code
}

func ParseJQ added in v0.18.0

func ParseJQ(query string) (JQQuery, error)

func (JQQuery) Run added in v0.18.0

func (q JQQuery) Run(ctx context.Context, s Store, logScope string, input any) (MCPOutput, error)

type LinkHeader added in v0.13.3

type LinkHeader struct {
	Upstream http.HandlerFunc
	Link     string
}

func (LinkHeader) ServeHTTP added in v0.13.3

func (lh LinkHeader) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MCPIncidentsInput added in v0.18.0

type MCPIncidentsInput struct {
	IncludeOngoing  *bool  `` /* 141-byte string literal not displayed */
	IncludeResolved bool   `` /* 148-byte string literal not displayed */
	JQ              string `` /* 507-byte string literal not displayed */
}

type MCPLogsInput added in v0.18.0

type MCPLogsInput struct {
	Since  string `json:"since" jsonschema:"The start time for fetching logs, in RFC3339 format."`
	Until  string `json:"until" jsonschema:"The end time for fetching logs, in RFC3339 format."`
	Search string `` /* 302-byte string literal not displayed */
	JQ     string `` /* 445-byte string literal not displayed */
}

type MCPOutput added in v0.18.0

type MCPOutput struct {
	Result any `json:"result" jsonschema:"The result of the query."`
}

func FetchIncidentsByJq added in v0.18.0

func FetchIncidentsByJq(ctx context.Context, s Store, input MCPIncidentsInput) (MCPOutput, error)

func FetchLogsByJq added in v0.18.0

func FetchLogsByJq(ctx context.Context, s Store, input MCPLogsInput) (MCPOutput, error)

func FetchStatusByJq added in v0.18.0

func FetchStatusByJq(ctx context.Context, s Store, input MCPStatusInput) (MCPOutput, error)

type MCPStatusInput added in v0.18.0

type MCPStatusInput struct {
	JQ string `` /* 469-byte string literal not displayed */
}

type PagingScanner added in v0.16.0

type PagingScanner struct {
	Scanner api.LogScanner
	Offset  uint64
	Limit   uint64
	// contains filtered or unexported fields
}

func (*PagingScanner) Close added in v0.16.0

func (s *PagingScanner) Close() error

func (*PagingScanner) Record added in v0.16.0

func (s *PagingScanner) Record() api.Record

func (*PagingScanner) Scan added in v0.16.0

func (s *PagingScanner) Scan() bool

func (*PagingScanner) ScanTotal added in v0.16.0

func (s *PagingScanner) ScanTotal() uint64

ScanTotal scans all logs and return number of records. Don't call this before get records you need, because this method consumes all logs.

type Store added in v0.12.0

type Store interface {
	// Name returns the Ayd instance name.
	Name() string

	// Targets returns target URLs include inactive target.
	Targets() []string

	// ProbeHistory returns a slice of ProbeHistory.
	ProbeHistory() []api.ProbeHistory

	// CurrentIncidents returns a slice of current incidents.
	CurrentIncidents() []*api.Incident

	// IncidentHistory returns a slice of past incidents.
	IncidentHistory() []*api.Incident

	// MakeReport creates ayd.Report for exporting for endpoint.
	MakeReport(probeHistoryLength int) api.Report

	// ReportInternalError reports Ayd internal error.
	ReportInternalError(scope, message string)

	// Errors returns a list of internal (critical) errors.
	Errors() (healthy bool, messages []string)

	// IncidentCount returns the count of incident causes.
	IncidentCount() int

	// OpenLog opens ayd.LogScanner.
	OpenLog(since, until time.Time) (api.LogScanner, error)
}

Jump to

Keyboard shortcuts

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