jan-gerling / FLOCKA

1 stars 1 forks source link

Sagas implementation Suggestions #40

Closed jan-gerling closed 5 years ago

jan-gerling commented 5 years ago

Here a suggestion on how to restructure the Saga Execution mostly for better maintenance and performance. The Saga Logic is still the same but with same differences.

Major changes:

Moved execution logic in SagaOperation and Saga

The SagaOperation case class now handles its state internally, validates itself and executes reverse and forward operation. The advantage is that it is easier to maintain.

The Saga class now handles its own state internally anbd decides on when to proceed to the next step or rollback. It also composes the SagaCompleted and SagaFailed Events.

Removed StepCompleted, StartSagaExecution and StepRolledback events from SagaComs

I think the overhead of storing these events, that are not necessary for consistency, is not worth the rare occasions, where it might speed up the SagaExecution.

Refactored SagasExecutionControllerActor to inherit from PersistentActor instead of PersistentActorBase

removed loads of the unused overhead from PersistentActorBase that was not needed for this actor

Current Issues

The Sagas takes to long and times out: It is not stopped and rolledback, but keeps executing. The requester thinks it wasn't done though.

The Node of a SEC dies: We will not recover the SAGA, because we never recover the individual SEC, even though it is persisted in the journal.

PSilvestre commented 5 years ago

So regarding the first issue, my suggestion is: