I create a reliable, wealthy, service actor.
Question:
Is there a way to pass initialization data while creating an actor ( ActorProxy.Create()) proxy server ? In principle, the equivalent of a constructor for my actor.
Current thoughts:
I can achieve this by executing a proxy creation call with an actor method call responsible for initializing the state.
eg.
ITokenManager tokenActor = ActorProxy.Create<IMyActor>(actorId, "AppName");
await tokenActor.InitializeAsync(desiredInitialState);
My concern for this approach:
- This operation is not atomic. This may leave my actor in an inconsistent state.
- This initialization method is now available throughout the entire life cycle of the actor, which is undesirable.
source
share