Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service fabric - Manual Actor Deactivation for debug/testing purposes

I'm working on a Service Fabric project using ReliableActors with a state. I save and delete things in the state of the actor, and have some re-activation logic that I want to test.

Is there a way to manually deactivate or garbage collect an actor? I would optimally have a test loading data into the actor, deactivating it, and then run some function to ensure that the actor still opperates as intended.

like image 612
Kristoffer la Cour Avatar asked Sep 26 '16 10:09

Kristoffer la Cour


1 Answers

You can adjust the time an actor is considered as idle to force more frequent garbage collection. Code from the documentation:

ActorRuntime.RegisterActorAsync<MyActor>((context, actorType) =>
        new ActorService(context, actorType,
                settings:
                    new ActorServiceSettings()
                    {
                        ActorGarbageCollectionSettings =
                            new ActorGarbageCollectionSettings(idleTimeoutInSeconds: 20, scanIntervalInSeconds:20)
                    }))
        .GetAwaiter()
        .GetResult();

As you can see, there are two parameters: idleTimeoutInSeconds — after that time an actor that is doing nothing could be considered for deactivation; scanIntervalInSeconds — time interval in which service fabric will check actors on their inactivity.

like image 190
cassandrad Avatar answered Sep 19 '22 14:09

cassandrad