Skip to content

Releases: fraktalio/fmodel

v3.5.1

23 May 19:43
Compare
Choose a tag to compare

Version 3.5.1 is a reactive and a multiplatform version of fmodel libraries optimized for Event sourcing, CQRS, and Domain Modeling.

Maven coordinates

 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>domain</artifactId>
    <version>3.5.1</version>
 </dependency>

 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>application-vanilla</artifactId>
    <version>3.5.1</version>
 </dependency>
 
 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>application-arrow</artifactId>
    <version>3.5.1</version>
 </dependency>

In this release, we have fixed the bug on the Event Sourced aggregate within the application module - #291. It is reproducible only in the orchestrating scenarios where you communicate two deciders back and forth, a couple of times.

The full release notes:

What's Changed

  • Update gradle/gradle-build-action action to v2.6.1 by @renovate in #212
  • Update actions/setup-java action to v3.12.0 by @renovate in #216
  • Update gradle/gradle-build-action action to v2.7.0 by @renovate in #217
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.7.3 by @renovate in #218
  • Update dependency gradle to v8.3 by @renovate in #219
  • Update gradle/gradle-build-action action to v2.7.1 by @renovate in #220
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.9.10 by @renovate in #221
  • Update actions/checkout action to v3.6.0 by @renovate in #222
  • Update gradle/gradle-build-action action to v2.8.0 by @renovate in #223
  • Update dependency org.jetbrains.dokka to v1.9.0 by @renovate in #224
  • Update dependency io.kotest.multiplatform to v5.7.0 by @renovate in #225
  • Update kotest to v5.7.0 by @renovate in #226
  • Update dependency io.kotest.multiplatform to v5.7.1 by @renovate in #227
  • Update kotest to v5.7.1 by @renovate in #228
  • Update dependency io.kotest.multiplatform to v5.7.2 by @renovate in #230
  • Update kotest to v5.7.2 by @renovate in #231
  • Update dependency io.arrow-kt:arrow-core to v1.2.1 by @renovate in #232
  • Update actions/checkout action to v4 by @renovate in #229
  • Update actions/upload-artifact action to v3.1.3 by @renovate in #233
  • Update actions/setup-java action to v3.13.0 by @renovate in #234
  • Update actions/checkout action to v4.1.0 by @renovate in #236
  • Update actions/checkout digest to 8ade135 by @renovate in #235
  • Update gradle/gradle-build-action action to v2.8.1 by @renovate in #237
  • Update gradle/gradle-build-action action to v2.9.0 by @renovate in #239
  • Update dependency gradle to v8.4 by @renovate in #240
  • Update dependency org.jetbrains.dokka to v1.9.10 by @renovate in #241
  • Update actions/checkout action to v4.1.1 by @renovate in #242
  • Update actions/checkout digest to b4ffde6 by @renovate in #243
  • Update dependency io.kotest.multiplatform to v5.8.0 by @renovate in #246
  • Update kotest to v5.8.0 by @renovate in #247
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.9.20 by @renovate in #245
  • Conforming to new default hierarchy template for setting up multiplatform projects by @idugalic in #248
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.9.21 by @renovate in #252
  • Support for handling event/command metadata - application layer by @idugalic in #250
  • Update dependency gradle to v8.5 by @renovate in #254
  • Update gradle/gradle-build-action action to v2.11.0 by @renovate in #253
  • Update actions/setup-java action to v4 by @renovate in #255
  • Update actions/upload-artifact action to v4 by @renovate in #256
  • Update gradle/gradle-build-action action to v2.11.1 by @renovate in #257
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.9.22 by @renovate in #258
  • Update actions/upload-artifact action to v4.1.0 by @renovate in #260
  • Update actions/upload-artifact action to v4.2.0 by @renovate in #261
  • Update actions/upload-artifact action to v4.3.0 by @renovate in #262
  • Update gradle/gradle-build-action action to v2.12.0 by @renovate in #263
  • Update plugin org.jetbrains.kotlinx.binary-compatibility-validator to v0.14.0 by @renovate in #264
  • Update gradle/gradle-build-action action to v3 by @renovate in #265
  • Update dependency gradle to v8.6 by @renovate in #266
  • Update actions/upload-artifact action to v4.3.1 by @renovate in #267
  • Update gradle/gradle-build-action action to v3.1.0 by @renovate in #268
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.8.0 by @renovate in #269
  • Update dependency io.arrow-kt:arrow-core to v1.2.3 by @renovate in #270
  • Update actions/setup-java action to v4.1.0 by @renovate in #271
  • Update dependency org.jetbrains.dokka to v1.9.20 by @renovate in #272
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.9.23 by @renovate in #273
  • Update dependency io.kotest.multiplatform to v5.8.1 by @renovate in #274
  • Update kotest to v5.8.1 by @renovate in #275
  • Update dependency gradle to v8.7 by @renovate in #277
  • Update dependency io.arrow-kt:arrow-core to v1.2.4 by @renovate in #278
  • Update actions/setup-java action to v4.2.1 by @renovate in #276
  • Update gradle/gradle-build-action action to v3.3.0 by @renovate in #279
  • Update actions/upload-artifact action to v4.3.3 by @renovate in #280
  • Update gradle/gradle-build-action action to v3.3.2 by @renovate in #281
  • Update actions/checkout action to v4.1.4 by @renovate in #283
  • Update actions/checkout digest to 0ad4b8f by @renovate in #282
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.9.24 by @renovate in #284
  • Update dependency io.kotest.multiplatform to v5.9.0 by @renovate in #287
  • Update kotest to v5.9.0 by @renovate in #288
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.8.1 by @renovate in #289
  • Update actions/checkout action to v4.1.5 by @renovate in #286
  • Update actions/checkout action to v4.1.6 by @renovate in #290
  • Application module: Fixing bug in event computation - orchestrated scenario by @idugalic in #291

