Documentation
¶
Overview ¶
Package edge is the agent: it polls the central, runs probes and reports results.
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrUnauthorized is returned when the central refuses the token.
Functions ¶
func DoctorSteps ¶ added in v1.1.0
func DoctorSteps(cfg DoctorConfig) []doctor.Step
DoctorSteps checks, in order, everything an edge needs to work: the settings, the name of the central, the network path to it, its certificate, its health, the token and the clock.
Types ¶
type Agent ¶
type Agent struct {
Client *Client
Measure Measurer
Interval time.Duration // between two polls
ReportInterval time.Duration // between two reports
Log *slog.Logger
}
Agent polls the central for checks, runs them and reports the results.
type Client ¶ added in v1.1.0
type Client struct {
// contains filtered or unexported fields
}
Client talks to the edge API of the central.
func NewClient ¶ added in v1.1.0
func NewClient(central, token string, opts ...ClientOption) (*Client, error)
NewClient checks the central URL and prepares a client. A token is never sent over plain HTTP unless the central is on this machine.
func (*Client) Assignments ¶ added in v1.1.0
Assignments fetches the checks to run. changed is false when the central answered that nothing differs from the previous call.
type ClientOption ¶ added in v1.1.0
type ClientOption func(*Client)
ClientOption changes how a Client talks to the central.
func WithTLS ¶ added in v1.1.0
func WithTLS(cfg *tls.Config) ClientOption
WithTLS sets the TLS settings of the connection, for a private CA or a client certificate.
type DoctorConfig ¶ added in v1.1.0
type DoctorConfig struct {
Central string
Token string
// TLS holds the private CA and the client certificate; nil means the system
// trust store and no client certificate.
TLS *tls.Config
}
DoctorConfig is what the edge diagnostics need.
type Measurer ¶ added in v1.1.0
Measurer runs one check and describes the outcome.
func ProbeMeasurer ¶ added in v1.1.0
ProbeMeasurer runs each check with the probe of its kind.
type Reporter ¶ added in v1.1.0
type Reporter struct {
// contains filtered or unexported fields
}
Reporter queues results and sends them to the central in batches. While the central is unreachable the results wait in memory, up to maxQueued; the oldest are dropped first.
func NewReporter ¶ added in v1.1.0
NewReporter sends what was queued every interval.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler runs each assigned check on its own interval and hands the results to a sink, which is called from several goroutines.
func NewScheduler ¶
NewScheduler starts with no checks; the context ends every one of them.
type StatusError ¶ added in v1.1.0
StatusError is an answer of the central that is neither a success nor an authentication failure.
func (*StatusError) Error ¶ added in v1.1.0
func (e *StatusError) Error() string