Just the other day, I saw this tweet and knew this post was long overdue:
Is there any list of actor model design patterns ? @AkkaDotNET
— Laurent Lepinay (@foobarcode) June 24, 2015
Quite understandably, people want to know what the design patterns in Akka.NET are! There are quite a few-our team has cataloged 30+ across various areas of the framework so far-but there is also that rarefied set of patterns that show up again, and again, and again.
These patterns cover four broad categories:
- Actor Composition
- Messaging
- Reliability
- Testability
Let’s get going.
Actor Composition Patterns
“Actor Composition” patterns are used to create groups of interrelated actors in order to accomplish specific goals. Patterns of this type help you think about how many actors you need, and how to structure the relationships between them in your hierarchy.
These patterns are aimed at allowing you to use Akka.NET’s supervision hierarchy to your advantage in order to achieve maximum reliability and transparency when working with actors. They will also make your architecture more intuitive.
Composition Pattern: Child-Per-Entity
The Child-per-Entity pattern occurs whenever some /parent
actor is responsible for a domain of entities and elects to represent each entity as its own actor. The parent maintains a mapping to know which child actor corresponds with which domain entity. The /parent
can then lookup/create/kill child actors as domain object enter or leave its going concerns.