Skip to content

v3.1.0

Compare
Choose a tag to compare
@idugalic idugalic released this 04 Jun 09:54
· 535 commits to main since this release

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