config: add a read limit option to the connection.

By default, the read limit is never set by NewConnection.
When using the default pool dialer, a read limit of 512KB is set.
When the read limit option is set, all sockets passed to NewConnection have that read limit set.
This commit is contained in:
Jay
2026-08-10 12:16:23 -04:00
parent 3ea8810f7c
commit 19810798a7
6 changed files with 71 additions and 1 deletions
+3
View File
@@ -16,6 +16,7 @@ All configuration uses option functions applied at construction time. Validation
| Connection | `PingInterval` | 20s | `0` | ±10% jitter applied per interval |
| Connection | `IncomingBufferSize` | 100 | — | Must be positive |
| Connection | `ErrorsBufferSize` | 10 | — | Must be positive |
| Connection | `ReadLimit` | nil | 0 | Does nothing when unset, 0 = unlimited |
| Retry | `MaxRetries` | 0 | — | 0 means infinite |
| Retry | `InitialDelay` | 1s | — | Must be positive |
| Retry | `MaxDelay` | 60s | — | Must be ≥ `InitialDelay` |
@@ -61,6 +62,8 @@ These are passed to `transport.NewConnectionConfig`. Import `git.wisehodl.dev/ja
**`WithErrorsBufferSize(int)`** — sets the capacity of the channel carrying connection-level errors. Must be at least 1.
**`WithReadLimit(int64)`** — sets the limit on incoming socket messages. Does nothing when unset. Incoming message size is unlimited when set to zero. The default pool dialer sets a read limit of 512KB. Setting this option overrides that default.
## Retry Options
These are passed to `transport.NewRetryConfig`. Import `git.wisehodl.dev/jay/go-honeybee/transport`. The resulting `RetryConfig` is then passed to `NewSessionConfig` via `WithRetryConfig`.