feat(go-client): configurable event buffer, grpc.NewClient dial, typed diagnostics

- Options.EventBufferSize (default 1024) replaces the fixed 16-slot Events buffer
- Dial/DialGalaxy use grpc.NewClient + explicit READY wait (replaces DialContext+WithBlock)
- Session.Ping/GetSessionState/GetWorkerInfo/DrainEvents typed diagnostics
This commit is contained in:
Joseph Doherty
2026-10-22 06:08:31 -04:00
parent 488649ce99
commit a3a7bd2170
7 changed files with 389 additions and 14 deletions
+23
View File
@@ -100,6 +100,29 @@ judges each `MXSTATUS_PROXY` entry by its category — an entry fails when
`Category` is not `MX_STATUS_CATEGORY_OK`, and the raw `Success` member is a
diagnostic that never decides the verdict. A nil entry is success.
`Dial` is connect-or-fail: it creates the connection with `grpc.NewClient`
(the endpoint resolves with the `passthrough` scheme unless it names one) and
then waits for the channel to become READY, bounded by `DialTimeout` (default
10 s) or the context deadline. A failure is returned as a `GatewayError` with
`Op == "dial"`. Passing a connection to `NewClient`/`NewGalaxyClient` stays lazy.
### Event buffering
The channel returned by `Session.Events`/`EventsAfter` buffers
`Options.EventBufferSize` data results (default `DefaultEventBufferSize`, 1024).
If the consumer falls behind and the buffer fills, the stream is cancelled; the
results already buffered are still delivered in order, followed by a final
result whose error matches `errors.Is(err, mxgateway.ErrSlowConsumer)`. Raise
`EventBufferSize` for bursty feeds, or use `SubscribeEvents`/`SubscribeEventsAfter`,
which block instead of dropping and are the non-dropping alternative.
### Diagnostics
`Session.Ping`, `GetSessionState`, `GetWorkerInfo`, and `DrainEvents` are typed
wrappers over the diagnostic commands (`PingRaw` remains for the raw reply).
`DrainEvents(ctx, maxEvents)` returns fewer events than requested when the
server caps the reply; call it until it returns an empty slice.
### Reconnect-replay gap
Each `EventResult` carries exactly one of `Event`, `ReplayGap`, or `Err`. When