Replies: 3 comments 1 reply
-
Process = Decider + SagaBy looking closely at the signature of the Process component we can see the resemblance to a Decider component, where interface Process<AR, S, Ei, A> {
val ingest: (AR, S) -> Flow<Ei>
val evolve: (S, Ei) -> S
val pending: (S) -> Flow<A>
val initialState: S
}
interface Decider<in C, S, E> {
val decide: (C, S) -> Flow<E>
val evolve: (S, E) -> S
val initialState: S
}
interface Saga<in AR, out A> {
val react: (AR) -> Flow<A>
} The You do not have a |
Beta Was this translation helpful? Give feedback.
-
Pay attention to
|
Beta Was this translation helpful? Give feedback.
-
Simple is hard!Keeping the number of functions to 3 was hard! 1. decide: (C, S) -> Flow<E>
2. evolve: (S, E) -> S
3. react: (AR) -> Flow<A>
Keeping the number of types to 3 was hard!
Wrapping these functions in 3 robust components (that will not leak or couple) was hard!
Enabling switching from state-stored to event-sourced systems, or the other way around, enabling adoption, and minimizing the risk was hard!
|
Beta Was this translation helpful? Give feedback.
-
This discussion is an attempt to formalize a Process Manager type.
The type formalizes a pure algorithm, and we do not care about how and from where state/events are coming from (or saved).
The whole idea of this type comes from Jérémie Chassaing, and you can find more info about it here
Domain
AR
/ActionResult will trigger your Process (manager) by callingingest: (AR, S) -> Flow<Ei>
.AR
can beE1
/Event of your system,E2
/Event of another system, or HTTP response of some service that you are calling.S
represents the current state of your Process (aToDo
list). The result is a list/flow of new event types (Ei
) that this process can publish.Ei
) to evolve the state of your process:evolve: (S, Ei) -> S
. This relation between events and state gives us the opportunity to either store the state of this Process (manager) as a series of events (Ei
) / event sourced, or as a plain old state (S
) / state stored.pending: (S) -> Flow<A>
. These actions (A
) can be a Command of your system, a Command of another system, HTTP request ...This type maintains a symmetric relation between the state and events of a
single
system, enabling a robust integration pattern by loosely coupling systems. Every S/State of any system is always backed out of its events, sharing nothing!Infrastructure
Application
Two flavors: State Stored and Event Sourced
The algorithm is the same! The way we store the state (eg. a ToDo list) of the Process Manager is different:
state
(ToDo list) in some table/documentevents
that potentially can build that state/projection (ToDo list)If your system is event-sourced (you use event sourcing), events are the whole truth! Any state/projection you have in your system can evolve from these events! The event-sourced process manager will ensure that integration components align with this fact, otherwise, you might directly evolve the state of your process manager/integration component with
events
of another system. This is a very robust way of integrating systems. Events are all you need to back up, and there is no need to back up any projection/state.Beta Was this translation helpful? Give feedback.
All reactions