Last active
December 17, 2022 17:18
-
-
Save Blind-Striker/e9267552af55bc467d2d43f9a11e4728 to your computer and use it in GitHub Desktop.
SupervisorStrategy example for Akka.Net Medium Article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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