Open richardimaoka opened 7 years ago
Write these at the end? (as it will be giving too much info to beginners)
Note: implementation details can change so don't go in too much
BackoffSupervisor
- companion obj with different factory methods
def props(options: BackoffOptions): Props
def props(childProps, childName, ..., randomFactor, replyWhileStopped): Props
strategy
in the below signature?def propsWithSupervisorStrategy(childProps, childName, ..., randomFactory, strategy, replyWhileStopped): Props
Note that these factory methods accepts childProps
i.e. child actor definition as a parameter.
Also this companion object defines...:
GetCurrentChild
<- send this to BackoffSupervisor
then you get BackoffSupervisor
's child (ask (!) pattern)GetRestartCount
<- send this to BackoffSupervisor
then you get the restart count of the child child (ask (!) pattern)HandleBackoff
- trait having message-sending implementation with Backoff algorithm
BackoffOptions
- a companion to create Backoff "Options" to be passed to BackoffSupervisor
factory metods (i.e. def props
)
Note that these factory methods accepts childProps
i.e. child actor definition as a parameter.
BackoffSupervisor
actually has two concrete classes - it's confusing but in two separate files:
final class BackoffSupervisor
in BAckoffSupervisor.scala
BackoffSupervisor
objectprivate class BackoffOnRestartSupervisor
in BackoffOnRestartSupervisor.scalaThese two classes are instantiated as follows, when creating backoff options:
BackoffOption
's factory methods to create BackoffOption
onFailure()
onStop()
BackoffSupervisor
's factory methods props()
to create BackoffOption
insideThen, BackoffOptionsImpl
-> def props = { backoffType match { ... } }
(this is too much implementation detail, so you might not want to go into this in the article)
Pic to illustrate restart with back off Link to actor lifecycle Pic to illustrate exponential interval
Normal situation, ask and reply -> vine to illustrate
When target fails, DB down, web server down
Retry ... sometimes it works ok (slow target), sometimes not
Typical configuration, or hard coding ... pseudo code to specify reply
Problem ... slowness could be resolved by quicker retries However, 1000s of clients doing quick retries... target slowed down by retries
Conclusion, retry interval to change over time
Break down to multiple issues / articles