-
This is really interesting work you have here! I have a couple of questions
Thanks for what you have done here! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @gbragi
So, you are not keeping this Flow of commands in memory. It will sequentally handle commands one by one. The Aggregate(Decider+EventRepository) will take that command message, fetch the current state (or events) and store the new state (or events) for every command. You can further optimize this by handling commands concurrently (not sequentally): https://github.com/fraktalio/fmodel/blob/main/application-vanilla/src/jvmMain/kotlin/com/fraktalio/fmodel/application/EventSourcingAggregateActorExtension.kt
BTW, It should be very difficult to design your Decider components to misuse other Decider events. We can use the type system of Kotlin to take care of that: https://fraktalio.com/blog/types-and-functions.html I am also sharing a Demo project that demonstrates different strategies (distributed/monolith):https://github.com/fraktalio/fmodel-demos |
Beta Was this translation helpful? Give feedback.
-
Hi,
You can use this Decider and create a StateStoredAggregate< val myStateStoredAggregate = stateStoredAggregate(
decider = myDeciderInstance,
stateRepository = myRepositoryInstance
) and use that Aggregate. myStateStoredAggregate.handle(flowOf(command1, command2....)) or more conveniently: flowOf(command1, command2....).publishTo(myStateStoredAggregate) Please notice that this aggregate is only fetching and storing/updating the final Podcast trascript/text. Audio is not part of this state. Audio ranges are rather part of the Command payload, and you have to came up with the process of reading that audio file and emit commands in a kotlin Flow: flow {
emit ( /* create a Command by reading Audio in chanks/ranges */ )
}.publishTo(myStateStoredAggregate) |
Beta Was this translation helpful? Give feedback.
Hi @gbragi
Flow
operator:fun <C, E> Flow<C>.publishTo(aggregate: EventSourcingAggregate<C, *, E>): Flow<E> = aggregate.handle(this)