Full Changelog: v3.5.0...v3.5.1

v3.5.0

14 Jul 10:45
Compare
Choose a tag to compare

Version 3.5.0 is a reactive and a multiplatform version of fmodel libraries optimized for Event sourcing, CQRS, and Domain Modeling.

Maven coordinates

 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>domain</artifactId>
    <version>3.5.0</version>
 </dependency>

 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>application-vanilla</artifactId>
    <version>3.5.0</version>
 </dependency>
 
 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>application-arrow</artifactId>
    <version>3.5.0</version>
 </dependency>

In this release, we have upgraded the Kotlin Arrow library to 1.2.0. It is a breaking change for the application-arrow module/extension.

We have introduced and configured a binary compatibility validator into our build process.

The tool allows dumping binary API of a JVM part of a Kotlin library that is public in the sense of Kotlin visibilities and ensures that the public binary API wasn't changed in a way that makes this change binary incompatible.

We extended the case of using actor functions to parallelize the message handling processes. (available on JVM target only)

/**
 * Extension function - Handles the flow of command messages of type [C] by concurrently distributing the load across finite number of actors/handlers
 *
 * @param commands [Flow] of Command messages of type [C]
 * @param numberOfActors total number of actors/workers available for distributing the load. Minimum one.
 * @param actorsCapacity capacity of the actors channel's buffer
 * @param actorsStart actors coroutine start option
 * @param actorsContext additional to [CoroutineScope.coroutineContext] context of the actor coroutines.
 * @param partitionKey a function that calculates the partition key/routing key of command - commands with the same partition key will be handled with the same 'actor' to keep the ordering
 * @return [Flow] of stored Events of type [E]
 *
 */
fun <C, S, E> EventSourcingAggregate<C, S, E>.handleConcurrently(
    commands: Flow<C>,
    numberOfActors: Int = 100,
    actorsCapacity: Int = Channel.BUFFERED,
    actorsStart: CoroutineStart = CoroutineStart.LAZY,
    actorsContext: CoroutineContext = EmptyCoroutineContext,
    partitionKey: (C) -> Int
): Flow<E>

Deprecating factory functions in favor of constructor-like functions.

