GET /v1/stream connection open in a background Task. Whenever the Nexus backend emits a change event (config.updated, flag.toggled, secret.created, resync, …), the SDK triggers an immediate full sync - so the cache is updated within milliseconds of the change, instead of waiting for the next TTL tick.
Enabling it
CallConnectStream() after the client is created (or rely on your DI factory to do it):
ConnectStream() is idempotent. Calling it twice is a no-op.
What happens under the hood
- The SDK opens an HTTP streaming response to
<BaseUrl>/v1/streamwithAccept: text/event-streamand theX-Nexus-API-Keyheader. - The server immediately sends a
resyncevent, which causes the SDK to callSyncAsync()once to align with the current state. - The connection stays open. Every change event triggers another full sync.
- While the stream is up,
IsStreamConnectedreportstrueand the effective polling TTL is bumped to 60 s as a safety net.
Reconnection
Any transport error (server restart, TCP drop, network blip) triggers a reconnect with exponential backoff: 1s - 2s - 4s - 8s - 16s - 30s (capped at 30s). AfterMaxStreamErrors consecutive transport errors the SDK does not give up permanently. Instead, it sleeps for the next interval in the SseReconnectCooldown schedule and then retries SSE automatically.
[5, 10, 20, 40, 60] minutes. After the cooldown elapses the SDK resets the transport-error counter and reconnects. Configure the schedule via SseReconnectCooldown in NexusConfig - see Configuration.
429 Too Many Requests
Every project tier has a per-service stream connection limit:
Behaviour (v0.6.0+)
Retry-After parsing uses RetryConditionHeaderValue.Delta with a Date - DateTimeOffset.UtcNow fallback for the HTTP-date form.
The [5 s, 5 min] clamp is deliberate:
- 5 s floor - protects the SDK against a hostile or misconfigured server advertising
Retry-After: 0. - 5 min ceiling - caps the indefinite-stall risk.
Disabling SSE
Just don’t callConnectStream(). The SDK then runs in pure TTL-polling mode.
You can also disconnect at runtime:
Lifecycle
The stream is bound to the client.Dispose() / DisposeAsync() stops the background task before releasing the underlying HTTP client - always dispose the client (or use await using) on shutdown.
What events trigger a sync
IConfiguration live reload
When the SDK is wired into ASP.NET Core viaAddWestyx(...), the NexusConfigurationProvider calls IConfiguration.Reload() automatically after every sync that returns new data. This means:
IOptionsMonitor<T>.CurrentValueis immediately updated.IOptionsMonitor<T>.OnChange(...)callbacks fire without any manual intervention.- No application restart is required.
