"""Transaction Manager interface for managing database transactions. This module defines the abstract interface for transaction management. Implementations control transaction boundaries for use cases. """ from abc import ABC, abstractmethod class TransactionManager(ABC): """Abstract Transaction Manager for controlling transaction boundaries. Provides interface for committing or rolling back database transactions. Used by use cases to manage atomic operations. Example: >>> async with transaction_manager: ... await repository.add(entity) ... await transaction_manager.commit() """ @abstractmethod async def commit(self) -> None: """Commit the current transaction. Persists all pending changes to the database. Should be called after all operations succeed. """ ... @abstractmethod async def rollback(self) -> None: """Rollback the current transaction. Discards all pending changes. Should be called when an error occurs. """ ...