How should I structure actors of perseverance in Akka's tenacity?

How should I structure my Actors in Akka persistent (Eventsourcing / CQRS)?

  • Hierarchical
  • Parallel

I have these domain objects in an ecommerce application

  • User. User can create an account
  • Save - User can create storage
  • Product. The user can add products to it.
  • Basket. The user can add any product from the user's other stores to the cart.

So my question is: how do I structure my actors? What are the advantages and disadvantages of choosing one of them, especially with regard to the e-commerce domain model?

akka actor structure

+5
source share
1 answer

I think your question is more about the boundaries of your aggregates.

In any case, there should be no hierarchical structure between the aggregates. Aggregates must be independent of each other. No parenting with child.

According to your description. There is a user aggregate that can create stores and add products to them.

The magazine may be a separate unit initiated by the user unit. Please note that the fact that a user can create a Store does not mean that they must have a parent / child relationship. This is more about access control. The store is created by the user, and only this user has the right to add products to him.

However, the product appears to be an entity within the Store aggregate.

Your fourth example: “Shopping Cart - The user can add any product from other user's stores to the shopping cart”, shows something completely different. You have two types of users. Users who create and manage the stores and consumers of this store. They do not match, and they should be modeled in different ways.

Try to simulate your company’s domain without trying to reuse objects just because they are similar.

+3
source

Source: https://habr.com/ru/post/1237323/


All Articles