I was wondering about how this project encapsulate the relational database transaction.
The definition of good repository interface (/internal/app/service/barter/interface.go/GoodRepository) might can't get away from race condition. Before using UpdateGoods, there must be a GetGoodByID somewhere. Since the read and write are not in the same transaction, so the state is not protected by the relational database.
let's have a look at /internal/app/service/barter/exchange_service.go/(*BarterService).ExchangeGoods
- let's say the initial state is...
- a good X belongs to trader A
- a good Y belongs to trader B
- a good Z belongs to trader C
- trader A launch two exchange request XY and XZ

- the final state is...
- a good X belongs to trader C
- a good Y belongs to trader A
- a good Z belongs to trader A
I'm might be wrong because I'm not really execute it. I'm just simulate the execution in my head.
I was wondering about how this project encapsulate the relational database transaction.
The definition of good repository interface (
/internal/app/service/barter/interface.go/GoodRepository) might can't get away from race condition. Before usingUpdateGoods, there must be aGetGoodByIDsomewhere. Since the read and write are not in the same transaction, so the state is not protected by the relational database.let's have a look at
/internal/app/service/barter/exchange_service.go/(*BarterService).ExchangeGoodsI'm might be wrong because I'm not really execute it. I'm just simulate the execution in my head.