Refactoring a bad actor to FSM
Now that we have recapped what actors are and understood some of the core features of the Akka actor system, it's time to dive in to our first big refactor. In the Chapter 1, Building a Better Reactive App, I called out the fact that the current implementation of the OrderManager was a poor use of an actor as it was mixing in too much usage of Futures.
This is a complicated actor, in that, it needs to fetch a bunch of data and then make various decisions on whether to stop or continue based on that data. When I end up with something like this, I usually turn to a finite-state machine (FSM) based actor. This is probably a different use case than what was originally intended or thought of as an FSM, but I think the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access