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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With