client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const APIVersion = 2

APIVersion is a version of NGINX Plus API.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connections

type Connections struct {
	Accepted uint64
	Dropped  uint64
	Active   uint64
	Idle     uint64
}

Connections represents connection related stats.

type HTTPRequests

type HTTPRequests struct {
	Total   uint64
	Current uint64
}

HTTPRequests represents HTTP request related stats.

type HealthChecks

type HealthChecks struct {
	Checks     uint64
	Fails      uint64
	Unhealthy  uint64
	LastPassed bool `json:"last_passed"`
}

HealthChecks represents health check related stats for a peer.

type NginxClient

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

NginxClient allows you to fetch NGINX metrics from the stub_status page.

func NewNginxClient

func NewNginxClient(httpClient *http.Client, apiEndpoint string) (*NginxClient, error)

NewNginxClient creates an NginxClient.

func (*NginxClient) GetStubStats

func (client *NginxClient) GetStubStats() (*StubStats, error)

GetStubStats fetches the stub_status metrics.

type NginxPlusClient

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

NginxPlusClient lets you add/remove servers to/from NGINX Plus via its API.

func NewNginxPlusClient

func NewNginxPlusClient(httpClient *http.Client, apiEndpoint string) (*NginxPlusClient, error)

NewNginxPlusClient creates an NginxPlusClient.

func (*NginxPlusClient) AddHTTPServer

func (client *NginxPlusClient) AddHTTPServer(upstream string, server UpstreamServer) error

AddHTTPServer adds the server to the upstream.

func (*NginxPlusClient) AddStreamServer

func (client *NginxPlusClient) AddStreamServer(upstream string, server StreamUpstreamServer) error

AddStreamServer adds the server to the upstream.

func (*NginxPlusClient) CheckIfStreamUpstreamExists

func (client *NginxPlusClient) CheckIfStreamUpstreamExists(upstream string) error

CheckIfStreamUpstreamExists checks if the stream upstream exists in NGINX. If the upstream doesn't exist, it returns the error.

func (*NginxPlusClient) CheckIfUpstreamExists

func (client *NginxPlusClient) CheckIfUpstreamExists(upstream string) error

CheckIfUpstreamExists checks if the upstream exists in NGINX. If the upstream doesn't exist, it returns the error.

func (*NginxPlusClient) DeleteHTTPServer

func (client *NginxPlusClient) DeleteHTTPServer(upstream string, server string) error

DeleteHTTPServer the server from the upstream.

func (*NginxPlusClient) DeleteStreamServer

func (client *NginxPlusClient) DeleteStreamServer(upstream string, server string) error

DeleteStreamServer the server from the upstream.

func (*NginxPlusClient) GetHTTPServers

func (client *NginxPlusClient) GetHTTPServers(upstream string) ([]UpstreamServer, error)

GetHTTPServers returns the servers of the upstream from NGINX.

func (*NginxPlusClient) GetStats

func (client *NginxPlusClient) GetStats() (*Stats, error)

GetStats gets connection, request, ssl, zone, and upstream related stats from the NGINX Plus API.

func (*NginxPlusClient) GetStreamServers

func (client *NginxPlusClient) GetStreamServers(upstream string) ([]StreamUpstreamServer, error)

GetStreamServers returns the stream servers of the upstream from NGINX.

func (*NginxPlusClient) UpdateHTTPServers

func (client *NginxPlusClient) UpdateHTTPServers(upstream string, servers []UpstreamServer) ([]UpstreamServer, []UpstreamServer, error)

UpdateHTTPServers updates the servers of the upstream. Servers that are in the slice, but don't exist in NGINX will be added to NGINX. Servers that aren't in the slice, but exist in NGINX, will be removed from NGINX.

func (*NginxPlusClient) UpdateStreamServers

func (client *NginxPlusClient) UpdateStreamServers(upstream string, servers []StreamUpstreamServer) ([]StreamUpstreamServer, []StreamUpstreamServer, error)

UpdateStreamServers updates the servers of the upstream. Servers that are in the slice, but don't exist in NGINX will be added to NGINX. Servers that aren't in the slice, but exist in NGINX, will be removed from NGINX.

type Peer

type Peer struct {
	ID           int
	Server       string
	Service      string
	Name         string
	Backup       bool
	Weight       int
	State        string
	Active       uint64
	MaxConns     int `json:"max_conns"`
	Requests     uint64
	Responses    Responses
	Sent         uint64
	Received     uint64
	Fails        uint64
	Unavail      uint64
	HealthChecks HealthChecks `json:"health_checks"`
	Downtime     uint64
	Downstart    string
	Selected     string
	HeaderTime   uint64 `json:"header_time"`
	ResponseTime uint64 `json:"response_time"`
}

Peer represents peer (upstream server) related stats.

type Queue

type Queue struct {
	Size      int
	MaxSize   int `json:"max_size"`
	Overflows uint64
}

Queue represents queue related stats for an upstream.

type Responses

type Responses struct {
	Responses1xx uint64 `json:"1xx"`
	Responses2xx uint64 `json:"2xx"`
	Responses3xx uint64 `json:"3xx"`
	Responses4xx uint64 `json:"4xx"`
	Responses5xx uint64 `json:"5xx"`
}

Responses represents HTTP reponse related stats.

type SSL

type SSL struct {
	Handshakes       uint64
	HandshakesFailed uint64 `json:"handshakes_failed"`
	SessionReuses    uint64 `json:"session_reuses"`
}

SSL represents SSL related stats.

type ServerZone

type ServerZone struct {
	Processing uint64
	Requests   uint64
	Responses  Responses
	Discarded  uint64
	Received   uint64
	Sent       uint64
}

ServerZone represents server zone related stats.

type ServerZones

type ServerZones map[string]ServerZone

ServerZones is map of server zone stats by zone name

type Stats

type Stats struct {
	Connections  Connections
	HTTPRequests HTTPRequests
	SSL          SSL
	ServerZones  ServerZones
	Upstreams    Upstreams
}

Stats represents NGINX Plus stats fetched from the NGINX Plus API. https://nginx.org/en/docs/http/ngx_http_api_module.html

type StreamUpstreamServer

type StreamUpstreamServer struct {
	ID          int64  `json:"id,omitempty"`
	Server      string `json:"server"`
	MaxFails    int64  `json:"max_fails"`
	FailTimeout string `json:"fail_timeout,omitempty"`
	SlowStart   string `json:"slow_start,omitempty"`
}

StreamUpstreamServer lets you configure Stream upstreams.

type StubConnections

type StubConnections struct {
	Active   int64
	Accepted int64
	Handled  int64
	Reading  int64
	Writing  int64
	Waiting  int64
}

StubConnections represents connections related metrics.

type StubStats

type StubStats struct {
	Connections StubConnections
	Requests    int64
}

StubStats represents NGINX stub_status metrics.

type Upstream

type Upstream struct {
	Peers      []Peer
	Keepalives int
	Zombies    int
	Zone       string
	Queue      Queue
}

Upstream represents upstream related stats.

type UpstreamServer

type UpstreamServer struct {
	ID          int    `json:"id,omitempty"`
	Server      string `json:"server"`
	MaxFails    int    `json:"max_fails"`
	FailTimeout string `json:"fail_timeout,omitempty"`
	SlowStart   string `json:"slow_start,omitempty"`
}

UpstreamServer lets you configure HTTP upstreams.

type Upstreams

type Upstreams map[string]Upstream

Upstreams is a map of upstream stats by upstream name.

Jump to

Keyboard shortcuts

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