Documentation ¶
Index ¶
- Constants
- func SortServersByDistance(servers []Server, org geo.Coordinates) map[ServerID]geo.Kilometers
- func StableSortServersByAverageLatency(servers []Server, ctx context.Context, client *Client, samples int) (map[ServerID]time.Duration, error)
- type Client
- type Config
- type Server
- func (s Server) AverageLatency(ctx context.Context, client *Client, samples int) (time.Duration, error)
- func (s Server) Latency(ctx context.Context, client *Client) (time.Duration, error)
- func (s Server) ProbeDownloadSpeed(ctx context.Context, client *Client, stream chan<- units.BytesPerSecond) (units.BytesPerSecond, error)
- func (s Server) ProbeUploadSpeed(ctx context.Context, client *Client, stream chan<- units.BytesPerSecond) (units.BytesPerSecond, error)
- func (s *Server) RelativeURL(local string) (string, error)
- func (s Server) String() string
- type ServerID
Constants ¶
View Source
const DefaultLatencySamples = 4
Variables ¶
This section is empty.
Functions ¶
func SortServersByDistance ¶
func SortServersByDistance(servers []Server, org geo.Coordinates) map[ServerID]geo.Kilometers
func StableSortServersByAverageLatency ¶
func StableSortServersByAverageLatency( servers []Server, ctx context.Context, client *Client, samples int, ) (map[ServerID]time.Duration, error)
Probes each and every server and stable sorts them based on their average latencies.
Returns the average latencies in a map keyed by each server's ID and an error if all probes were unsuccessful. An error for a particular server gets treated as if the latency was higher than any successful probe.
Types ¶
type Server ¶
type Server struct { ID ServerID `xml:"id,attr"` Name string `xml:"name,attr"` Coordinates geo.Coordinates URL string `xml:"url,attr"` URL2 string `xml:"url2,attr"` Country string `xml:"country,attr"` CC string `xml:"cc,attr"` Sponsor string `xml:"sponsor,attr"` Host string `xml:"host,attr"` }
func (Server) AverageLatency ¶
func (s Server) AverageLatency( ctx context.Context, client *Client, samples int, ) (time.Duration, error)
Takes samples of a server's latency and returns the average.
Serialized and fails fast. It is assumed that if there is an error doing a single latency probe to a server, that server is not a good candidate for a speed test.
func (Server) ProbeDownloadSpeed ¶
func (s Server) ProbeDownloadSpeed( ctx context.Context, client *Client, stream chan<- units.BytesPerSecond, ) (units.BytesPerSecond, error)
Will probe download speed until enough samples are taken or ctx expires.
func (Server) ProbeUploadSpeed ¶
func (s Server) ProbeUploadSpeed( ctx context.Context, client *Client, stream chan<- units.BytesPerSecond, ) (units.BytesPerSecond, error)
Will probe upload speed until enough samples are taken or ctx expires.
Click to show internal directories.
Click to hide internal directories.