Documentation
¶
Overview ¶
Package globalping is the Globalping integration: the owner's settings (off by default, an interval, an optional write-only token; the country is the shared one of countryreach), a client of the Globalping API and the health.CountrySource that the country check measures through. It knows nothing about Telegram or any other integration; alerts it leads to travel through the usual alert pipeline.
Switching it off stops everything: Country reports it as off, so the health module starts no round and makes no request, and a round in flight is cancelled.
Index ¶
Constants ¶
const (
// DefaultBaseURL is Globalping's API.
DefaultBaseURL = "https://api.globalping.io"
)
Variables ¶
var ErrDisabled = errors.New("globalping: switched off")
ErrDisabled: Globalping is switched off, so a one-off measurement is not made either.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Store *store.Store
Vault *vault.Vault
// StepUp is auth.Service.RequireStepUp: changing the settings asks for it.
StepUp func(context.Context) error
// HTTPClient reaches Globalping (tests use a fake server's). Default: a client with a 20 s timeout.
HTTPClient *http.Client
// BaseURL of the API; default DefaultBaseURL (tests use a fake server).
BaseURL string
// PollDelay between two reads of a running measurement; default 500 ms, which the API's guidelines ask for.
PollDelay time.Duration
// Country is the country to look from, the shared setting of the country check (countryreach.Service.Country). Default RU.
Country func(context.Context) string
// OnChange is called after the settings were changed or the integration was disconnected, so that the alerts that depended
// on it are brought up to date at once (health.Service.ReconcileCountry). May be nil.
OnChange func(context.Context)
Log *slog.Logger
Now func() time.Time
}
Config configures Service. Store, Vault and StepUp are required.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the integration.
func (*Service) Country ¶
func (s *Service) Country(ctx context.Context) (health.CountryConfig, health.CountrySource)
Country is health.Config.Country: the owner's choice and the source to measure with. While the integration is off (the default, or any trouble reading the settings) it says so and returns no source.
func (*Service) ProbeTCP6 ¶ added in v0.1.66
func (s *Service) ProbeTCP6(ctx context.Context, addr string, port uint16) (answered, connected int, err error)
ProbeTCP6 is the last resort of the IPv6 check of a node (fleet.Config.GlobalpingTCP6): one TCP ping of a port of an IPv6 address from two probes anywhere. It says how many probes gave an answer and how many of those connected. An IPv6 literal takes no ipVersion; the API picks only probes that have IPv6 and answers 422 when it has none, which is an error here. It costs two tests of the hourly budget and honours the owner's switch (not the IPv6 round's own toggle: this is a request, not a schedule).