globalping

package
v0.2.2-dev.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	// DefaultBaseURL is Globalping's API.
	DefaultBaseURL = "https://api.globalping.io"
)

Variables

View Source
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 New

func New(cfg Config) (*Service, error)

New builds the service.

func (*Service) Country

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) Handler

func (s *Service) Handler(opts ...connect.HandlerOption) (string, http.Handler)

Handler is the admin GlobalpingService.

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).

Jump to

Keyboard shortcuts

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