diff --git a/README.md b/README.md index 935c0829..99663a61 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ Design patterns, optimised for Event Sourcing and CQRS. - The [`domain` model library](https://search.maven.org/artifact/com.fraktalio.fmodel/domain/1.3.0/jar) is fully isolated from the application layer and API-related concerns. It represents a pure declaration of the program logic. It is written in [Kotlin](https://kotlinlang.org/) programming language, without additional dependencies. -- The [`application` library](https://search.maven.org/artifact/com.fraktalio.fmodel/application/1.3.0/jar) orchestrates +- The [`application` library](https://search.maven.org/artifact/com.fraktalio.fmodel/application/1.3.1/jar) orchestrates the execution of the logic by loading state, executing `domain` components and storing new state. Two flavors ( extensions of `Application` module) are available: - - [`application-vanilla`]((https://search.maven.org/artifact/com.fraktalio.fmodel/application-vanilla/1.3.0/jar)) is + - [`application-vanilla`]((https://search.maven.org/artifact/com.fraktalio.fmodel/application-vanilla/1.3.1/jar)) is using plain/vanilla Kotlin to implement the application layer in order to load the state, orchestrate the execution of the logic and save new state. - - [`application-arrow`]((https://search.maven.org/artifact/com.fraktalio.fmodel/application-arrow/1.3.0/jar)) is + - [`application-arrow`]((https://search.maven.org/artifact/com.fraktalio.fmodel/application-arrow/1.3.1/jar)) is using [Arrow](https://arrow-kt.io/) and Kotlin to implement the application layer in order to load the state, orchestrate the execution of the logic and save new state - managing errors much better (using Either). @@ -435,19 +435,19 @@ All `fmodel` components/libraries are released to [Maven Central](https://repo1. com.fraktalio.fmodel domain - 1.3.0 + 1.3.1 com.fraktalio.fmodel application-vanilla - 1.3.0 + 1.3.1 com.fraktalio.fmodel application-arrow - 1.3.0 + 1.3.1 ``` diff --git a/application-arrow/pom.xml b/application-arrow/pom.xml index 1a8d4287..ffd23d09 100644 --- a/application-arrow/pom.xml +++ b/application-arrow/pom.xml @@ -22,7 +22,7 @@ com.fraktalio.fmodel fmodel - 1.3.0 + 1.3.1 application-arrow @@ -39,7 +39,7 @@ com.fraktalio.fmodel application - 1.3.0 + 1.3.1 org.jetbrains.kotlin diff --git a/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/EventSourcingAggregatArrowExtension.kt b/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/EventSourcingAggregatArrowExtension.kt index 9a78bc97..67a337df 100644 --- a/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/EventSourcingAggregatArrowExtension.kt +++ b/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/EventSourcingAggregatArrowExtension.kt @@ -59,17 +59,3 @@ suspend fun EventSourcingAggregate.handleEither(command: C): .eitherSaveOrFail().bind() } } - -/** - * Extension function - Handles the command message of type [C] - * - * @param command Command message of type [C] - * @return [Sequence] of Events of type [E] that are saved, or throws an exception - * - * @author Иван Дугалић / Ivan Dugalic / @idugalic - */ -suspend fun EventSourcingAggregate.handle(command: C): Sequence = - command - .fetchEvents() - .computeNewEvents(command) - .save() diff --git a/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/MaterializedViewArrowExtension.kt b/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/MaterializedViewArrowExtension.kt index 0b7ef141..c3f869c3 100644 --- a/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/MaterializedViewArrowExtension.kt +++ b/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/MaterializedViewArrowExtension.kt @@ -19,21 +19,6 @@ package com.fraktalio.fmodel.application import arrow.core.Either import arrow.core.computations.either -/** - * Extension function - Handles the event of type [E] - * - * @param event Event of type [E] to be handled - * @return State of type [S] - * - * @author Иван Дугалић / Ivan Dugalic / @idugalic - */ -suspend fun MaterializedView.handle(event: E): S = - event - .fetchState() - .computeNewState(event) - .save() - - suspend fun MaterializedView.handleEither(event: E): Either { /** * Inner function - Computes new State based on the Event or fails. diff --git a/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/SagaManagerArrowExtension.kt b/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/SagaManagerArrowExtension.kt index b174c243..459f40c7 100644 --- a/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/SagaManagerArrowExtension.kt +++ b/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/SagaManagerArrowExtension.kt @@ -19,19 +19,6 @@ package com.fraktalio.fmodel.application import arrow.core.Either import arrow.core.computations.either -/** - * Extension function - Handles the action result of type [AR]. - * - * @param actionResult Action Result represent the outcome of some action you want to handle in some way - * @return [Sequence] of Actions of type [A] - * - * @author Иван Дугалић / Ivan Dugalic / @idugalic - */ -suspend fun SagaManager.handle(actionResult: AR): Sequence = - actionResult - .computeNewActions() - .publish() - /** * Extension function - Handles the action result of type [AR]. * diff --git a/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/StateStoredAggregateArrowExtension.kt b/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/StateStoredAggregateArrowExtension.kt index 071c1f07..7e261276 100644 --- a/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/StateStoredAggregateArrowExtension.kt +++ b/application-arrow/src/main/kotlin/com/fraktalio/fmodel/application/StateStoredAggregateArrowExtension.kt @@ -19,20 +19,6 @@ package com.fraktalio.fmodel.application import arrow.core.Either import arrow.core.computations.either -/** - * Extension function - Handles the command message of type [C] - * - * @param command Command message of type [C] - * @return State of type [S] - * - * @author Иван Дугалић / Ivan Dugalic / @idugalic - */ -suspend fun StateStoredAggregate.handle(command: C): S = - command - .fetchState() - .computeNewState(command) - .save() - /** * Handles the command message of type [C] * diff --git a/application-arrow/src/test/kotlin/com/fraktalio/fmodel/application/StateStoredAggregateTest.kt b/application-arrow/src/test/kotlin/com/fraktalio/fmodel/application/StateStoredAggregateTest.kt index 1e0d2d1f..7bea8e4b 100644 --- a/application-arrow/src/test/kotlin/com/fraktalio/fmodel/application/StateStoredAggregateTest.kt +++ b/application-arrow/src/test/kotlin/com/fraktalio/fmodel/application/StateStoredAggregateTest.kt @@ -36,7 +36,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runBlockingTest import org.spekframework.spek2.Spek import org.spekframework.spek2.style.gherkin.Feature -import kotlin.test.assertEquals @ExperimentalCoroutinesApi @@ -62,56 +61,6 @@ object StateStoredAggregateTest : Spek({ ) } - Scenario("Success") { - lateinit var result: EvenNumberState - - When("handling command of type AddEvenNumber") { - runBlockingTest { - (evenNumberStateRepository as EvenNumberStateRepository).deleteAll() - result = evenAggregate.handle( - AddEvenNumber( - Description("Add 2"), - NumberValue(2) - ) - ) - } - } - Then("expect success") { - runBlockingTest { - assertEquals( - EvenNumberState(Description("Add 2"), NumberValue(2)), - result - ) - } - } - } - - Scenario("Success - combined aggregate") { - lateinit var result: Pair - - When("handling command of type AddEvenNumber") { - runBlockingTest { - (numberStateRepository() as NumberStateRepository).deleteAll() - result = allNumbersAggregate.handle( - AddEvenNumber( - Description("Add 2"), - NumberValue(2) - ) - ) - } - } - Then("expect success") { - runBlockingTest { - assertEquals( - EvenNumberState(Description("Add 2"), NumberValue(2)), - result.first - ) - } - } - } - - // EITHER - Scenario("Success - Either") { lateinit var result: Either diff --git a/application-vanilla/pom.xml b/application-vanilla/pom.xml index c1d71d47..eb90b2f9 100644 --- a/application-vanilla/pom.xml +++ b/application-vanilla/pom.xml @@ -22,7 +22,7 @@ com.fraktalio.fmodel fmodel - 1.3.0 + 1.3.1 application-vanilla @@ -38,7 +38,7 @@ com.fraktalio.fmodel application - 1.3.0 + 1.3.1 org.jetbrains.kotlin diff --git a/application/pom.xml b/application/pom.xml index c47be770..3ede48b8 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -22,7 +22,7 @@ com.fraktalio.fmodel fmodel - 1.3.0 + 1.3.1 application @@ -38,7 +38,7 @@ com.fraktalio.fmodel domain - 1.3.0 + 1.3.1 org.jetbrains.kotlin diff --git a/domain/pom.xml b/domain/pom.xml index 59c06022..6ec52a81 100644 --- a/domain/pom.xml +++ b/domain/pom.xml @@ -22,7 +22,7 @@ com.fraktalio.fmodel fmodel - 1.3.0 + 1.3.1 domain diff --git a/pom.xml b/pom.xml index f38b8020..0675ae60 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ com.fraktalio.fmodel fmodel - 1.3.0 + 1.3.1 pom fmodel