private async Task <StartRevalidationStatus?> CanStartRevalidationAsync() { if (!await _singletonService.IsSingletonAsync()) { _logger.LogCritical("Detected another instance of the revalidate job, cancelling revalidations!"); return(StartRevalidationStatus.UnrecoverableError); } if (await _jobState.IsKillswitchActiveAsync()) { _logger.LogWarning("Revalidation killswitch has been activated, retry later..."); return(StartRevalidationStatus.RetryLater); } if (await _throttler.IsThrottledAsync()) { _logger.LogInformation("Revalidations have reached the desired event rate, retry later..."); return(StartRevalidationStatus.RetryLater); } if (!await _healthService.IsHealthyAsync()) { _logger.LogWarning("Service appears to be unhealthy, resetting the desired package event rate. Retry later..."); await _jobState.ResetDesiredPackageEventRateAsync(); return(StartRevalidationStatus.RetryLater); } if (await _jobState.IsKillswitchActiveAsync()) { _logger.LogWarning("Revalidation killswitch has been activated after the throttle and health check, retry later..."); return(StartRevalidationStatus.RetryLater); } return(null); }