Skip to content

Commit

Permalink
Credits and additional documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
reisenberger committed Sep 1, 2019
1 parent ac09e65 commit 0c2743e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public static IEnumerable<TimeSpan> DecorrelatedJitterBackoffV2(TimeSpan medianF

return Enumerate(medianFirstRetryDelay, retryCount, fastFirst, new ConcurrentRandom(seed));

// The original author/credit for this jitter formula is @george-polevoy . Jitter formula used with permission as described at https://github.com/App-vNext/Polly/issues/530#issuecomment-526555979
// Minor adaptations (pFactor = 4.0 and rpScalingFactor = 1 / 1.4d) by @reisenberger, to scale the formula output for easier parameterisation to users.

IEnumerable<TimeSpan> Enumerate(TimeSpan scaleFirstTry, int maxRetries, bool fast, ConcurrentRandom random)
{
// A factor used within the formula to help smooth the first calculated delay.
Expand Down
3 changes: 3 additions & 0 deletions src/Polly.Contrib.WaitAndRetry/ConcurrentRandom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ internal sealed class ConcurrentRandom
// Also note that in concurrency testing, using a 'new Random()' for every thread ended up
// being highly correlated. On NetFx this is maybe due to the same seed somehow being used
// in each instance, but either way the singleton approach mitigated the problem.

// For more discussion of different approaches to randomization in concurrent scenarios: https://github.com/App-vNext/Polly/issues/530#issuecomment-439680613

private static readonly Random s_random = new Random();
private readonly Random _random;

Expand Down

0 comments on commit 0c2743e

Please sign in to comment.