latency

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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