I am writing a HTTP client and am trying to decide what would be the correct time to wait before retrying the HTTP request in case the downstream service is for some reason not responding. I intend use a library which has a great feature for scheduling requests. It has a function called Schedule.exponential e.g.
val exponential = Schedule.exponential(10.milliseconds)
The definition is:
/**
* A schedule that always recurs, but will wait a certain amount between
* repetitions, given by `base * factor.pow(n)`, where `n` is the number of
* repetitions so far. Returns the current duration between recurrences.
*/
def exponential(base: Duration, factor: Double = 2.0): Schedule[Clock, Any, Duration] =
delayed(forever.map(i => base * math.pow(factor, i.doubleValue)))
I am not sure what is the best practice on setting the base and factor value. What is reasonable or preferred practice here?