https://github.com/probablyclem/transaction-processing-exercice
https://github.com/probablyclem/transaction-processing-exercice
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/probablyclem/transaction-processing-exercice
- Owner: ProbablyClem
- Created: 2024-08-13T07:22:54.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-14T15:52:29.000Z (almost 2 years ago)
- Last Synced: 2025-01-29T05:28:24.401Z (over 1 year ago)
- Language: Rust
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# transaction-processing-exercice
Made by Clement Guiton
## Toy transaction processing engine
The engine implements all the required cases :
- Deposit
- Withdrawal
- Dispute
- Resolve
- Chargeback
## Usage
The program takes the path of the input file as a argument, and outputs the result in the console.
## Tests
The code is tested all the way through, and the tests can be run with the following command:
```bash
cargo test
```
Tests includes serialization and deserialization of the transactions, file reading, and all the cases of the transaction processing engine.
## Safety
Since this is a CLI tool, handling financial transactions, we panic on error.
We'd rather fail fast and loud than let a bug go unnoticed, and cause corrutped data.
Cases that were documented in the requirements are skipped, for example a dispute on a non-existing transaction.
Otherwise we assert business logic constraits with expects throughout the code [Tiger style](https://github.com/tigerbeetle/tigerbeetle/blob/main/docs/TIGER_STYLE.md).
Some cases are also handled gracefully, a deposit on a frozen account will be ignored, but we keep it in a separate queue for further processing in case of unlocking.
## Performance
We use the tokio async runtime to parse the file and process the transactions concurrently.
This allows us to stream through a large file or handle tcp streams.
We also use a hashmap to store the accounts and a hashmap to store the transactions, which allows us to have a average O(1) complexity for the lookups.