EnvelopeFlow.Throttling.Stores.Postgres
0.1.0-alpha.3.1
dotnet add package EnvelopeFlow.Throttling.Stores.Postgres --version 0.1.0-alpha.3.1
NuGet\Install-Package EnvelopeFlow.Throttling.Stores.Postgres -Version 0.1.0-alpha.3.1
<PackageReference Include="EnvelopeFlow.Throttling.Stores.Postgres" Version="0.1.0-alpha.3.1" />
<PackageVersion Include="EnvelopeFlow.Throttling.Stores.Postgres" Version="0.1.0-alpha.3.1" />
<PackageReference Include="EnvelopeFlow.Throttling.Stores.Postgres" />
paket add EnvelopeFlow.Throttling.Stores.Postgres --version 0.1.0-alpha.3.1
#r "nuget: EnvelopeFlow.Throttling.Stores.Postgres, 0.1.0-alpha.3.1"
#:package EnvelopeFlow.Throttling.Stores.Postgres@0.1.0-alpha.3.1
#addin nuget:?package=EnvelopeFlow.Throttling.Stores.Postgres&version=0.1.0-alpha.3.1&prerelease
#tool nuget:?package=EnvelopeFlow.Throttling.Stores.Postgres&version=0.1.0-alpha.3.1&prerelease
EnvelopeFlow.Throttling.Stores.Postgres
The six-argument admission overload accepts an optional same-data-source IPostgresSubmissionConstraint. It locks/checks the extra constraint before delivery and recipient-policy locks and retains those locks through the final transaction commit. Optional bounce destination availability uses this seam; separately committed preflights cannot substitute. Different-data-source constraints are rejected during construction, and existing constructor signatures remain available.
PostgresProviderBudgetStore persists small version-two account headers and indexed permit/waiter rows using the application's NpgsqlDataSource. Admission and completion load active permits, the current attempt and the bounded live waiter queue; completed historical permits are paged separately. Retained counts and serialized byte costs preserve account capacity without deserializing that history. Store clocks, missing-row advisory locks and transactions serialize account updates across independent clients. Exact stored scope/provider/account columns are checked against their SHA-256 key. Missing required, malformed, oversized or future ledger data fails closed without provider I/O.
Explicit deployment InitializeAsync applies the checksummed PostgresProviderBudgetMigrations.Catalog, then converts legacy version-one ledgers one account per atomic transaction. Cancellation or failure rolls back that account and initialization can resume. The conversion preserves revision, usage, cooldown, waiters, permit fences and uncertain ownership. Version-two headers reject older writers through both the reader version check and database constraint; deploy readers/writers together and complete initialization before workers start. Construction and worker startup perform no DDL or automatic conversion. Inspection uses read-only snapshots and never rewrites a header. Cleanup uses indexed completion times with a bounded page and retains every Started/Unknown permit.
PostgresProviderSubmissionAdmission requires the exact same data-source instance as its IPostgresSubmissionStore and optional PostgresRecipientPolicyStore. Supplied ordinary and routed delivery stores participate through a same-transaction begin operation, retaining route hop/attempt/cost/age checks. Arbitrary custom/separate-database stores are refused unless they supply a conforming participant; a sequential spending guard is insufficient.
One transaction locks the budget, begins the current delivery/routing claim, verifies its full persisted context, reserves current recipient policy and rechecks database-time eligibility before writing the permit. Policy/rate/claim refusal rolls back begin and frequency; a routed terminal budget stop can still commit its existing evidence without spending policy/provider capacity. Network submission occurs only after the transaction commits. Lost begin acknowledgment leaves a recoverable Submitting/Unknown delivery and an occupied permit, never permission to repeat a call automatically.
Each committed start retains its connection with a random session advisory owner lock, without an open transaction during provider I/O. Result recording commits the outcome and monotonic cooldown before releasing that owner. A failed result write closes/releases the owner while preserving the delivery's actual result; a dead worker loses its owner when PostgreSQL detects session termination. Any Started permit without its owner quarantines the entire account, including spare concurrent slots, until the original result is successfully recorded or an owner-authorized fenced reconciliation resolves it. A recorded Unknown keeps its occupied slot. Reconciliation requires external evidence that the request ended and any provider cooldown was honored; the fixed audit reason cannot prove either fact or authorize replay.
Use await using for PostgresProviderSubmissionAdmission. It requires stable backend session affinity: Npgsql multiplexing and transaction-pooling proxies are unsupported. Pooling needs at least two connections. Supplied admission instances sharing the exact data source bound retained owners to Maximum Pool Size - 1, leaving transactional capacity for completion; unpooled sources bound owners to 1000. Size the pool for in-flight provider requests plus application work. Owner locks use PostgreSQL's advisory lock functions and database-local lock metadata; database/session availability and disconnect detection govern recovery. No heartbeat expiry automatically releases provider accounting.
Owner-capacity refusal samples the participating database clock through the reserved transactional capacity, with caller cancellation and a 30-second bound. It never waits for an owner permit or provider completion, takes an account lock, or substitutes the host's wall clock for a database-owned expiry/retry decision. Cancellation or clock-read failure publishes no begin, cost, permit or frequency reservation; the transient query releases its connection for completion.
Owner-only bounded inspection and explicit reconciliation preserve unresolved starts. Result recording uses its opaque original receipt, not a newly resolved account, so configuration changes cannot redirect accounting. Retention, capacity and priority semantics match the development adapter; global database provisioning, access, encryption, backups and operator authorization remain application responsibilities. Ledger writes are bounded to 32 MiB and operations to 30 seconds. Local separate-client/process tests establish atomicity and restart behavior; they do not certify external delivery, HA or production throughput.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- EnvelopeFlow.Preferences.Stores.Postgres (>= 0.1.0-alpha.3.1)
- EnvelopeFlow.Stores.Migrations.Postgres (>= 0.1.0-alpha.3.1)
- EnvelopeFlow.Stores.Postgres (>= 0.1.0-alpha.3.1)
- EnvelopeFlow.Throttling (>= 0.1.0-alpha.3.1)
- Npgsql (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-alpha.3.1 | 43 | 11/22/2026 |
| 0.1.0-alpha.2.1 | 61 | 11/9/2026 |