WestyxNexus.Extensions.DependencyInjection (v0.11.0+)
AddWestyxNexus() registers the client as a singleton, wires it through IHttpClientFactory and the application’s ILoggerFactory, and performs the initial sync during host startup.
NexusClient anywhere:
Options
HttpClient and StreamHandler are deliberately absent. On this path the HTTP clients come from IHttpClientFactory, which is the point of using it - configure them by name instead.
Startup is asynchronous
The initial sync is a network call. A plain singleton factory would have to block:AddWestyxNexus() instead starts the work once and awaits it in an IHostedService, so host startup stays properly asynchronous and a misconfiguration surfaces as a startup failure rather than as a failure on the first request.
The hosted service is inserted at the front of the service collection, so the client is ready before any hosted service you registered can resolve it.
Customising the HTTP clients
Two named clients are registered:
Add your own handlers, retry policies or timeouts to either:
Handler rotation is safe for SSE
IHttpClientFactory rotates handlers every two minutes, which looks fatal for a connection that stays open for hours. It is not: the factory only stops handing an expired handler to new requests - a request already in flight keeps its handler until it completes.
Next
- Secrets binding -
IOptions<T>for secrets - Feature management - Nexus flags through
IFeatureManager - ASP.NET Core configuration - configs through
IConfiguration - Design decisions
