Replies: 3 comments 3 replies
-
You have exactly pin-pointed the problem. What decides the state is the entire history of events, not just the last one. |
Beta Was this translation helpful? Give feedback.
-
I also think that |
Beta Was this translation helpful? Give feedback.
-
One improvement that we could finally action in relation to this is adding a However that still does not help the user understand why the button might not be available in some |
Beta Was this translation helpful? Give feedback.
-
Internally we now have an event based model, i.e. we append events to the
Cfd
and build (hydrate) the state of theCfd
from the list of events when we load it.In the projection we still have states - mostly because the user interface has to be able to display something to the user, and a textual state (
Pending Setup
,Contract Setup
,Open
, ...) is easier to perceive than a list of events.In a way the state is an aggregate of the events.
When we
apply
the events inporjection::Cfd
we always set a state depending on the event, meaning that the last event basically decides the state. While this sounds good in theory, it can have weird side effects.Problems can happen, when a protocol fails because the
Cfd
was put into a closed state while another protocol was ongoing. This can for example happen during a rollover. If we trigger a collaborative settlement during rollover, the rollover will fail upon finishing up, because the collaborative settlement has priority (as per the changes in ##1359).Note: Making collaborative settlement and rollover mutually exclusive would be possible, but then we have to ensure that we actually always record a
Completed
event for a protocol. At the moment this is not guaranteed, because if the application is restarted mid protocol the protocol actor will be gone and we might never record a failure.We could solve this by ensuring that we always properly complete a protocol. This could involve some kind of housekeeping task upon startup.
We could also redefine what it means to record failure events. Such kind of events do not necessarily guarantee a 1:1 mapping to a state; i.e. if rollover fails I have to know why it failed to reason about mapping to
Open
or another state (at the moment it's alwaysOpen
). But we don't record the reason in theEvent
. We could also say that upon failure I have to take the previous event history into account to decide what my state it.I think another part of this problem comes from mapping the events to state in general. We discussed on several occasions that the state model in the projection "should change". I wanted to open a discussion on how we see this evolve in the future.
Beta Was this translation helpful? Give feedback.
All reactions