What is the best pattern for implementing a entity hierarchies in Akka Severless?

Just getting started with Akka Severless and trying to do something I’ve done with Akka Actors which is to handle a request flow and deterministically produce child actors that encapsulates and rematerializes state for that actor. For instance, if I want an app entity to gate a set of user database entities.

Using Javascript FWIW.



Jeremy Pollock, from Lightbend, here. I’ll let some others comment specifically on the actor hierarchy problem, given that that is their expertise! But there are some important concepts to dig into that might help direct you.

I believe that Actions will be your friend here (Actions :: Akka Serverless Documentation) . Not exactly an Actor - it is stateless - but it can be used as a controller, directing incoming requests to entities. When using Scala/Java, the SDK is more mature in its developer experience (Actions as Controllers :: Akka Serverless Documentation) but that is mainly a wrapper around calling other gRPC services, which is possible in the TS/JS SDK (Calling other services :: Akka Serverless Documentation).

Happy to assist more or explain more, if the above isn’t help. It is good to remember that Akka Serverless does not equal “Akka put into a serverless environment”. There are plenty of similar concepts in the Akka Serverless product and we certainly leverage Akka quite a bit in the underlying platform. But there are differences and not having direct access to the actor system is a big difference.

Hi @maurerbot,

As Jeremy suggested, Actions is the best component to build this kind of coordination between entities.

I would not call it an entity hierarchy tough. Each entity has it own transaction boundary and we can’t have a has relationship. They all live in isolation, in their own transactional bubble.

An entity can refer to another one by id only. And the Action won’t be the parent of any underlying entity, like you have with Actors. The Action will work more as a coordinator where you send a message to one entity and then to a second one and then to a third one, etc.

I hope this clarifies.