Skip to content

Commit

Permalink
Fixed linter's warnings. Add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
ekalinin committed Nov 19, 2021
1 parent 2a6f564 commit d87bc28
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (
CheckTypeTCP CheckType = iota
// CheckTypeHTTP is HTTP type of check
CheckTypeHTTP
// CheckTypeHTTP is HTTPS type of check
// CheckTypeHTTPS is HTTPS type of check
CheckTypeHTTPS
)

Expand Down
10 changes: 9 additions & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@ import (
"time"
)

// RequestType describes a type for a request type
type RequestType int

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

// Requester is an interface to do a network request
type Requester interface {
Do(ua, url string, reqType RequestType) (time.Duration, error)
}

// AWSRequest implements Requester interface
type AWSRequest struct{}

// DoHTTP does HTTP request for a URL by User-Agent (ua)
func (r *AWSRequest) DoHTTP(ua, url string) (time.Duration, error) {
client := &http.Client{}

Expand All @@ -40,7 +46,8 @@ func (r *AWSRequest) DoHTTP(ua, url string) (time.Duration, error) {
return latency, nil
}

func (r *AWSRequest) DoTCP(ua, addr string) (time.Duration, error) {
// DoTCP does TCP request to the Addr
func (r *AWSRequest) DoTCP(_, addr string) (time.Duration, error) {
d := net.Dialer{}

start := time.Now()
Expand All @@ -54,6 +61,7 @@ func (r *AWSRequest) DoTCP(ua, addr string) (time.Duration, error) {
return l, nil
}

// Do does a request. Type of request depends on reqType
func (r *AWSRequest) Do(ua, url string, reqType RequestType) (time.Duration, error) {
if reqType == RequestTypeHTTP {
return r.DoHTTP(ua, url)
Expand Down
3 changes: 3 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import (
)

var (
// Version describes application version
Version = "1.0.0"
github = "https://github.com/ekalinin/awsping"
useragent = fmt.Sprintf("AwsPing/%s (+%s)", Version, github)
)

const (
// ShowOnlyRegions describes a type of output when only region's name and code printed out
ShowOnlyRegions = -1
)

Expand All @@ -45,6 +47,7 @@ type LatencyOutput struct {
w io.Writer
}

// NewOutput creates a new LatencyOutput instance
func NewOutput(level, repeats int) *LatencyOutput {
return &LatencyOutput{
Level: level,
Expand Down

0 comments on commit d87bc28

Please sign in to comment.