I'm writing my own retry logic with exponential backoff based on Microsoft's sample code on following page: https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/explore-custom-http-call-retries-exponential-backoff
In the following line of code there is a division by 2 that I can't understand:
int delay = Math.Min(m_delayMilliseconds * (m_pow - 1) / 2,
m_maxDelayMilliseconds);
Assume I defined int m_delayMilliseconds = 200
, so we get following delays:
200 * 1 / 2 --> 100 ms
200 * 2 / 2 --> 200 ms
200 * 4 / 2 --> 400 ms
200 * 8 / 2 --> 800 ms
200 * 16 / 2 --> 1600 ms
. . . etc.
What disturbs me is that I get 100 ms for the first delay, but I want the minimum delay to be 200 ms, as defined. Can someone explain this to me?
Aucun commentaire:
Enregistrer un commentaire