Skip to content

Instantly share code, notes, and snippets.

@Blind-Striker
Last active December 17, 2022 17:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blind-Striker/e9267552af55bc467d2d43f9a11e4728 to your computer and use it in GitHub Desktop.
Save Blind-Striker/e9267552af55bc467d2d43f9a11e4728 to your computer and use it in GitHub Desktop.
SupervisorStrategy example for Akka.Net Medium Article
protected override SupervisorStrategy SupervisorStrategy()
{
return new OneForOneStrategy(// or AllForOneStrategy
maxNumberOfRetries: 10, // opsiyonel
duration: TimeSpan.FromSeconds(30), // opsiyonel
decider: x =>
{
// ArithmeticException Actor durduracak kadar kritik bir hata değil
// dolayısıyla devam etmesinde bir sakınca yok.
if (x is ArithmeticException) return Directive.Resume;
// Bu tip bir hatada ne yapılacağını bilmiyorsak, bir üste havale edebilir.
else if (x is InsanelyBadException) return Directive.Escalate;
// Böyle bir durumda artık Actor'ü kurtarmamızın ihtimali yok
// durdurmamız gerekiyor.
else if (x is NotSupportedException) return Directive.Stop;
// geri kalan her durumda Actor'ü yeniden başlatacağız.
else return Directive.Restart;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment