Skip to content

feat: Register IEventOutbox as PostgreSqlEventOutbox in AddPostgreSqlOutbox()#370

Merged
samtrion merged 6 commits intomainfrom
copilot/register-ieventoutbox-postgresql
Apr 14, 2026
Merged

feat: Register IEventOutbox as PostgreSqlEventOutbox in AddPostgreSqlOutbox()#370
samtrion merged 6 commits intomainfrom
copilot/register-ieventoutbox-postgresql

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

AddPostgreSqlOutbox() was not registering IEventOutbox, causing apps to fall back to the default OutboxEventStore which opens a separate Npgsql connection instead of sharing the caller's transaction. This mirrors the existing SQL Server pattern.

Changes

New: PostgreSqlEventOutbox

  • public sealed class implementing IEventOutbox directly via ADO.NET
  • Accepts IOptions<OutboxOptions>, TimeProvider, and optional IOutboxTransactionScope
  • Enlists in the active NpgsqlTransaction from IOutboxTransactionScope when present; opens its own connection otherwise

Updated: RegisterPostgreSqlOutboxServices

  • Now calls AddOutbox() then overrides IEventOutbox → PostgreSqlEventOutbox, IOutboxRepository → PostgreSqlOutboxRepository, and IOutboxManagement → PostgreSqlOutboxManagement (same pattern as SQL Server)

New: AddPostgreSqlOutboxTransactionScope<TUnitOfWork>()

  • Convenience extension registering a UoW as IOutboxTransactionScope (Scoped), mirroring AddSqlServerOutboxTransactionScope<TUnitOfWork>()
services.AddPulse(config => config
    .AddPostgreSqlOutbox("Host=localhost;Database=MyDb;Username=postgres;******;")
    .AddPostgreSqlOutboxTransactionScope<MyUnitOfWork>() // IEventOutbox now uses UoW's NpgsqlTransaction
);

Tests

  • Unit Tests:
    • PostgreSqlEventOutboxTests: constructor validation, transaction scope path, StoreAsync argument guards
    • PostgreSqlExtensionsTests: IEventOutbox registration type assertions + AddPostgreSqlOutboxTransactionScope coverage
  • Integration Tests:
    • PostgreSqlAdoNetInitializer: database initializer that loads and executes the PostgreSQL OutboxMessage.sql script
    • PostgreSqlAdoNetOutboxTests: integration test class that inherits from OutboxTestsBase and tests the ADO.NET implementation against a real PostgreSQL container via Testcontainers

Copilot AI linked an issue Apr 13, 2026 that may be closed by this pull request
5 tasks
Copilot AI changed the title [WIP] Register IEventOutbox as PostgreSqlEventOutbox in AddPostgreSqlOutbox feat: Register IEventOutbox as PostgreSqlEventOutbox in AddPostgreSqlOutbox() Apr 13, 2026
Copilot AI requested a review from samtrion April 13, 2026 18:37
@samtrion samtrion force-pushed the copilot/register-ieventoutbox-postgresql branch from 7f926e0 to be431d5 Compare April 13, 2026 18:50
@samtrion samtrion added state:ready for merge Indicates that a pull request has been reviewed and approved, and is ready to be merged into the mai type:feature Indicates a new feature or enhancement to be added. labels Apr 13, 2026
@samtrion samtrion marked this pull request as ready for review April 13, 2026 18:53
@samtrion samtrion requested a review from a team as a code owner April 13, 2026 18:53
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 89.06250% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.28%. Comparing base (7bce6db) to head (d6719f3).

Files with missing lines Patch % Lines
...e.Pulse.PostgreSql/Outbox/PostgreSqlEventOutbox.cs 85.54% 7 Missing and 5 partials ⚠️
...se.PostgreSql/Outbox/PostgreSqlOutboxRepository.cs 94.44% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #370      +/-   ##
==========================================
+ Coverage   84.94%   90.28%   +5.33%     
==========================================
  Files         106      107       +1     
  Lines        3867     3983     +116     
  Branches      353      365      +12     
==========================================
+ Hits         3285     3596     +311     
+ Misses        496      284     -212     
- Partials       86      103      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samtrion
Copy link
Copy Markdown
Contributor

@copilot Also add Integration tests similar to SqlServerAdoNetOutboxTests

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 13, 2026

@copilot Also add Integration tests similar to SqlServerAdoNetOutboxTests

Added PostgreSqlAdoNetOutboxTests integration test class and PostgreSqlAdoNetInitializer in commit 92c0cce. The test class inherits from OutboxTestsBase to run all outbox integration tests against a real PostgreSQL container using the ADO.NET implementation.

@samtrion
Copy link
Copy Markdown
Contributor

@copilot Fix pipeline errors

@samtrion samtrion force-pushed the copilot/register-ieventoutbox-postgresql branch from e42fa2a to c8c9814 Compare April 13, 2026 21:15
Agent-Logs-Url: https://github.com/dailydevops/pulse/sessions/2ae647b9-9902-4001-8aac-4a08c31c9b25

Co-authored-by: samtrion <3283596+samtrion@users.noreply.github.com>
@samtrion samtrion force-pushed the copilot/register-ieventoutbox-postgresql branch from c8c9814 to 02508b6 Compare April 13, 2026 21:25
- Add GetPendingCountAsync and batch update methods to PostgreSqlOutboxRepository for efficient message handling.
- Update SQL functions to accept explicit timestamps and improve retry logic.
- Limit connection pool size and eagerly clear pools in test fixtures to prevent exhausting PostgreSQL connections during parallel tests.
- Raise max_connections in test container to support high parallelism.
- Update verified test output to match new message handling logic.
@samtrion samtrion merged commit fe11cd8 into main Apr 14, 2026
8 of 9 checks passed
@samtrion samtrion deleted the copilot/register-ieventoutbox-postgresql branch April 14, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:ready for merge Indicates that a pull request has been reviewed and approved, and is ready to be merged into the mai type:feature Indicates a new feature or enhancement to be added.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Register IEventOutbox as PostgreSqlEventOutbox in AddPostgreSqlOutbox()

2 participants