FdbAspireHostingExtensions

Namespace: Aspire.Hosting · class

Provides extension methods for adding FoundationDB resources to the application model.

Methods

AddFoundationDb

static IResourceBuilder<FdbClusterResource> AddFoundationDb(IDistributedApplicationBuilder builder, string name, int apiVersion, string root, int? port = null, string clusterVersion = null, FdbVersionPolicy? rollForward = null)

Adds a FoundationDB container to application model.

  • builder — Builder for the distributed application
  • name — Name of the FoundationDB cluster resource (ex: "fdb")
  • apiVersion — API version that is requested by the application
  • root — Root subspace location used by the application, in the cluster keyspace.
  • port — Custom port for the docker container
  • clusterVersion — If not null, specifies the targeted version for the cluster nodes (ex: "7.4.6", "7.3.27", "7.4.", "7.", ...)
  • rollForward — Specifies the policy used to optionally select a more recent version

static IResourceBuilder<FdbClusterResource> AddFoundationDb(IDistributedApplicationBuilder builder, string name, int apiVersion, FdbPath root, int? port = null, string clusterVersion = null, FdbVersionPolicy? rollForward = null, string imageRegistry = null)

Adds a FoundationDB container to application model.

  • builder — Builder for the distributed application
  • name — Name of the FoundationDB cluster resource (ex: "fdb")
  • apiVersion — API version that is requested by the application
  • root — Root subspace location used by the application, in the cluster keyspace.
  • port — The host port to bind the underlying container to (defaults to 4550)
  • clusterVersion — If not null, specifies the targeted version for the cluster nodes (ex: "7.4.6", "7.3.27", "7.4.", "7.", ...)
  • rollForward — Specifies the policy used to optionally select a more recent version
  • imageRegistry — Specifies a custom image registry for the container (defaults to "docker.io")

AddFoundationDbCluster

static IResourceBuilder<FdbConnectionResource> AddFoundationDbCluster(IDistributedApplicationBuilder builder, string name, int apiVersion, string root, string clusterFile = null, string clusterVersion = null)

Adds a connection to an external FoundationDB cluster

  • builder — Builder for the distributed application
  • name — Name of the FoundationDB cluster resource (ex: "fdb")
  • apiVersion — API version that is requested by the application
  • root — Base subspace location used by the application, in the cluster keyspace.
  • clusterFile — Path to the cluster file, or null if the default cluster file should be used.
  • clusterVersion — If not null, the known version of the remote cluster, which can be used to infer the appropriate version of the local FDB client library that should be used to connect to this cluster.

static IResourceBuilder<FdbConnectionResource> AddFoundationDbCluster(IDistributedApplicationBuilder builder, string name, int apiVersion, FdbPath root, string clusterFile = null, string clusterVersion = null)

Adds a connection to an external FoundationDB cluster

  • builder — Builder for the distributed application
  • name — Name of the FoundationDB cluster resource (ex: "fdb")
  • apiVersion — API version that is requested by the application
  • root — Root subspace location used by the application, in the cluster keyspace.
  • clusterFile — Path to the cluster file, or null if the default cluster file should be used.
  • clusterVersion — If not null, the known version of the remote cluster, which can be used to infer the appropriate version of the local FDB client library that should be used to connect to this cluster.

WithAutoProvisioning

static IResourceBuilder<FdbClusterResource> WithAutoProvisioning(IResourceBuilder<FdbClusterResource> builder, bool enabled = true)

Enables or disables the automatic configure new of a database when the container starts on a fresh volume

Enabled by default. See .

WithClusterContents

static IResourceBuilder<FdbConnectionResource> WithClusterContents(IResourceBuilder<FdbConnectionResource> builder, string clusterContents)

Configures the FoundationDB client to use a hardcoded cluster file content

static IResourceBuilder<FdbConnectionResource> WithClusterContents(IResourceBuilder<FdbConnectionResource> builder, string description, string id, params EndPoint[] coordinators)

Configures the FoundationDB client to use a hardcoded cluster file content

WithClusterFile

static IResourceBuilder<FdbConnectionResource> WithClusterFile(IResourceBuilder<FdbConnectionResource> builder, string clusterFile)

Configures the FoundationDB client to use a cluster file at a specific location

WithClusterVersion

static IResourceBuilder<FdbConnectionResource> WithClusterVersion(IResourceBuilder<FdbConnectionResource> builder, string version)

Configures the FoundationDB client to use a specific library version

WithDefaultClusterFile

static IResourceBuilder<FdbConnectionResource> WithDefaultClusterFile(IResourceBuilder<FdbConnectionResource> builder)

Configures the FoundationDB client to use the cluster file at the default location

WithDefaults

static IResourceBuilder<FdbClusterResource> WithDefaults(IResourceBuilder<FdbClusterResource> builder, TimeSpan? timeout = null, int? retryLimit = null, bool? readOnly = null, FdbTracingOptions? tracing = null, string logSessionId = null)

Sets various default configuration options (timeouts, max retry limits, ...) that will be applied to all processes using this resource.

  • builder — FDB cluster builder
  • timeout — Default transaction timeout (or TimeSpan.Zero for infinite timeout)
  • retryLimit — Default transaction max retry limit (or 0 for infinite retries)
  • readOnly — If true, the process will only have read-only access to the FoundationDB cluster.
  • tracing — Default tracing options
  • logSessionId — Default common Log Session Id

These settings will be applied to the default connection options, and can be overriden per transaction, or during the program startup.

WithLogSessionId

static IResourceBuilder<FdbClusterResource> WithLogSessionId(IResourceBuilder<FdbClusterResource> builder, string sessionId)

Sets the Session ID used when logging transactions to this local cluster.

  • builder — FDB cluster builder
  • sessionId — Common Session Identifier used by all transactions logged.

This identifier will be injected, via the connection string, to all resources that reference this cluster, and will be automatically be assigned to all logged transactions.

Once a session has been completed, this identifier could then be used to match conflicting transactions, or to recreate a sensible history of what happened during a specific time window.

WithNativeLibrary

static IResourceBuilder<FdbClusterResource> WithNativeLibrary(IResourceBuilder<FdbClusterResource> builder, string nativeLibraryPath)

Specifies the path to the native FoundationDB C library that should be used by the application

  • builder — FDB cluster builder
  • nativeLibraryPath — Path to the library on the host. The path may be rewritten if required.

This should only be used for local development, or very specific deployments where the application must use a very specific build of the native library.

The file must be present on the host. If a project that references this resource runs inside a Docker image, the path may be rewritten to where the library was copied inside the container image.

WithRandomizedLogSessionId

static IResourceBuilder<FdbClusterResource> WithRandomizedLogSessionId(IResourceBuilder<FdbClusterResource> builder)

Sets the Session ID used when logging transactions to this local cluster to a pseudo-random value.

  • builder — FDB cluster builder

The identifier will be generated using the current time, the hostname and current PID. This will ensure that any log file that will use this identifier should be mostly sorted chronologically.

This identifier will be injected, via the connection string, to all resources that reference this cluster, and will be automatically be assigned to all logged transactions.

Once a session has been completed, this identifier could then be used to match conflicting transactions, or to recreate a sensible history of what happened during a specific time window.

Fields

LatestVersion71

static readonly Version LatestVersion71

Tag for the latest v7.1 docker image

LatestVersion72

static readonly Version LatestVersion72

Tag for the latest v7.2 docker image

LatestVersion73

static readonly Version LatestVersion73

Tag for the latest v7.3 docker image

LatestVersion74

static readonly Version LatestVersion74

Tag for the latest v7.4 docker image