Skip to content

Commit

Permalink
Add client statistics to the connection spec
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
Jarema committed Sep 30, 2024
1 parent 2c9cc9d commit 3414ba6
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions adr/ADR-40.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
| -------- | ---------- | -------- | ---------------------------- |
| 1 | 2023-10-12 | @Jarema | Initial draft |
| 2 | 2024-6-24 | @aricart | Added protocol error section |
| 3 | 2024-9-30 | @Jarema | Add connection Statistics |

## Summary

Expand Down Expand Up @@ -388,7 +389,7 @@ server. The client will follow its reconnect logic.
`Secure Connection - TLS Required` is sent if the client is trying to connect on
a server that requires TLS.

> [!IMPORTANT]
> [!IMPORTANT]
> The client should have done extensive ServerInfo investigation
> and determined that this would have been a failure when initiating the
> connection.
Expand Down Expand Up @@ -434,7 +435,7 @@ disconnected. Reconnect was greeted with a `Authorization Error`.
`invalid client protocol` sent to the client if the protocol version from the
client doesn't match. Client is disconnected when this error is sent.

> [!NOTE]
> [!NOTE]
> Currently, this is not a concern since presumably, a server will be
> able to deal with protocol version 1 when protocol upgrades.
Expand All @@ -445,7 +446,7 @@ responder, but rejects headers. Client is disconnected when this error is sent.
Current clients hardcode `headers: true`, so this error shouldn't be seen by
clients.

> [!IMPORTANT]
> [!IMPORTANT]
> `headers` connect option shouldn't be exposed by the clients -
> this is a holdover from when clients opted in to `headers`.
Expand Down Expand Up @@ -473,6 +474,24 @@ a command. This is followed by a disconnect.
- `maximum account active connections exceeded` not notified to the client, the
client connecting will be disconnected (seen as a connection refused.)

### Client Statistics
Clients should implement statistics gathered throughout the lifetime of the client (persisted between connections):

#### Bytes In
Should account for everything received from the server, a record of bytes received on the socket.

#### Bytes Out
Should account for everything sent to the server, a record of bytes sent on the socket.

#### Messages In
Every message (`MSG` and `HMSG`) received from the server.

#### Messages out
Every message (`PUB` and `HPUB`) sent to the server.

#### Connets
Total number of connections (first connection and any successful reconnection) made by the client.

### Security Considerations

Discuss any additional security considerations pertaining to the TLS
Expand Down

0 comments on commit 3414ba6

Please sign in to comment.