AspireNatsClientExtensions Methods
ClassMethods13 members
Extension methods for connecting NATS server with NATS client
AddKeyedNatsClient(IHostApplicationBuilder, string) Section titled AddKeyedNatsClient(IHostApplicationBuilder, string)extensionpublic static class AspireNatsClientExtensions{ public static void AddKeyedNatsClient( this IHostApplicationBuilder builder, string name) { // ... }}Parameters
builderIHostApplicationBuilder namestringAddKeyedNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>) Section titled AddKeyedNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>)extensionpublic static class AspireNatsClientExtensions{ public static void AddKeyedNatsClient( this IHostApplicationBuilder builder, string name, Action<NatsClientSettings>? configureSettings) { // ... }}Parameters
builderIHostApplicationBuilder namestringconfigureSettings Action<NatsClientSettings> AddKeyedNatsClient(IHostApplicationBuilder, string, Func<NatsOpts, NatsOpts>) Section titled AddKeyedNatsClient(IHostApplicationBuilder, string, Func<NatsOpts, NatsOpts>)extensionpublic static class AspireNatsClientExtensions{ public static void AddKeyedNatsClient( this IHostApplicationBuilder builder, string name, Func<NatsOpts, NatsOpts>? configureOptions) { // ... }}Parameters
builderIHostApplicationBuilder namestringconfigureOptions Func<NatsOpts, NatsOpts> AddKeyedNatsClient(IHostApplicationBuilder, string, Func<IServiceProvider, NatsOpts, NatsOpts>) Section titled AddKeyedNatsClient(IHostApplicationBuilder, string, Func<IServiceProvider, NatsOpts, NatsOpts>)extensionpublic static class AspireNatsClientExtensions{ public static void AddKeyedNatsClient( this IHostApplicationBuilder builder, string name, Func<IServiceProvider, NatsOpts, NatsOpts>? configureOptions) { // ... }}Parameters
builderIHostApplicationBuilder namestringconfigureOptions Func<IServiceProvider, NatsOpts, NatsOpts> AddKeyedNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>, Func<NatsOpts, NatsOpts>) Section titled AddKeyedNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>, Func<NatsOpts, NatsOpts>)extensionpublic static class AspireNatsClientExtensions{ public static void AddKeyedNatsClient( this IHostApplicationBuilder builder, string name, Action<NatsClientSettings>? configureSettings, Func<NatsOpts, NatsOpts>? configureOptions) { // ... }}Parameters
builderIHostApplicationBuilder namestringconfigureSettings Action<NatsClientSettings> configureOptions Func<NatsOpts, NatsOpts> AddKeyedNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>, Func<IServiceProvider, NatsOpts, NatsOpts>) Section titled AddKeyedNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>, Func<IServiceProvider, NatsOpts, NatsOpts>)extension Registers
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 class AspireNatsClientExtensions{ public static void AddKeyedNatsClient( this IHostApplicationBuilder builder, string name, Action<NatsClientSettings>? configureSettings, Func<IServiceProvider, NatsOpts, NatsOpts>? configureOptions) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.namestringThe name of the component, which is used as the ServiceDescriptor.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<IServiceProvider, NatsOpts, NatsOpts> An optional delegate that can be used for customizing NATS options that aren't exposed as standard configuration.Exceptions
ArgumentNullExceptionThrown when builder or name is null.ArgumentExceptionThrown if mandatory name is empty.InvalidOperationExceptionThrown when mandatory NatsClientSettings.ConnectionString is not provided.AddNatsClient(IHostApplicationBuilder, string) Section titled AddNatsClient(IHostApplicationBuilder, string)extensionpublic static class AspireNatsClientExtensions{ public static void AddNatsClient( this IHostApplicationBuilder builder, string connectionName) { // ... }}Parameters
builderIHostApplicationBuilder connectionName stringAddNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>) Section titled AddNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>)extensionpublic static class AspireNatsClientExtensions{ public static void AddNatsClient( this IHostApplicationBuilder builder, string connectionName, Action<NatsClientSettings>? configureSettings) { // ... }}Parameters
builderIHostApplicationBuilder connectionName stringconfigureSettings Action<NatsClientSettings> AddNatsClient(IHostApplicationBuilder, string, Func<NatsOpts, NatsOpts>) Section titled AddNatsClient(IHostApplicationBuilder, string, Func<NatsOpts, NatsOpts>)extensionpublic static class AspireNatsClientExtensions{ public static void AddNatsClient( this IHostApplicationBuilder builder, string connectionName, Func<NatsOpts, NatsOpts>? configureOptions) { // ... }}Parameters
builderIHostApplicationBuilder connectionName stringconfigureOptions Func<NatsOpts, NatsOpts> AddNatsClient(IHostApplicationBuilder, string, Func<IServiceProvider, NatsOpts, NatsOpts>) Section titled AddNatsClient(IHostApplicationBuilder, string, Func<IServiceProvider, NatsOpts, NatsOpts>)extensionpublic static class AspireNatsClientExtensions{ public static void AddNatsClient( this IHostApplicationBuilder builder, string connectionName, Func<IServiceProvider, NatsOpts, NatsOpts>? configureOptions) { // ... }}Parameters
builderIHostApplicationBuilder connectionName stringconfigureOptions Func<IServiceProvider, NatsOpts, NatsOpts> AddNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>, Func<NatsOpts, NatsOpts>) Section titled AddNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>, Func<NatsOpts, NatsOpts>)extensionpublic static class AspireNatsClientExtensions{ public static void AddNatsClient( this IHostApplicationBuilder builder, string connectionName, Action<NatsClientSettings>? configureSettings, Func<NatsOpts, NatsOpts>? configureOptions) { // ... }}Parameters
builderIHostApplicationBuilder connectionName stringconfigureSettings Action<NatsClientSettings> configureOptions Func<NatsOpts, NatsOpts> AddNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>, Func<IServiceProvider, NatsOpts, NatsOpts>) Section titled AddNatsClient(IHostApplicationBuilder, string, Action<NatsClientSettings>, Func<IServiceProvider, NatsOpts, NatsOpts>)extension Registers
Core.INatsConnection service for connecting NATS server with NATS client. Configures health check and logging for the NATS client. public static class AspireNatsClientExtensions{ public static void AddNatsClient( this IHostApplicationBuilder builder, string connectionName, Action<NatsClientSettings>? configureSettings, Func<IServiceProvider, NatsOpts, NatsOpts>? configureOptions) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.connectionName stringA name used 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<IServiceProvider, NatsOpts, NatsOpts> An optional delegate that can be used for customizing NATS options that aren't exposed as standard configuration.Exceptions
ArgumentNullExceptionThrown if mandatory builder is null.InvalidOperationExceptionThrown when mandatory NatsClientSettings.ConnectionString is not provided.AddNatsJetStream(IHostApplicationBuilder) Section titled AddNatsJetStream(IHostApplicationBuilder)extension Registers
JetStream.INatsJSContext service for NATS JetStream operations. public static class AspireNatsClientExtensions{ public static void AddNatsJetStream( this IHostApplicationBuilder builder) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.Exceptions
ArgumentNullExceptionThrown if mandatory builder is null.