Skip to content

Commit

Permalink
Enable more linters
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome committed Feb 5, 2024
1 parent d8a91de commit 56fb59a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 52 deletions.
15 changes: 13 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ linters-settings:
- name: unused-parameter
- name: var-declaration
- name: var-naming
govet:
check-shadowing: true
enable-all: true

linters:
enable:
enable:
- asciicheck
- bidichk
- dupword
- errcheck
- errorlint
- gofmt
Expand All @@ -45,15 +50,21 @@ linters:
- misspell
- nilerr
- noctx
- perfsprint
- predeclared
- reassign
- revive
- staticcheck
- tagalign
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
disable-all: true
- whitespace
disable-all: true
issues:
max-issues-per-linter: 0
max-same-issues: 0
Expand Down
100 changes: 50 additions & 50 deletions client/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ var ErrUnsupportedVer = errors.New("API version of the client is not supported b

// NginxClient lets you access NGINX Plus API.
type NginxClient struct {
apiVersion int
apiEndpoint string
httpClient *http.Client
apiEndpoint string
apiVersion int
checkAPI bool
}

Expand All @@ -54,38 +54,38 @@ type versions []int

// UpstreamServer lets you configure HTTP upstreams.
type UpstreamServer struct {
ID int `json:"id,omitempty"`
Server string `json:"server"`
MaxConns *int `json:"max_conns,omitempty"`
MaxFails *int `json:"max_fails,omitempty"`
FailTimeout string `json:"fail_timeout,omitempty"`
SlowStart string `json:"slow_start,omitempty"`
Route string `json:"route,omitempty"`
Backup *bool `json:"backup,omitempty"`
Down *bool `json:"down,omitempty"`
Drain bool `json:"drain,omitempty"`
Weight *int `json:"weight,omitempty"`
Server string `json:"server"`
FailTimeout string `json:"fail_timeout,omitempty"`
SlowStart string `json:"slow_start,omitempty"`
Route string `json:"route,omitempty"`
Service string `json:"service,omitempty"`
ID int `json:"id,omitempty"`
Drain bool `json:"drain,omitempty"`
}

// StreamUpstreamServer lets you configure Stream upstreams.
type StreamUpstreamServer struct {
ID int `json:"id,omitempty"`
Server string `json:"server"`
MaxConns *int `json:"max_conns,omitempty"`
MaxFails *int `json:"max_fails,omitempty"`
FailTimeout string `json:"fail_timeout,omitempty"`
SlowStart string `json:"slow_start,omitempty"`
Backup *bool `json:"backup,omitempty"`
Down *bool `json:"down,omitempty"`
Weight *int `json:"weight,omitempty"`
Server string `json:"server"`
FailTimeout string `json:"fail_timeout,omitempty"`
SlowStart string `json:"slow_start,omitempty"`
Service string `json:"service,omitempty"`
ID int `json:"id,omitempty"`
}

type apiErrorResponse struct {
Error apiError
RequestID string `json:"request_id"`
Href string
Error apiError
}

func (resp *apiErrorResponse) toString() string {
Expand All @@ -94,14 +94,14 @@ func (resp *apiErrorResponse) toString() string {
}

type apiError struct {
Status int
Text string
Code string
Status int
}

type internalError struct {
apiError
err string
apiError
}

// Error allows internalError to match the Error interface.
Expand All @@ -119,34 +119,34 @@ func (internalError *internalError) Wrap(err string) *internalError {
// Stats represents NGINX Plus stats fetched from the NGINX Plus API.
// https://nginx.org/en/docs/http/ngx_http_api_module.html
type Stats struct {
NginxInfo NginxInfo
Caches Caches
Processes Processes
Connections Connections
Slabs Slabs
HTTPRequests HTTPRequests
SSL SSL
ServerZones ServerZones
Upstreams Upstreams
ServerZones ServerZones
StreamServerZones StreamServerZones
StreamUpstreams StreamUpstreams
StreamZoneSync *StreamZoneSync
LocationZones LocationZones
Resolvers Resolvers
HTTPLimitRequests HTTPLimitRequests
Slabs Slabs
Caches Caches
HTTPLimitConnections HTTPLimitConnections
StreamLimitConnections StreamLimitConnections
HTTPLimitRequests HTTPLimitRequests
Resolvers Resolvers
LocationZones LocationZones
StreamZoneSync *StreamZoneSync
Workers []*Workers
NginxInfo NginxInfo
SSL SSL
Connections Connections
HTTPRequests HTTPRequests
Processes Processes
}

// NginxInfo contains general information about NGINX Plus.
type NginxInfo struct {
Version string
Build string
Address string
Generation uint64
LoadTimestamp string `json:"load_timestamp"`
Timestamp string
Generation uint64
ProcessID uint64 `json:"pid"`
ParentProcessID uint64 `json:"ppid"`
}
Expand Down Expand Up @@ -194,8 +194,8 @@ type Slabs map[string]Slab

// Slab represents slab related stats.
type Slab struct {
Pages Pages
Slots Slots
Pages Pages
}

// Pages represents the slab memory usage stats.
Expand Down Expand Up @@ -358,21 +358,21 @@ type Upstreams map[string]Upstream

// Upstream represents upstream related stats.
type Upstream struct {
Zone string
Peers []Peer
Queue Queue
Keepalives int
Zombies int
Zone string
Queue Queue
}

// StreamUpstreams is a map of stream upstream stats by upstream name.
type StreamUpstreams map[string]StreamUpstream

// StreamUpstream represents stream upstream related stats.
type StreamUpstream struct {
Zone string
Peers []StreamPeer
Zombies int
Zone string
}

// Queue represents queue related stats for an upstream.
Expand All @@ -384,54 +384,54 @@ type Queue struct {

// Peer represents peer (upstream server) related stats.
type Peer struct {
ID int
Server string
Service string
Name string
Backup bool
Weight int
Selected string
Downstart string
State string
Active uint64
Responses Responses
SSL SSL
MaxConns int `json:"max_conns"`
HealthChecks HealthChecks `json:"health_checks"`
Requests uint64
Responses Responses
ID int
MaxConns int `json:"max_conns"`
Sent uint64
Received uint64
Fails uint64
Unavail uint64
HealthChecks HealthChecks `json:"health_checks"`
Active uint64
Downtime uint64
Downstart string
Selected string
Weight int
HeaderTime uint64 `json:"header_time"`
ResponseTime uint64 `json:"response_time"`
Backup bool
}

// StreamPeer represents peer (stream upstream server) related stats.
type StreamPeer struct {
ID int
Server string
Service string
Name string
Backup bool
Weight int
Selected string
Downstart string
State string
Active uint64
SSL SSL
MaxConns int `json:"max_conns"`
HealthChecks HealthChecks `json:"health_checks"`
Connections uint64
Received uint64
ID int
ConnectTime int `json:"connect_time"`
FirstByteTime int `json:"first_byte_time"`
ResponseTime uint64 `json:"response_time"`
Sent uint64
Received uint64
MaxConns int `json:"max_conns"`
Fails uint64
Unavail uint64
HealthChecks HealthChecks `json:"health_checks"`
Active uint64
Downtime uint64
Downstart string
Selected string
Weight int
Backup bool
}

// HealthChecks represents health check related stats for a peer.
Expand Down

0 comments on commit 56fb59a

Please sign in to comment.