Skip to content

Commit

Permalink
paatch release 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
idugalic committed Dec 18, 2021
1 parent d8d0dff commit c491aac
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 121 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -435,19 +435,19 @@ All `fmodel` components/libraries are released to [Maven Central](https://repo1.
<dependency>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>domain</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>application-vanilla</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>application-arrow</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions application-arrow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>fmodel</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>application-arrow</artifactId>
Expand All @@ -39,7 +39,7 @@
<dependency>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>application</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,3 @@ suspend fun <C, S, E> EventSourcingAggregate<C, S, E>.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 <C, S, E> EventSourcingAggregate<C, S, E>.handle(command: C): Sequence<E> =
command
.fetchEvents()
.computeNewEvents(command)
.save()
Original file line number Diff line number Diff line change
Expand Up @@ -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 <S, E> MaterializedView<S, E>.handle(event: E): S =
event
.fetchState()
.computeNewState(event)
.save()


suspend fun <S, E> MaterializedView<S, E>.handleEither(event: E): Either<Error, S> {
/**
* Inner function - Computes new State based on the Event or fails.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <AR, A> SagaManager<AR, A>.handle(actionResult: AR): Sequence<A> =
actionResult
.computeNewActions()
.publish()

/**
* Extension function - Handles the action result of type [AR].
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <C, S, E> StateStoredAggregate<C, S, E>.handle(command: C): S =
command
.fetchState()
.computeNewState(command)
.save()

/**
* Handles the command message of type [C]
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<EvenNumberState, OddNumberState>

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<Error, EvenNumberState>

Expand Down
4 changes: 2 additions & 2 deletions application-vanilla/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>fmodel</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>application-vanilla</artifactId>
Expand All @@ -38,7 +38,7 @@
<dependency>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>application</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down
4 changes: 2 additions & 2 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>fmodel</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>application</artifactId>
Expand All @@ -38,7 +38,7 @@
<dependency>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>domain</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down
2 changes: 1 addition & 1 deletion domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>fmodel</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>domain</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>com.fraktalio.fmodel</groupId>
<artifactId>fmodel</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>pom</packaging>

<name>fmodel</name>
Expand Down

0 comments on commit c491aac

Please sign in to comment.