methodConfigureRlsLockedBySchema
public PostgreSqlStorageOptions ConfigureRlsLockedBySchema(string? claimPendingFunction = null, string? completeMessageFunction = null, string? failMessageFunction = null, string? tenantInsertFallbackSqlFunction = "")
Configures the storage options for a `FORCE ROW LEVEL SECURITY` multi-tenant PostgreSQL schema using `locked_by VARCHAR`, `locked_until TIMESTAMPTZ`, and `company_id UUID`.
- claimPendingFunction: string?
- Optional `SECURITY DEFINER` claim function (e.g., `outbox.claim_pending_messages`).
- completeMessageFunction: string?
- Optional `SECURITY DEFINER` per-message completion function (e.g., `outbox.complete_outbox_message`).
- failMessageFunction: string?
- Optional `SECURITY DEFINER` per-message failure function (e.g., `outbox.fail_outbox_message`).
- tenantInsertFallbackSqlFunction: string?
- Optional SQL function fallback for `company_id` on insert (e.g., `core.current_company_id()`).
Retorna: This `PostgreSqlStorageOptions` instance for chaining.
propertyAdditionalSessionContextSettingNames
public IReadOnlyList<string> AdditionalSessionContextSettingNames { get; set; }
Gets or sets additional PostgreSQL session setting names to populate alongside `SessionContextSettingName` during multi-tenant RLS context propagation (e.g., `app.current_tenant_id`, `app.current_tenant`).
propertyClaimPendingFunctionName
public string? ClaimPendingFunctionName { get; set; }
Gets or sets an optional schema-qualified `SECURITY DEFINER` PostgreSQL function name (e.g., `outbox.claim_pending_messages`) invoked with `(@OwnerId, @BatchSize, @LeaseSeconds)` so background workers running as `NOBYPASSRLS` roles (`app_user`) can atomically claim pending messages across tenants under `FORCE ROW LEVEL SECURITY`.
propertyCompanyColumnIsUuid
public bool CompanyColumnIsUuid { get; set; }
Gets or sets whether `CompanyColumnName` is typed as PostgreSQL `UUID`. Default is `true`.
propertyCompanyColumnName
public string CompanyColumnName { get; set; }
Gets or sets the holding company column name when `EnableCompanyColumn` is enabled. Default is `company_id`.
propertyCompanyInsertFallbackSqlFunction
public string? CompanyInsertFallbackSqlFunction { get; set; }
Gets or sets an optional SQL fallback function expression (such as `core.current_company_id()`) for `CompanyColumnName` on insert.
propertyCompleteMessageFunctionName
public string? CompleteMessageFunctionName { get; set; }
Gets or sets an optional schema-qualified `SECURITY DEFINER` PostgreSQL function name (e.g., `outbox.complete_outbox_message`) invoked per completed message inside a single pipelined `NpgsqlBatch` with `(@Id, @OwnerId)`.
propertyCompleteMessagesBatchFunctionName
public string? CompleteMessagesBatchFunctionName { get; set; }
Gets or sets an optional schema-qualified `SECURITY DEFINER` PostgreSQL batch function name (e.g., `outbox.complete_messages`) invoked once per batch with `(@OwnerId, @Ids, @CreatedAts, @DeleteOnDispatch)`.
propertyCustomClaimPendingCallback
public Func<NpgsqlConnection, string, int, TimeSpan, CancellationToken, ValueTask<IReadOnlyList<OutboxMessage>>>? CustomClaimPendingCallback { get; set; }
Gets or sets an optional custom override delegate for claiming pending messages when bespoke stored-function parameter signatures are required.
propertyCustomMarkDispatchedCallback
public Func<NpgsqlConnection, string, IReadOnlyList<OutboxMessage>, CancellationToken, ValueTask>? CustomMarkDispatchedCallback { get; set; }
Gets or sets an optional custom override delegate for marking claimed messages as dispatched.
propertyCustomMarkFailedCallback
public Func<NpgsqlConnection, string, IReadOnlyList<OutboxMessage>, string, bool, CancellationToken, ValueTask>? CustomMarkFailedCallback { get; set; }
Gets or sets an optional custom override delegate for marking claimed messages as failed or dead-lettered.
propertyEnableAtomicDeadLetterTransfer
public bool EnableAtomicDeadLetterTransfer { get; set; }
Gets or sets whether messages exceeding max retries are atomically moved to the dead-letter table. Default is `true`.
propertyEnableCompanyColumn
public bool EnableCompanyColumn { get; set; }
Gets or sets whether the outbox table includes an explicit secondary holding `company_id` column alongside `tenant_id`.
propertyEnableSessionContextPropagation
public bool EnableSessionContextPropagation { get; set; }
Gets or sets whether to automatically propagate the message's tenant and company context during background dispatch. Default is `true`.
propertyEnableTenantColumn
public bool EnableTenantColumn { get; set; }
Gets or sets whether the outbox table includes a dedicated tenant/company column for PostgreSQL Row-Level Security (RLS). Default is `false` for backward compatibility with single-tenant schemas.
propertyFailMessageFunctionName
public string? FailMessageFunctionName { get; set; }
Gets or sets an optional schema-qualified `SECURITY DEFINER` PostgreSQL function name (e.g., `outbox.fail_outbox_message`) invoked per failed message inside a single pipelined `NpgsqlBatch` with `(@Id, @OwnerId, @Error, @IsDeadLetter, @MaxBackoffSeconds)`.
propertyFailMessagesBatchFunctionName
public string? FailMessagesBatchFunctionName { get; set; }
Gets or sets an optional schema-qualified `SECURITY DEFINER` PostgreSQL batch function name (e.g., `outbox.fail_messages`) invoked once per batch with `(@OwnerId, @Ids, @CreatedAts, @State, @Error, @MaxBackoffSeconds)`.
propertyGetPendingCountFunctionName
public string? GetPendingCountFunctionName { get; set; }
Gets or sets an optional schema-qualified `SECURITY DEFINER` PostgreSQL function name (e.g., `outbox.get_pending_count`) invoked with no arguments (or `()`) to count pending messages under `FORCE ROW LEVEL SECURITY`.
propertyLeaseDuration
public TimeSpan LeaseDuration { get; set; }
Gets or sets the lease duration applied when claiming pending messages via `LeaseExpirationColumnName` or `ClaimPendingFunctionName`. Default is 60 seconds.
propertyLeaseExpirationColumnName
public string? LeaseExpirationColumnName { get; set; }
Gets or sets an optional lease-expiration timestamp column name (such as `locked_until`) updated when claiming pending messages and cleared upon completion, failure, or stale lease reclamation.
propertyLockOwnerColumnIsText
public bool LockOwnerColumnIsText { get; set; }
Gets or sets whether `LockOwnerColumnName` is typed as `VARCHAR`/`TEXT` rather than `UUID`. Default is `false` (`UUID`); set `true` when `locked_by` is `VARCHAR(64)`.
propertyLockOwnerColumnName
public string LockOwnerColumnName { get; set; }
Gets or sets the column name used to record the worker instance holding the active dispatch lease (e.g., `owner_id` or `locked_by`). Default is `owner_id` for backward compatibility with canonical `Outbox_DDL.sql`; set to `locked_by` for lease-based RLS schemas.
propertyMaxDeliveryRetries
public int MaxDeliveryRetries { get; set; }
Gets or sets the maximum number of delivery retry attempts before a message is moved to the dead-letter queue. Default is 5 (aligned with enterprise production standard).
propertyMaxInsertBatchChunkSize
public int MaxInsertBatchChunkSize { get; set; }
Gets or sets the maximum number of messages written per PostgreSQL batch statement before automatic chunking. Default is 1,000 rows to stay well under PostgreSQL's 65,535 wire parameter ceiling.
propertyPerMessageDispatchScopeCallback
public Func<OutboxMessage, OutboxMessageMetadata, OutboxDispatchTenantContext, CancellationToken, ValueTask<IDisposable?>>? PerMessageDispatchScopeCallback { get; set; }
Gets or sets an optional per-message ambient scope factory invoked by `PostgreSqlSessionContextMiddleware` to rehydrate application execution context (`TenantId`, `CompanyId`, `ExecutionPlane`) before dispatching each message.
propertyPlaneSessionSettingName
public string PlaneSessionSettingName { get; set; }
Gets or sets the PostgreSQL session setting name used for the multi-plane execution discriminator (`TENANT` vs `CONTROL`). Default is `app.current_plane`.
propertyReclaimStaleFunctionName
public string? ReclaimStaleFunctionName { get; set; }
Gets or sets an optional schema-qualified `SECURITY DEFINER` PostgreSQL function name (e.g., `outbox.reclaim_stale_messages`) invoked with `(@StaleSeconds, @MaxAgeDays, @ReclaimLimit, @MaxRetryCount)` to recover expired leases under `FORCE ROW LEVEL SECURITY`.
propertySessionContextIsLocal
public bool SessionContextIsLocal { get; set; }
Gets or sets whether the session context setting is local to the current transaction. When `true`, executes `set_config(name, value, true)`. Default is `true`.
propertySessionContextSettingName
public string SessionContextSettingName { get; set; }
Gets or sets the name of the PostgreSQL session setting used for tenant/company isolation (RLS). Default is `app.current_company_id`.
propertyTenantColumnIsUuid
public bool TenantColumnIsUuid { get; set; }
Gets or sets whether `TenantColumnName` is typed as PostgreSQL `UUID` rather than `VARCHAR`/`TEXT`. Default is `false` for backward compatibility; set `true` when `company_id` is `UUID`.
propertyTenantColumnName
public string TenantColumnName { get; set; }
Gets or sets the column name in the outbox table used to store the tenant/company identifier when `EnableTenantColumn` is enabled. Default is `company_id`.
propertyTenantInsertFallbackSqlFunction
public string? TenantInsertFallbackSqlFunction { get; set; }
Gets or sets an optional SQL function call expression (such as `core.current_company_id()`) used via `COALESCE(@TenantId, expr)` during transactional `INSERT` / `UNNEST` when `EnableTenantColumn` and `TenantColumnIsUuid` are enabled.
propertyUseSkipLocked
public bool UseSkipLocked { get; set; }
Gets or sets whether to use `FOR UPDATE SKIP LOCKED` during polling to prevent lock contention across multiple consumers. Default is `true`.
propertyWorkerSessionContextCallback
public Func<NpgsqlConnection, NpgsqlTransaction, CancellationToken, ValueTask>? WorkerSessionContextCallback { get; set; }
Gets or sets an optional transaction-scoped session initialization callback executed inside an explicit `NpgsqlTransaction` before background worker repository operations when direct table SQL is used under Row-Level Security.