cloudping

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 8 Imported by: 0

README

cloudping

Check latency in each region of various cloud providers (supports TCP, ICMP and HTTP)

Documentation

Index

Constants

View Source
const AWSProvider = "aws"
View Source
const GCPProvider = "gcp"

Variables

This section is empty.

Functions

func AddTarget

func AddTarget(t ...*RegionTarget)

Types

type HTTPRequester

type HTTPRequester interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPRequester is an interface for HTTP requests

type PingResult

type PingResult struct {
	Err    error
	Target RegionTarget
	Pings  []int
}

type Pinger

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

func NewPinger

func NewPinger(reqType string, c int) *Pinger

func (*Pinger) AddTarget

func (p *Pinger) AddTarget(targets ...*RegionTarget)

func (*Pinger) Results

func (p *Pinger) Results() []PingResult

func (*Pinger) Run

func (p *Pinger) Run(ctx context.Context) error

type RegionTarget

type RegionTarget struct {
	Provider string
	Name     string
	CodeName string
	Host     string
}

func GetAllTargets

func GetAllTargets() []*RegionTarget

func NewRegionTarget

func NewRegionTarget(provider, regionName, regionCodeName, host string) *RegionTarget

func (*RegionTarget) GetIP

func (t *RegionTarget) GetIP() (*net.TCPAddr, error)

GetIP return IP for target

func (*RegionTarget) GetURL

func (t *RegionTarget) GetURL() string

GetURL return HTTP URL for target

type Request

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

Request implements Requester interface

func NewRequest

func NewRequest() *Request

NewRequest creates a new instance of Request

func (*Request) Do

func (r *Request) Do(ua, url string, reqType RequestType) (time.Duration, error)

Do does a request. Type of request depends on reqType

func (*Request) DoHTTP

func (r *Request) DoHTTP(ua, url string) (time.Duration, error)

DoHTTP does HTTP request for a URL by User-Agent (ua)

func (*Request) DoTCP

func (r *Request) DoTCP(_, addr string) (time.Duration, error)

DoTCP does TCP request to the Addr

type RequestType

type RequestType int

RequestType describes a type for a request type

const (
	// RequestTypeHTTP is HTTP type of request
	RequestTypeHTTP RequestType = iota
	// RequestTypeTCP is TCP type of request
	RequestTypeTCP
)

type Requester

type Requester interface {
	Do(ua, url string, reqType RequestType) (time.Duration, error)
}

Requester is an interface to do a network request

type Runner

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

A Runner waits for a collection of goroutines to finish. It's wrapper around the waitgroup struct to add concurrency limit.

func NewRunner

func NewRunner(limit int) *Runner

NewRunner creates a new runner for concurrency tasks

func (*Runner) Add

func (wgl *Runner) Add(delta int)

Add adds delta, which may be negative, to the WaitGroup counter. See sync.WaitGroup for more info.

func (*Runner) Done

func (wgl *Runner) Done()

Done decrements the WaitGroup counter by one.

func (*Runner) Wait

func (wgl *Runner) Wait()

Wait blocks until the WaitGroup counter is zero.

type TCPRequester

type TCPRequester interface {
	Dial(network, address string) (net.Conn, error)
}

TCPRequester is an interface for TCP requests

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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