What's Changed

  • Update actions/checkout action to v3.5.0 by @renovate in #181
  • Update actions/setup-java action to v3.11.0 by @renovate in #182
  • Arrow KT upgraded to 1.2.0 - a step closer to 2.0.0 by @idugalic in #184
  • Kotlin upgraded to 1.8.20 by @idugalic in #185
  • Update dependency gradle to v8.1 by @renovate in #187
  • Update actions/checkout action to v3.5.1 by @renovate in #186
  • Update gradle/gradle-build-action action to v2.4.1 by @renovate in #188
  • Update actions/checkout action to v3.5.2 by @renovate in #189
  • Update gradle/gradle-build-action action to v2.4.2 by @renovate in #190
  • Update dependency gradle to v8.1.1 by @renovate in #193
  • Update kotest to v5.6.1 by @renovate in #192
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.8.21 by @renovate in #194
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.7.0 by @renovate in #195
  • Deprecating factory functions in favour of constructor-like functions. by @idugalic in #196
  • Update kotest to v5.6.2 by @renovate in #198
  • Update dependency io.kotest.multiplatform to v5.6.2 by @renovate in #197
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.7.1 by @renovate in #199
  • Properly propagating ExperimentalCoroutinesApi by @idugalic in #200
  • Promote ``@FlowPreview` API to stable/experimental by @idugalic in #201
  • Update dependency org.jetbrains.dokka to v1.8.20 by @renovate in #203
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.8.22 by @renovate in #204
  • Update actions/checkout action to v3.5.3 by @renovate in #205
  • Update gradle/gradle-build-action action to v2.5.1 by @renovate in #206
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.7.2 by @renovate in #207
  • Update dependency gradle to v8.2 by @renovate in #208
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.9.0 by @renovate in #209
  • handling the messages concurrently and in parallel - actors by @idugalic in #210
  • Update dependency gradle to v8.2.1 by @renovate in #211
  • Update dependency io.arrow-kt:arrow-core to v1.2.0 by @renovate in #213
  • Binary compatibility validator configured by @idugalic in #214

Full Changelog: v3.4.0...v3.5.0

v3.4.0

14 Mar 18:24
Compare
Choose a tag to compare

Version 3.4.0 is a reactive and a multiplatform version of fmodel libraries optimized for Event sourcing, CQRS, and Domain Modeling.

Maven coordinates

 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>domain</artifactId>
    <version>3.4.0</version>
 </dependency>

 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>application-vanilla</artifactId>
    <version>3.4.0</version>
 </dependency>
 
 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>application-arrow</artifactId>
    <version>3.4.0</version>
 </dependency>

New Native targets available

linuxX64()
mingwX64()
macosX64()
macosArm64()
tvos()
tvosSimulatorArm64()
watchosArm32()
watchosArm64()
watchosX86()
watchosX64()
watchosSimulatorArm64()
iosX64()
iosArm64()
iosArm32()
iosSimulatorArm64()

What's Changed

  • Publish multiple (native) targets by @idugalic in #175
  • Event (Locking) Repository simplified by @idugalic in #178
  • Application interfaces simplified (unused methods deleted) by @idugalic in #172
  • Nodejs - Apple Silicon build/config fixed by @idugalic in #176
  • Update actions/checkout action to v3.3.0 by @renovate in #165
  • Update actions/upload-artifact action to v3.1.2 by @renovate in #166
  • Update dependency io.arrow-kt:arrow-core to v1.1.5 by @renovate in #167
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.8.10 by @renovate in #168
  • Update kotest to v5.5.5 by @renovate in #170
  • Update dependency io.kotest.multiplatform to v5.5.5 by @renovate in #169
  • Update actions/setup-java action to v3.10.0 by @renovate in #171
  • Update dependency gradle to v8.0.1 by @renovate in #173
  • Update gradle/gradle-build-action action to v2.4.0 by @renovate in #177
  • Update dependency gradle to v8.0.2 by @renovate in #179
  • Update dependency org.jetbrains.dokka to v1.8.10 by @renovate in #180

Full Changelog: v3.3.0...v3.4.0

v3.3.0

30 Dec 11:29
Compare
Choose a tag to compare

Version 3.3.0 is a reactive and a multiplatform version of fmodel libraries optimized for Event sourcing, CQRS, and Domain Modeling.

Maven coordinates

 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>domain</artifactId>
    <version>3.3.0</version>
 </dependency>

 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>application-vanilla</artifactId>
    <version>3.3.0</version>
 </dependency>
 
 <dependency>
    <groupId>com.fraktalio.fmodel</groupId>
    <artifactId>application-arrow</artifactId>
    <version>3.3.0</version>
 </dependency>

A convenient DSL (builder) for the domain components:

For example:

fun evenNumberDecider(): Decider<EvenNumberCommand?, EvenNumberState, EvenNumberEvent?> =
    decider {
        initialState {
            evenNumberState {
                descriptionString { "Initial state" }
                valueInt { 0 }
            }
        }
        decide { c, s ->
            when (c) {
                is AddEvenNumber -> flowOf(
                    evenNumberAdded {
                        description { c.description }
                        value { s.value + c.value }
                    }
                )

                is SubtractEvenNumber -> flowOf(
                    evenNumberSubtracted {
                        description { c.description }
                        value { s.value - c.value }
                    }
                )

                null -> emptyFlow()
            }
        }
        evolve { s, e ->
            when (e) {
                is EvenNumberAdded ->
                    evenNumberState {
                        description { s.description + e.description }
                        value { e.value }
                    }

                is EvenNumberSubtracted ->
                    evenNumberState {
                        description { s.description - e.description }
                        value { e.value }
                    }

                null -> s
            }
        }
    }

Minimizing the API

  • _Decider<C, Si, So, Ei, Eo> is internal now
  • _View<Si, So, E> is internal now

There was no true usage of this API, so we have chosen to make it internal, in favor of Decider<C, S, E> and View<S, E>.
Previously, Decider was just a type alias of _Decider, but these are different types actually and we want to promote that.

We hope to minimize the complexity of the API and make the right thing to do the easy thing to do.

What's Changed

Full Changelog: v3.2.0...v3.3.0

v3.2.0

15 Sep 11:56
Compare
Choose a tag to compare

Version 3.2.0 is a reactive and a multiplatform version of fmodel libraries optimized for Event sourcing, CQRS, and Domain Modeling.

Optimistic Locking

Optimistic locking, also referred to as optimistic concurrency control, allows multiple concurrent users to attempt to update the same resource.

There are two common ways to implement optimistic locking: version number and timestamp. The version number is generally considered to be a better option because the server clock can be inaccurate over time, but we do not want to restrict it to only one option, so we have the generic parameter V acting as a Version.

The optimistic locking mechanism is not leaking into the core Domain layer.

Application modules provide more interfaces and extensions, giving you additional options to compose your unique Domain components with Optimistic Locking formally in place, without changing the Domain components whatsoever.

example (state-stored aggregate / tradiotional)

  stateStoredLockingAggregate(
      decider = myDecider,
      stateRepository = myLockingRepository
  ).handleOptimistically(myCommand)

where myDecider is of type IDecider<C, S, E>, myLockingRepository is of type StateLockingRepository<C, S, V> and myCommand is of type C

example (event-sourced aggregate / event-driven)

  eventSourcingLockingAggregate(
      decider = myDecider,
      stateRepository = myLockingRepository
  ).handleOptimistically(myCommand)

where myDecider is of type IDecider<C, S, E>, myLockingRepository is of type EventLockingRepository<C, E, V> and myCommand is of type C

What's Changed

  • Update gradle/gradle-build-action action to v2.2.0 by @renovate in #105
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.6.3 by @renovate in #104
  • Update gradle/gradle-build-action action to v2.2.1 by @renovate in #109
  • Update actions/setup-java action to v3.4.0 by @renovate in #110
  • Update dependency org.jetbrains.dokka to v1.7.0 by @renovate in #108
  • Update actions/setup-java action to v3.4.1 by @renovate in #113
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.6.4 by @renovate in #115
  • Update dependency gradle to v7.5 by @renovate in #116
  • Update kotest by @renovate in #112
  • Update dependency org.jetbrains.dokka to v1.7.10 by @renovate in #114
  • Update gradle/gradle-build-action action to v2.2.2 by @renovate in #118
  • Update dependency org.jetbrains.kotlin.multiplatform to v1.7.10 by @renovate in #106
  • Update dependency io.kotest.multiplatform to v5.4.1 by @renovate in #121
  • Update kotest to v5.4.1 by @renovate in #122
  • Update dependency gradle to v7.5.1 by @renovate in #123
  • Update gradle/gradle-build-action action to v2.2.3 by @renovate in #126
  • Update gradle/gradle-build-action action to v2.2.5 by @renovate in #127
  • Update gradle/gradle-build-action action to v2.3.0 by @renovate in #128
  • Opt-In propagated correctly. by @idugalic in #129
  • Marking the combine function as infix by @idugalic in #130
  • Publishing all native targets by Github Actions by @idugalic in #131
  • Feature - optimistic locking by @idugalic in #133
  • Update actions/setup-java action to v3.5.0 by @renovate in #132

Full Changelog: v3.1.0...v3.2.0

v3.1.0

04 Jun 09:54
Compare
Choose a tag to compare

Version 3.1.0 is a reactive and a multiplatform version of fmodel libraries optimized for Event sourcing, CQRS, and Domain Modeling.

Experimental Actors (JVM only)

  • Kotlin Actors (experimental) - concurrently handling messages by @idugalic in #70

kotlin actors

/**
 * Extension function - Handles the flow of command messages of type [C] by concurrently distributing the load across finite number of actors/handlers
 *
 * @param commands [Flow] of Command messages of type [C]
 * @param numberOfActors total number of actors/workers available for distributing the load
 * @param actorsCapacity capacity of the actors channel's buffer
 * @param actorsStart actors coroutine start option
 * @param actorsContext additional to [CoroutineScope.coroutineContext] context of the actor coroutines.
 * @param partitionKey a function that calculates the partition key/routing key of command - commands with the same partition key will be handled wit the same actor to keep the ordering
 * @return [Flow] of stored Events of type [E]
 *
 * @author Иван Дугалић / Ivan Dugalic / @idugalic
 */
@ExperimentalContracts
@FlowPreview
fun <C, S, E> EventSourcingAggregate<C, S, E>.handleConcurrently(
    commands: Flow<C>,
    numberOfActors: Int = 100,
    actorsCapacity: Int = Channel.BUFFERED,
    actorsStart: CoroutineStart = CoroutineStart.LAZY,
    actorsContext: CoroutineContext = EmptyCoroutineContext,
    partitionKey: (C) -> Int
): Flow<E> = channelFlow {
    val actors: List<SendChannel<C>> = (1..numberOfActors).map {
        commandActor(channel, actorsCapacity, actorsStart, actorsContext) { handle(it) }

    }
    commands
        .onCompletion {
            actors.forEach {
                it.close()
            }
        }
        .collect {
            val partition = partitionKey(it).absoluteValue % numberOfActors.coerceAtLeast(1)
            actors[partition].send(it)
        }
}

Arrow new Effect system

suspend fun C.fetchStateWithEffect(): Effect<Error, S?> =
        effect {
            try {
                fetchState()
            } catch (t: Throwable) {
                shift(FetchingStateFailed(this@fetchStateWithEffect, t.nonFatalOrThrow()))
            }
        }

What's Changed

  • Configure Renovate by @renovate in #61
  • Update plugin dokka to v1.6.10 by @renovate in #62
  • Update io.kotest to v5.1.0 by @renovate in #63
  • Update gradle/gradle-build-action action to v2.1.1 by @renovate in #66
  • Update gradle/gradle-build-action action to v2.1.2 by @renovate in #67
  • Update gradle/gradle-build-action action to v2.1.3 by @renovate in #68
  • Update dependency gradle to v7.4 by @renovate in #69
  • Kotlin Actors (experimental) - concurrently handling messages by @idugalic in #70
  • Update actions/setup-java action to v3 by @renovate in #73
  • Update actions/checkout action by @renovate in #74
  • Update actions/upload-artifact action to v3 by @renovate in #75
  • Update dependency gradle to v7.4.1 by @renovate in #77
  • Update io.kotest to v5.2.1 by @renovate in #78
  • Update gradle/gradle-build-action action to v2.1.4 by @renovate in #80
  • Update gradle/gradle-build-action action to v2.1.5 by @renovate in #82
  • Update plugin kotlin-multiplatform to v1.6.20 by @renovate in #85
  • Update dependency gradle to v7.4.2 by @renovate in #83
  • Update actions/setup-java action to v3.1.0 by @renovate in #84
  • Update io.kotest to v5.2.3 by @renovate in #89
  • Update actions/setup-java action to v3.1.1 by @renovate in #90
  • Update plugin dokka to v1.6.20 by @renovate in #91
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.6.1 by @renovate in #86
  • Update actions/checkout action to v3.0.2 by @renovate in #92
  • Update plugin kotlin-multiplatform to v1.6.21 by @renovate in #93
  • Update dependency io.arrow-kt:arrow-core to v1.1.2 by @renovate in #94
  • Update plugin dokka to v1.6.21 by @renovate in #96
  • Update actions/setup-java action to v3.2.0 by @renovate in #97
  • Update kotest to v5.3.0 by @renovate in #101
  • Update actions/setup-java action to v3.3.0 by @renovate in #100
  • Update gradle/gradle-build-action action to v2.1.7 by @renovate in #102
  • Update actions/upload-artifact action to v3.1.0 by @renovate in #103
  • Arrow (from either to Effect) by @idugalic in #95

Full Changelog: v3.0.0...v3.1.0

v3.0.0

04 Jan 16:05
Compare
Choose a tag to compare

Version 3.0.0 is a reactive and multiplatform version of fmodel libraries optimized for Event sourcing, CQRS, and Domain Modeling.

What's Changed

Tests example

class DeciderTest : FunSpec({
    val evenDecider = evenNumberDecider()
    val oddDecider = oddNumberDecider()

    test("Event-sourced Decider - add even number") {
        with(evenDecider) {
            givenEvents(emptyList()) {
                whenCommand(AddEvenNumber(Description("2"), NumberValue(2)))
            } thenEvents listOf(EvenNumberAdded(Description("2"), NumberValue(2)))
        }
    }

    test("Event-sourced Decider - given previous state, add even number") {
        with(evenDecider) {
            givenEvents(listOf(EvenNumberAdded(Description("2"), NumberValue(2)))) {
                whenCommand(AddEvenNumber(Description("4"), NumberValue(4)))
            } thenEvents listOf(EvenNumberAdded(Description("4"), NumberValue(4)))
        }
    }
})

https://github.com/fraktalio/fmodel/blob/main/domain/src/commonTest/kotlin/com.fraktalio.fmodel.domain/DeciderTest.kt

v1.3.1

18 Dec 09:01
Compare
Choose a tag to compare

Version 1.3.1 is a functional and async version of fmodel libraries optimized for Event sourcing and CQRS.
Please find the README/DOC here. It is maintained on the v1 branch.

Version 2.*.* is a reactive version (Flow included) of the libraries optimized for Event sourcing and CQRS. It is maintained on the main branch

What's Changed

  • A patch release for v1.3.0
  • Removed the unneeded extension functions from the application-arrow module.

v1.3.0

17 Dec 23:21
Compare
Choose a tag to compare

Version 1.3.0 is a functional and async version of fmodel libraries optimized for Event sourcing and CQRS.
Please find the README/DOC here. It is maintained on the v1 branch.

Version 2.*.* is a reactive version (Flow included) of the libraries optimized for Event sourcing and CQRS. It is maintained on the main branch

What's Changed

  • Increasing modularity and pluggability of the Application module
    The application module has interfaces only.
    The extensions to the interfaces will be provided in separate modules:
    • application vanilla extension (kotlin),
    • application arrow extension (kotlin, arrow),
    • your custom module

Application

interface EventSourcingAggregate<C, S, E> : IDecider<C, S, E>, EventRepository<C, E> {

    fun Sequence<E>.computeNewEvents(command: C): Sequence<E> =
        decide(command, fold(initialState) { s, e -> evolve(s, e) })
}

Application Vanilla

suspend fun <C, S, E> EventSourcingAggregate<C, S, E>.handle(command: C): Sequence<E> =
    command
        .fetchEvents()
        .computeNewEvents(command)
        .save()

Application Arrow

suspend fun <C, S, E> EventSourcingAggregate<C, S, E>.handleEither(command: C): Either<Error, Sequence<E>> {

    suspend fun C.eitherFetchEventsOrFail(): Either<Error.FetchingEventsFailed, Sequence<E>> =
        Either.catch {
            fetchEvents()
        }.mapLeft { throwable -> Error.FetchingEventsFailed(throwable) }

    suspend fun E.eitherSaveOrFail(): Either<Error.StoringEventFailed<E>, E> =
        Either.catch {
            this.save()
        }.mapLeft { throwable -> Error.StoringEventFailed(this, throwable) }

    suspend fun Sequence<E>.eitherSaveOrFail(): Either<Error.StoringEventFailed<E>, Sequence<E>> =
        either<Error.StoringEventFailed<E>, List<E>> {
            this@eitherSaveOrFail.asIterable().map { it.eitherSaveOrFail().bind() }
        }.map { it.asSequence() }

    fun Sequence<E>.eitherComputeNewEventsOrFail(command: C): Either<Error, Sequence<E>> =
        Either.catch {
            computeNewEvents(command)
        }.mapLeft { throwable ->
            Error.CalculatingNewEventsFailed(this.toList(), throwable)
        }

    // Arrow provides a Monad instance for Either. Except for the types signatures, our program remains unchanged when we compute over Either. All values on the left side assume to be Right biased and, whenever a Left value is found, the computation short-circuits, producing a result that is compatible with the function type signature.
    return either {
        command
            .eitherFetchEventsOrFail().bind()
            .eitherComputeNewEventsOrFail(command).bind()
            .eitherSaveOrFail().bind()
    }
}

v2.3.1

15 Dec 17:55
Compare
Choose a tag to compare

Version 2.3.1 is a reactive version of fmodel libraries optimized for Event sourcing, CQRS, and Domain Modeling.

What's Changed

  • A patch release for v2.3.0
  • Removed the unneeded dependencies from the pom files / arrow lib removed from application and application-vannila modules.
  • Source code documentation improved on Saga component.