Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/billowdev/go-repo-transactor-repo-pattern
π€© (Suitable for Hexagonal) Transactor Repository (TransactorRepo)
https://github.com/billowdev/go-repo-transactor-repo-pattern
Last synced: 3 days ago
JSON representation
π€© (Suitable for Hexagonal) Transactor Repository (TransactorRepo)
- Host: GitHub
- URL: https://github.com/billowdev/go-repo-transactor-repo-pattern
- Owner: billowdev
- Created: 2024-09-07T15:18:03.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-11-03T11:10:53.000Z (2 months ago)
- Last Synced: 2024-11-03T12:18:34.022Z (2 months ago)
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-repo-transactor-repo-pattern
Transactor Repository (TransactorRepo)## Transactor Repository (TransactorRepo)
In this approach, you define a TransactorRepo that provides a transaction context that can be passed to multiple repositories. The transaction is managed at the service level.`Pros`:
- Loose Coupling: Keeps repositories independent from each other. The transaction management is handled separately, allowing repositories to remain focused on their own responsibilities.
- Flexibility: Easily extendable to support more repositories without modifying existing ones.
Testability: Easier to test individual repositories independently, as they don't depend on each other.`Cons`:
- Complexity: Slightly more complex as it requires managing transaction context explicitly in the service layer.
- Potential for Misuse: Requires careful management of transaction context to ensure it's passed correctly between repositories, which can be error-prone.`Best Practice`:
- This approach is a good fit for a Hexagonal Architecture as it aligns well with dependency injection and separation of concerns. It allows you to inject the TransactorRepo into your service layer, making it flexible and scalable.
- Itβs suitable for more complex systems where multiple repositories need to be part of a transaction but should remain loosely coupled.