latency

package
v0.4.5-rc5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPV4Only

func IPV4Only(ip net.IP) bool

IPV4Only is an IPFilter function that filters out non IPv4 address

func Latency

func Latency(host string) (time.Duration, error)

Latency does a TCP dial to host and return the amount of time it took to get a response or an error if it fails to connect

Types

type IPFilter

type IPFilter func(net.IP) bool

IPFilter is function used by Sorted to filters out IP address during the latency test

func ExcludePrefix

func ExcludePrefix(prefix []byte) IPFilter

ExcludePrefix is a IPFilter function that filters IPs that start with prefix

type Result

type Result struct {
	Endpoint string
	Latency  time.Duration
}

Result is the struct return by the LatencySorter

type Sorter

type Sorter struct {
	// contains filtered or unexported fields
}

Sorter lets you get the latency from a list of endpoint and return an ascending sorted list of endpoint

func NewSorter

func NewSorter(endpoints []string, worker int, filters ...IPFilter) *Sorter

NewSorter create a new LatencySorter that will sort endpoints by latency you can controle the concurrency by tuning the worker value

func (*Sorter) Run

func (l *Sorter) Run(ctx context.Context) []Result

Run concurrently checks the latency of all the endpoint contained in l

Jump to

Keyboard shortcuts

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