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
builderIHostApplicationBuildernamestringAddKeyedNatsClient(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
builderIHostApplicationBuildernamestringconfigureSettingsAction<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
builderIHostApplicationBuildernamestringconfigureOptionsFunc<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
builderIHostApplicationBuildernamestringconfigureOptionsFunc<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
builderIHostApplicationBuildernamestringconfigureSettingsAction<NatsClientSettings>configureOptionsFunc<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
builderIHostApplicationBuilderThe 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.configureSettingsAction<NatsClientSettings>An optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.configureOptionsFunc<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
builderIHostApplicationBuilderconnectionNamestringAddNatsClient(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
builderIHostApplicationBuilderconnectionNamestringconfigureSettingsAction<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
builderIHostApplicationBuilderconnectionNamestringconfigureOptionsFunc<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
builderIHostApplicationBuilderconnectionNamestringconfigureOptionsFunc<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
builderIHostApplicationBuilderconnectionNamestringconfigureSettingsAction<NatsClientSettings>configureOptionsFunc<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
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.connectionNamestringA name used to retrieve the connection string from the ConnectionStrings configuration section.configureSettingsAction<NatsClientSettings>An optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.configureOptionsFunc<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
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.Exceptions
ArgumentNullExceptionThrown if mandatory builder is null.