Skip to content
Tracon

TraconPostgreSqlBuilderExtensions

Namespace Tracon · Assembly Tracon.PostgreSql.dll

Extensions that add PostgreSQL persistence to the Tracon chain.

public static class TraconPostgreSqlBuilderExtensions

objectTraconPostgreSqlBuilderExtensions

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Enables PostgreSQL persistence given a connection string.

public static ITraconBuilder UsePostgreSql(this ITraconBuilder builder, string connectionString)

builder ITraconBuilder

The Tracon chain.

connectionString string

The PostgreSQL connection string.

ITraconBuilder

The continuation of the chain.

The schema is created and migrated at startup; no separate migration step is needed.

builder.AddTracon()
.UseOpenAI(builder.Configuration["OpenAI:ApiKey"]!)
.UsePostgreSql(builder.Configuration.GetConnectionString("Tracon")!);

ArgumentNullException

builder is null.

ArgumentException

connectionString is empty.

UsePostgreSql(ITraconBuilder, IConfiguration)

Section titled “ UsePostgreSql(ITraconBuilder, IConfiguration)”

Enables PostgreSQL persistence, reading settings from the Tracon:PostgreSql section.

public static ITraconBuilder UsePostgreSql(this ITraconBuilder builder, IConfiguration configurationSection)

builder ITraconBuilder

The Tracon chain.

configurationSection IConfiguration

The section settings are read from. Usually configuration.GetSection(TraconPostgreSqlOptions.SectionName).

ITraconBuilder

The continuation of the chain.

ArgumentNullException

One of the parameters is null.

UsePostgreSql(ITraconBuilder, Action<TraconPostgreSqlOptions>)

Section titled “ UsePostgreSql(ITraconBuilder, Action<TraconPostgreSqlOptions>)”

Enables PostgreSQL persistence with settings given in code.

public static ITraconBuilder UsePostgreSql(this ITraconBuilder builder, Action<TraconPostgreSqlOptions> configure)

builder ITraconBuilder

The Tracon chain.

configure Action<TraconPostgreSqlOptions>

The settings mutator.

ITraconBuilder

The continuation of the chain.

Stores are registered with ServiceCollectionDescriptorExtensions.Replace, not TryAdd. AddTracon has already registered the in-memory stores with TryAddSingleton and runs before this call in the chain; using TryAdd here would silently do nothing.

Overwriting is correct here because UsePostgreSql is the consumer’s explicit choice. The “register with TryAdd” rule is for Tracon’s defaults, not for explicit calls.

ArgumentNullException

One of the parameters is null.