Method AddNatsClient
- Namespace
- NATS.Extensions.Microsoft.DependencyInjection
- Assembly
- NATS.Extensions.Microsoft.DependencyInjection.dll
AddNatsClient(IServiceCollection, Action<NatsBuilder>?)
Registers a NATS client on the service collection with ad hoc JSON serialization enabled by default.
public static IServiceCollection AddNatsClient(this IServiceCollection services, Action<NatsBuilder>? buildAction = null)
Parameters
servicesIServiceCollectionThe service collection to add NATS to.
buildActionAction<NatsBuilder>Optional callback to configure the client through NatsBuilder.
Returns
- IServiceCollection
The same service collection so calls can be chained.
Remarks
Registers INatsClient, INatsConnection, NatsConnection and the connection pool.
This is the option to use for most applications. For AOT deployments or a minimal dependency footprint
without the JSON serializer, use NATS.Client.Hosting and its AddNats method instead.