private async Task WaitForCallAsync(LockData @lock, IPageRequestSettings settings) { await @lock.Semaphore.WaitAsync() .ConfigureAwait(false); try { var currentSpan = DateTime.UtcNow - @lock.LastCall; if (currentSpan >= settings.DelayBetweenCalls) { logger.LogDebug("Waiting for a next call having host {Host} is not needed. Current span is {Span}", settings.Host, currentSpan); } else { var toWait = settings.DelayBetweenCalls - currentSpan; logger.LogDebug("Waiting {Delay} for a next call having host {Host}", toWait, settings.Host); await Task.Delay(toWait) .ConfigureAwait(false); } @lock.LastCall = DateTime.UtcNow; } finally { @lock.Semaphore.Release(); } }
public ContentController(IPageService pageService, IContentFragmentService fragmentService, IPageRequestSettings pageRequestSettings) { _pageService = pageService; _fragmentService = fragmentService; _pageRequestSettings = pageRequestSettings; }