Skip to content

feat(postgres): add TransactionAwareAggregateRepository for unit-of-work pattern - #369

Merged
iitsdani merged 2 commits into
mainfrom
feat/transaction-aware-aggregate-repository
Oct 2, 2026
Merged

iitsdani merged 2 commits into
mainfrom
feat/transaction-aware-aggregate-repository

Conversation

@iitsdani

@iitsdani iitsdani commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

This PR adds TransactionAwareAggregateRepository to postgres package, for caller-owned transactions (e.g. Unit of Work pattern).

TransactionAwareAggregateRepository implements aggregate.Repository without requiring a connection pool.
Instead, it expects a pgx.Tx be injected into context, and requires specifying the function to fetch the pgx.Tx from context.

repository := postgres.NewTransactionAwareAggregateRepository(
    unitofwork.TxFromContext,
    AggregateType,
    aggregateSerde,
    messageSerde,
    postgres.WithAggregateTableName[ID, *Root]("aggregates"),
)

@iitsdani
iitsdani enabled auto-merge (squash) October 2, 2026 09:00
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.18%. Comparing base (09cfa5e) to head (9cd0aa4).

Files with missing lines Patch % Lines
postgres/aggregate_repository.go 91.66% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #369      +/-   ##
==========================================
+ Coverage   81.73%   88.18%   +6.45%     
==========================================
  Files          37       36       -1     
  Lines        1177     1041     -136     
==========================================
- Hits          962      918      -44     
+ Misses        151      123      -28     
+ Partials       64        0      -64     

☔ View full report in Codecov by Harness.
📢 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.

@iitsdani
iitsdani force-pushed the feat/transaction-aware-aggregate-repository branch from f96b358 to 9cd0aa4 Compare October 2, 2026 09:45
@iitsdani
iitsdani merged commit bf021ca into main Oct 2, 2026
9 checks passed
@iitsdani
iitsdani deleted the feat/transaction-aware-aggregate-repository branch October 2, 2026 09:49
@github-actions github-actions Bot mentioned this pull request Sep 8, 2026
iitsdani pushed a commit that referenced this pull request Oct 2, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>0.4.4</summary>

##
[0.4.4](v0.4.3...v0.4.4)
(2026-10-02)


### Features

* **postgres:** add TransactionAwareAggregateRepository for unit-of-work
pattern
([#369](#369))
([bf021ca](bf021ca))


### Bug Fixes

* **deps:** update all non-major dependencies
([#363](#363))
([23ab466](23ab466))
* **deps:** update all non-major dependencies to v1.46.0
([#361](#361))
([4222124](4222124))
* **deps:** update google.golang.org/genproto digest to f8649dd
([#358](#358))
([09cfa5e](09cfa5e))
* **deps:** update module github.com/jackc/pgx/v5 to v5.11.0
([#362](#362))
([e7788f8](e7788f8))
* **deps:** update module github.com/stretchr/testify to v1.12.1
([#359](#359))
([a88a5fc](a88a5fc))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant