python-dependency-injector icon indicating copy to clipboard operation
python-dependency-injector copied to clipboard

How to manage rollback when need to call two repository method from a service

Open MahmudulHassan5809 opened this issue 2 years ago • 0 comments

Here suppose deposit updated successfully but user balance not updated because of error. in that case how to rollback

def status_change(self,id: int, entity: DepositUpdate) -> Deposit:
    # first call the deposit repository 
    self._deposit_repository.update(id, entity)

    # then call user repository to update balance
    self._user_repository.update(id, amount)


Framework : FastAPI DB : postgres ORM : sqlalchemy

MahmudulHassan5809 avatar Jul 31 '22 09:07 MahmudulHassan5809