Method AddNats
AddNats(IServiceCollection, int, Func<NatsOpts, NatsOpts>?, Action<NatsConnection>?)
Registers a NATS connection on the service collection with minimal dependencies and no JSON serializer.
[SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1001:Commas should not be preceded by whitespace", Justification = "Required for conditional build.")]
[SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1009:Closing parenthesis should not be preceded by a space", Justification = "Required for conditional build.")]
[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1111:Closing parenthesis should be on the same line as the last parameter", Justification = "Required for conditional build.")]
[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1113:Comma should be on the same line as previous parameter", Justification = "Required for conditional build.")]
public static IServiceCollection AddNats(this IServiceCollection services, int poolSize = 1, Func<NatsOpts, NatsOpts>? configureOpts = null, Action<NatsConnection>? configureConnection = null)
Parameters
servicesIServiceCollectionpoolSizeintconfigureOptsFunc<NatsOpts, NatsOpts>configureConnectionAction<NatsConnection>
Returns
Remarks
When poolSize is 1, NatsConnection and INatsConnection are registered as singletons.
For a larger pool, NatsConnectionPool is registered as a singleton and NatsConnection/
INatsConnection as transient, resolved from the pool. This package suits AOT and tight dependency
footprints; it does not register INatsClient or enable ad hoc JSON serialization. For those, use
NATS.Extensions.Microsoft.DependencyInjection and its AddNatsClient method instead.