mardi 24 mars 2015

How to model this situation with Actor Model (preferably Akka+Scala)?

Very frequently, I find the following scenario: you have to model some library/service/piece-of-software that gives you the functionality to manage (create, remove) some group of items along with their internal state and their identity. What would be a good starting point or template to do this in order to have a system which is scalable/fault tolerant/location transparent from the very beginning? Some practical examples can be:


1) You have to manage some group of sessions. Each session can have some properties and internal data. From time to time you need to update or query stuff about a particular session (from which you know the ID). You also need to be able to create/remove sessions.


2) You have to manage a group of coffee machines. Each machine can have some properties and internal data. From time to time you need to update or query stuff about a particular machine (from which you know the ID). You also need to be able to create/remove machines.


And so on. My objective is to have some sort of template for this situation, which allows me to spread the items operation across several machines if I need to, to provide an REST interface if I want, to make the system resilient to failure by persisting the state of the items automatically and to code only the parts relevant to the dynamic of the items. I have read about Akka Persistence and I'm aware that perhaps this sounds similar to aggregates and similar concepts of domain driven design (but I never applied it before). Thanks!


P.S.: if the question is not clear, I can post the code I currently have in order to illustrate the point.


Aucun commentaire:

Enregistrer un commentaire