Table of Contents

Method AddNats

Namespace
NATS.Client.Hosting
Assembly
NATS.Client.Hosting.dll

AddNats(IServiceCollection, int, Func<NatsOpts, NatsOpts>?, Action<NatsConnection>?)

Add NatsConnection/Pool to ServiceCollection. When poolSize = 1, registered NatsConnection and INatsConnection as singleton. Others, registered NatsConnectionPool as singleton, NatsConnection and INatsConnection as transient(get from pool).

[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

services IServiceCollection
poolSize int
configureOpts Func<NatsOpts, NatsOpts>
configureConnection Action<NatsConnection>

Returns

IServiceCollection