Dont' retry if remaining time isn't enough.

This commit is contained in:
serkar 2016-12-01 17:01:36 -08:00
Родитель e9d57c4300
Коммит 30a0551475
1 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -45,14 +45,16 @@ namespace Microsoft.Azure.EventHubs
double nextRetryInterval = Math.Pow(this.retryFactor, (double)currentRetryCount);
long nextRetryIntervalSeconds = (long)nextRetryInterval;
long nextRetryIntervalMilliseconds = (long)((nextRetryInterval - (double)nextRetryIntervalSeconds) * 1000);
if (remainingTime.TotalSeconds < Math.Max(nextRetryInterval, ClientConstants.TimerToleranceInSeconds))
{
return null;
}
TimeSpan retryAfter = this.minimumBackoff.Add(TimeSpan.FromMilliseconds(nextRetryIntervalSeconds * 1000 + nextRetryIntervalMilliseconds));
retryAfter = retryAfter.Add(TimeSpan.FromSeconds(baseWaitTimeSecs));
// Don't retry if remaining time isn't enough.
if (remainingTime.TotalSeconds < Math.Max(retryAfter.TotalSeconds, ClientConstants.TimerToleranceInSeconds))
{
return null;
}
return retryAfter;
}