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 ¶
This section is empty.
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.