Interface IPostgresOutboxBuilder
Fluent builder interface for configuring Postgres-specific outbox settings.
public interface IPostgresOutboxBuilder
- Extension Methods
Examples
outbox.UsePostgres(postgres =>
{
postgres.ConnectionString(connectionString)
.SchemaName("messaging")
.TableName("outbox_messages")
.CommandTimeout(TimeSpan.FromSeconds(60))
.ReservationTimeout(TimeSpan.FromMinutes(5));
});
Remarks
This builder configures Postgres-specific options such as table names, schema,
command timeouts, and reservation behavior.
All methods return this for method chaining.
Methods
BindConfiguration(string)
Binds options from an IConfiguration section.
IPostgresOutboxBuilder BindConfiguration(string sectionPath)
Parameters
sectionPathstringThe configuration section path.
Returns
- IPostgresOutboxBuilder
The builder for fluent chaining.
ConnectionFactory(Func<IServiceProvider, IDb>)
Sets a factory function that provides an IDb instance.
IPostgresOutboxBuilder ConnectionFactory(Func<IServiceProvider, IDb> dbFactory)
Parameters
dbFactoryFunc<IServiceProvider, IDb>A factory function that provides an IDb instance.
Returns
- IPostgresOutboxBuilder
The builder for fluent chaining.
Remarks
Use this for advanced scenarios like multi-database setups, custom connection pooling, or IDb integration. Mutually exclusive with ConnectionString(string). The last one set wins.
Exceptions
- ArgumentNullException
Thrown when
dbFactoryis null.
ConnectionString(string)
Sets the connection string for the Postgres outbox database.
IPostgresOutboxBuilder ConnectionString(string connectionString)
Parameters
connectionStringstringThe Postgres connection string.
Returns
- IPostgresOutboxBuilder
The builder for fluent chaining.
Remarks
This is the recommended way to provide a connection string for the outbox store. Mutually exclusive with ConnectionFactory(Func<IServiceProvider, IDb>). The last one set wins.
Exceptions
- ArgumentException
Thrown when
connectionStringis null, empty, or whitespace.
ConnectionStringName(string)
Resolves the connection string from IConfiguration.GetConnectionString(name).
IPostgresOutboxBuilder ConnectionStringName(string name)
Parameters
namestringThe connection string name.
Returns
- IPostgresOutboxBuilder
The builder for fluent chaining.
DataSource(NpgsqlDataSource)
Sets a pre-configured Npgsql.NpgsqlDataSource directly.
IPostgresOutboxBuilder DataSource(NpgsqlDataSource dataSource)
Parameters
dataSourceNpgsqlDataSourceThe Npgsql data source.
Returns
- IPostgresOutboxBuilder
The builder for fluent chaining.
Remarks
The source is borrowed and remains owned by the caller.
DataSourceFactory(Func<IServiceProvider, NpgsqlDataSource>)
Sets a factory function that creates an Npgsql.NpgsqlDataSource.
IPostgresOutboxBuilder DataSourceFactory(Func<IServiceProvider, NpgsqlDataSource> dataSourceFactory)
Parameters
dataSourceFactoryFunc<IServiceProvider, NpgsqlDataSource>A factory receiving IServiceProvider and returning an Npgsql.NpgsqlDataSource.
Returns
- IPostgresOutboxBuilder
The builder for fluent chaining.
Remarks
The factory must create a source exclusively for this outbox registration. The container owns and disposes that source. Use DataSource(NpgsqlDataSource) to borrow a source shared with other services.
DeadLetterTableName(string)
Sets the table name for storing dead letter messages.
IPostgresOutboxBuilder DeadLetterTableName(string tableName)
Parameters
tableNamestringThe table name for dead letters.
Returns
- IPostgresOutboxBuilder
The builder for fluent chaining.
Remarks
Default is "outbox_dead_letters".
Exceptions
- ArgumentException
Thrown when
tableNameis null, empty, or whitespace.
SchemaName(string)
Sets the schema name for the outbox tables.
IPostgresOutboxBuilder SchemaName(string schema)
Parameters
schemastringThe schema name (e.g., "public", "messaging").
Returns
- IPostgresOutboxBuilder
The builder for fluent chaining.
Remarks
Default is "public". Use this to organize outbox tables in a specific schema.
Exceptions
- ArgumentException
Thrown when
schemais null, empty, or whitespace.
TableName(string)
Sets the table name for storing outbox messages.
IPostgresOutboxBuilder TableName(string tableName)
Parameters
tableNamestringThe table name.
Returns
- IPostgresOutboxBuilder
The builder for fluent chaining.
Remarks
Default is "outbox".
Exceptions
- ArgumentException
Thrown when
tableNameis null, empty, or whitespace.