vendredi 26 octobre 2018

Constructive comments requested for the following Akka design pattern

I have recently joined an organisation using Akka for a major project. The organisation is not rich in experience with Akka but has been using it for a year. I have been working on the project for 3 months.

We are proposing to implement the following pattern using Akka.

enter image description here

Essentially we are looking to use Akka to provide thread safety and good concurrency . But we wish to separate the handling of business logic entirely from actors by placing all of it in delegates across a Task interface. The Task interface will correspond directly to the messages handled by the actor with a 1 to 1 mapping between messages the actor receives and methods on the interface. This interface will sit in front of the delegate and in front of the Actor thereby hiding the knowledge of messages sent between actors entirely. The Actor and delegate form a 'Parent - Child' relationship. Where the delegate needs to invoke Akka behavior it can do so by calling its 'Parent' across a Parent interface specifically for that purpose. The Actor inherits from ParentActor which implements the Parent interface. All classes in the system will follow this pattern and collaborate across these Task interfaces. The way we see it is that we have the flexibility to swap implementations of the Task interface and when new messages need to be implemented the act of adding a new method to the Task interface enforces the implementation of it in the delegate and the actor. We can also unit test the delegate completely independently of Akka.

May I respectfully request some thoughtful opinions on the pros and cons of this approach.

Aucun commentaire:

Enregistrer un commentaire