Add commit and rollback functionality for transactions#21
Conversation
…ctions - implement commit and rollback methods in TransactionService interface - create TransactionRpcService for handling transaction lifecycle operations - add TransactionState enum to manage transaction states - introduce TransactionLifecycle for managing transaction state transitions - create PendingTransactions object for shared configuration of pending transactions
… pending execution results - introduce transactionOrNull property to retrieve associated transaction or null - add valueOrNull property to get the result value or null based on execution outcome - implement isCompleted property to check if the transaction reached a committed state
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1f844aa49
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| require(transactions.isNotEmpty()) { "Cannot write an empty transaction list" } | ||
|
|
||
| val context = writeContext(transactions) ?: return UnknownAccountOrCurrency | ||
| val expiresAt = timeoutMillis?.let(context.now::plusMillis) |
There was a problem hiding this comment.
Reject timeouts that overflow Instant
When a caller passes a very large but finite positive Duration, the client accepts it as a millisecond value and the microservice reaches this plusMillis call; if the resulting expiration is outside Instant's range, Instant.plusMillis throws instead of returning PendingTransactionResult.InvalidTimeout. This makes oversized pending reservations fail as an RPC/service exception even though the public timeout contract says invalid durations are reported as typed reservation failures.
Useful? React with 👍 / 👎.
Database Migration required
This pull request introduces a comprehensive, durable pending transaction system to the financial microservice, enabling explicit commit, rollback, and expiration semantics for transactions. It adds new API types and methods to support pending reservations, extends the database schema to track transaction state and expiration, and documents the new workflows and their concurrency, timeout, and error handling behaviors.
Pending Transaction Lifecycle and API Enhancements:
commit,rollback,refresh) and result types (TransactionCommitResult,TransactionRollbackResult,PendingTransactionResult). [1] [2] [3] [4] [5] [6] [7]PendingReservationTimeoutException, to handle indeterminate reservation outcomes and support reconciliation by transaction identifier.PendingTransactionsconfiguration object with a default timeout for pending reservations.Database Schema Changes:
transactionstable with new columns forstate,expires_at,operation_id, andignore_minimum_amount, added relevant indexes, and introduced constraints to ensure pending transactions have expiration and operation IDs.Documentation Updates:
README.mdto explain the new pending transaction workflows, including the convenience and explicit lifecycle APIs, balance semantics, concurrency, and failure handling strategies. [1] [2]These changes collectively provide robust support for external operations that require atomic reservation, commit, or rollback of funds, improving reliability and auditability of financial workflows.