Skip to content

Add support for API version 8 #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ This project includes a client library for working with NGINX Plus API.

## Compatibility

This Client works against versions 4 to 7 of the NGINX Plus API. The table below shows the version of NGINX Plus where the API was first introduced.
This Client works against versions 4 to 8 of the NGINX Plus API. The table below shows the version of NGINX Plus where the API was first introduced.

| API version | NGINX Plus version |
|-------------|--------------------|
| 4 | R18 |
| 5 | R19 |
| 6 | R20 |
| 7 | R25 |
| 8 | R27 |

## Using the Client

Expand Down
8 changes: 6 additions & 2 deletions client/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

const (
// APIVersion is the default version of NGINX Plus API supported by the client.
APIVersion = 7
APIVersion = 8

pathNotFoundCode = "PathNotFound"
streamContext = true
Expand All @@ -25,7 +25,7 @@ const (
)

var (
supportedAPIVersions = versions{4, 5, 6, 7}
supportedAPIVersions = versions{4, 5, 6, 7, 8}

// Default values for servers in Upstreams.
defaultMaxConns = 0
Expand Down Expand Up @@ -235,6 +235,7 @@ type ServerZone struct {
Discarded uint64
Received uint64
Sent uint64
SSL SSL
}

// StreamServerZones is map of stream server zone stats by zone name.
Expand All @@ -248,6 +249,7 @@ type StreamServerZone struct {
Discarded uint64
Received uint64
Sent uint64
SSL SSL
}

// StreamZoneSync represents the sync information per each shared memory zone and the sync information per node in a cluster
Expand Down Expand Up @@ -373,6 +375,7 @@ type Peer struct {
Weight int
State string
Active uint64
SSL SSL
MaxConns int `json:"max_conns"`
Requests uint64
Responses Responses
Expand All @@ -398,6 +401,7 @@ type StreamPeer struct {
Weight int
State string
Active uint64
SSL SSL
MaxConns int `json:"max_conns"`
Connections uint64
ConnectTime int `json:"connect_time"`
Expand Down
5 changes: 4 additions & 1 deletion tests/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,13 @@ func TestStats(t *testing.T) {
if val.Requests < 1 {
t.Errorf("ServerZone stats missing: %v", val)
}
if val.Responses.Codes.HTTPOk < 1 {
t.Errorf("ServerZone response codes missing: %v", val.Responses.Codes)
}
} else {
t.Errorf("ServerZone 'test' not found")
}
if ups, ok := stats.Upstreams["test"]; ok {
if ups, ok := stats.Upstreams[upstream]; ok {
if len(ups.Peers) < 1 {
t.Errorf("upstream server not visible in stats")
} else {
Expand Down