Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin Actors (experimental) - concurrently handling messages #70

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

idugalic
Copy link
Member

@idugalic idugalic commented Feb 17, 2022

Experimenting with Kotlin Actors - concurrently handling messages by confining the shared state effects.

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>

Extension function - Handles the Flow of messages by concurrently distributing the load across a finite number of actors/handlers. partitionKey function enables you to choose which messages need to be handled sequentially and which could be handled concurrently.

Notice, the API is experimental and depends on Kotlin Actor ObsoleteCoroutinesApi. The API is available only on jvm target.

@idugalic idugalic merged commit ee05446 into main Feb 17, 2022
@idugalic idugalic deleted the feature/actors branch March 13, 2022 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant