0

As part of a Proof of Concept, We're trying to store an ASF Reliable Service or Actor state in a durable data store (like a MongoDB or DocumentDB).

The idea is to provide a custom state manager, that stores data in a database instead of memory (or disk, or whatever ASF does).

So far, We're unable to find documentation of guides showing how to provide our custom state manager to ASF when creating a Reliable Service or Actor.

Any help is highly appreciated.

2 Answers2

0

When you register your Actor type, you can specify your own custom ActorService for it. Into this ActorService, you can inject your own IActorStateManager and IActorStateProvider. Modify Program.cs:

            ActorRuntime.RegisterActorAsync<CustomActor>((context, actorType) => 
                new CustomActorService(context, actorType,
                    /* Inject a factory that creates StateManagers here */
                    stateManagerFactory: (actorBase, provider) => new CustomActorStateManager(actorBase, provider),
                    /* Inject a custom state provider here */
                    stateProvider: new CustomStateProvider()
               )
                ).GetAwaiter().GetResult();

A stateful service is very similar.

HiredMind
  • 1,827
  • 17
  • 27
  • Thank you @HiredMind for your answer. Indeed We've figure out that We can inject custom state providers. The issue is that We don't know how to correctly implement them due to the complexity of the interfaces. We're searching for tutorials or guides, but it seems that there are none. Maybe because the ASF is somehow new. – user9326824 Feb 13 '18 at 13:34
0

The built-in statemanagers are highly specialized (disk, memory, quorum), I'd recommend using the 'regular' way (api) when storing data in a different store.

So for DocumentDb, you'd simply use the client, as you would in any other program.

LoekD
  • 11,402
  • 17
  • 27
  • Thank you for your answer. However, I'm not talking about storing business information on a external database, but rather store the service state. – user9326824 Feb 13 '18 at 13:32