Is there a design pattern that would be commonly applied to facilitate the separation of concerns between an Akka actor's message handling and the business logic that it implements?
Asked
Active
Viewed 150 times
1
-
Take a look at this answer: http://stackoverflow.com/questions/37055472/scala-akka-discrete-event-simulation/37073030#37073030 – Ramón J Romero y Vigil Oct 13 '16 at 12:01
1 Answers
1
Not specific to Akka but I think one reasonable approach is to put the logic into traits a la the "cake" pattern:
http://www.cakesolutions.net/teamblogs/2011/12/19/cake-pattern-in-depth
Though it's more broadly a pattern for doing dependency injection, you can apply with actors as well. Your trait can contain re-usable functions you can mix in and Using the self-type annotation in your trait can theoretically allow your business logic code to access actor state (only if absolutely necessary).

simonl
- 1,240
- 7
- 19