kamiazya/scopes
Add Konsist rule to ensure TransactionManager rollback on Either.Left
开放
#182 创建于 2025年9月2日
hacktoberfest
仓库指标
- 星标
- (2 个星标)
- PR 合并指标
- (PR 指标待抓取)
描述
Context
Currently, TransactionManagerAdapter delegates blindly to the platform TransactionManager. When a transactional block returns Either.Left (indicating an error), the transaction is not automatically rolled back.
Problem
This can lead to partial commits when operations fail, violating transactional consistency.
Suggested Solution
- Update
TransactionManagerAdapterto mark transactions for rollback when the block returnsEither.Left:
override suspend fun <E, T> inTransaction(block: suspend () -> Either<E, T>): Either<E, T> =
platformTransactionManager.inTransaction {
val result = block()
if (result.isLeft()) markForRollback()
result
}
-
Add a Konsist test to ensure all TransactionManager implementations follow this pattern
-
Add integration tests to verify rollback behavior
Benefits
- Ensures transactional consistency
- Prevents partial commits on errors
- Makes error handling more predictable
Related
- PR #165 (Context View feature)
- TransactionManagementTest.kt
- Suggested by AI review