From cdc8b44390f7aa11c4d40efce7904f077a0b787a Mon Sep 17 00:00:00 2001 From: "kamil.jedrzejuk" Date: Wed, 9 Oct 2024 16:13:42 +0200 Subject: [PATCH] Small refactor --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7baa897..3ce9e12 100644 --- a/README.md +++ b/README.md @@ -35,18 +35,22 @@ The project follows **Domain-Driven Design (DDD)** principles, which structure t Transaction management is handled using a lambda function that wraps database operations in a transactional context. ```kotlin -fun executeInTransaction(block: () -> T): T { - return inTransaction(block as () -> Any) as T +fun inTransaction(block: () -> T): T { + return executeInTransaction(block as () -> Any) as T } -private var inTransaction: (() -> Any) -> Any = { block -> block() } +private var executeInTransaction: (() -> Any) -> Any = { block -> + block() +} @Configuration class TransactionManagerConfig { @PostConstruct fun setupProductionTransaction() { - inTransaction = { block -> transaction { block() } } + executeInTransaction = { block -> + transaction { block() } + } } } ``` @@ -61,7 +65,7 @@ fun create(command: CreateAccountCommand): AccountSnapshot { } val id = repository.nextAccountId() val account = Account.createNewAccount(command.toCreateAccountData(id)) - executeInTransaction { + inTransaction { repository.save(account) val events = account.getEvents() accountOperationRepository.save(events)