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).

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