AspireNatsClientExtensions.AddKeyedNatsClient Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers NATS.Client.Core.INatsConnection as a keyed service for given name
for connecting NATS server with NATS client.
Configures health check and logging for the NATS client.
public static void AddKeyedNatsClient (this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string name, Action<Aspire.NATS.Net.NatsClientSettings>? configureSettings = default, Func<NATS.Client.Core.NatsOpts,NATS.Client.Core.NatsOpts>? configureOptions = default);
static member AddKeyedNatsClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.NATS.Net.NatsClientSettings> * Func<NATS.Client.Core.NatsOpts, NATS.Client.Core.NatsOpts> -> unit
<Extension()>
Public Sub AddKeyedNatsClient (builder As IHostApplicationBuilder, name As String, Optional configureSettings As Action(Of NatsClientSettings) = Nothing, Optional configureOptions As Func(Of NatsOpts, NatsOpts) = Nothing)
Parameters
- builder
- IHostApplicationBuilder
The IHostApplicationBuilder to read config from and add services to.
- name
- String
The name of the component, which is used as the ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
- configureSettings
- Action<NatsClientSettings>
An optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.
- configureOptions
- Func<NATS.Client.Core.NatsOpts,NATS.Client.Core.NatsOpts>
An optional delegate that can be used for customizing NATS options that aren't exposed as standard configuration.
Exceptions
Thrown when builder
or name
is null.
Thrown if mandatory name
is empty.
Thrown when mandatory ConnectionString is not provided.