NatsBuilderExtensions Methods
ClassMethods6 members
Provides extension methods for adding NATS resources to the application model.
AddNats(IDistributedApplicationBuilder, string, int?)Section titled AddNats(IDistributedApplicationBuilder, string, int?)extensionIResourceBuilder<NatsServerResource> Adds a NATS server resource to the application model. A container is used for local development. This configures a default user name and password for the NATS server.
public static class NatsBuilderExtensions{ public static IResourceBuilder<NatsServerResource> AddNats( this IDistributedApplicationBuilder builder, string name, int? port) { // ... }}Parameters
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder.namestringThe name of the resource. This name will be used as the connection string name when referenced in a dependency.portint?The host port for NATS server.Returns
IResourceBuilder<NatsServerResource>The ApplicationModel.IResourceBuilder`1.Remarks
This version of the package defaults to the tag of the container image.
AddNats(IDistributedApplicationBuilder, string, int?, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)Section titled AddNats(IDistributedApplicationBuilder, string, int?, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)extensionIResourceBuilder<NatsServerResource> Adds a NATS server resource to the application model. A container is used for local development.
public static class NatsBuilderExtensions{ public static IResourceBuilder<NatsServerResource> AddNats( this IDistributedApplicationBuilder builder, string name, int? port = null, IResourceBuilder<ParameterResource>? userName = null, IResourceBuilder<ParameterResource>? password = null) { // ... }}Parameters
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder.namestringThe name of the resource. This name will be used as the connection string name when referenced in a dependency.portint?optionalThe host port for NATS server.userNameIResourceBuilder<ParameterResource>optionalThe parameter used to provide the user name for the NATS resource. If null a default value will be used.passwordIResourceBuilder<ParameterResource>optionalThe parameter used to provide the administrator password for the NATS resource. If null a random password will be generated.Returns
IResourceBuilder<NatsServerResource>The ApplicationModel.IResourceBuilder`1.Remarks
This version of the package defaults to the tag of the container image.
WithDataBindMount(IResourceBuilder<NatsServerResource>, string, bool)Section titled WithDataBindMount(IResourceBuilder<NatsServerResource>, string, bool)extensionIResourceBuilder<NatsServerResource> Adds a bind mount for the data folder to a NATS container resource.
public static class NatsBuilderExtensions{ public static IResourceBuilder<NatsServerResource> WithDataBindMount( this IResourceBuilder<NatsServerResource> builder, string source, bool isReadOnly = false) { // ... }}Parameters
builderIResourceBuilder<NatsServerResource>The resource builder.sourcestringThe source directory on the host to mount into the container.isReadOnlybooloptionalA flag that indicates if this is a read-only mount.Returns
IResourceBuilder<NatsServerResource>The ApplicationModel.IResourceBuilder`1.WithDataVolume(IResourceBuilder<NatsServerResource>, string?, bool)Section titled WithDataVolume(IResourceBuilder<NatsServerResource>, string?, bool)extensionIResourceBuilder<NatsServerResource> Adds a named volume for the data folder to a NATS container resource.
public static class NatsBuilderExtensions{ public static IResourceBuilder<NatsServerResource> WithDataVolume( this IResourceBuilder<NatsServerResource> builder, string? name = null, bool isReadOnly = false) { // ... }}Parameters
builderIResourceBuilder<NatsServerResource>The resource builder.namestring?optionalThe name of the volume. Defaults to an auto-generated name based on the application and resource names.isReadOnlybooloptionalA flag that indicates if this is a read-only volume.Returns
IResourceBuilder<NatsServerResource>The ApplicationModel.IResourceBuilder`1.WithJetStream(IResourceBuilder<NatsServerResource>, string?)Section titled WithJetStream(IResourceBuilder<NatsServerResource>, string?)extensionIResourceBuilder<NatsServerResource> Adds JetStream support to the NATS server resource.
public static class NatsBuilderExtensions{ public static IResourceBuilder<NatsServerResource> WithJetStream( this IResourceBuilder<NatsServerResource> builder, string? srcMountPath = null) { // ... }}Parameters
builderIResourceBuilder<NatsServerResource>The resource builder.srcMountPathstring?optionalOptional mount path providing persistence between restarts.Returns
IResourceBuilder<NatsServerResource>The ApplicationModel.IResourceBuilder`1.WithJetStream(IResourceBuilder<NatsServerResource>)Section titled WithJetStream(IResourceBuilder<NatsServerResource>)extensionIResourceBuilder<NatsServerResource> Adds JetStream support to the NATS server resource.
public static class NatsBuilderExtensions{ public static IResourceBuilder<NatsServerResource> WithJetStream( this IResourceBuilder<NatsServerResource> builder) { // ... }}Parameters
builderIResourceBuilder<NatsServerResource>The resource builder.Returns
IResourceBuilder<NatsServerResource>The ApplicationModel.IResourceBuilder`1.