/// <inheritdoc/> public TAWSClient FailOverToSecondaryRegion(Throttle throttle) { // Stop timer if no errors if (throttle.ConsecutiveErrorCount == 0) { _secondaryRegionFailoverTimer.Stop(); _secondaryRegionFailoverActivated = false; } // Start timer on first error else if (throttle.ConsecutiveErrorCount > 0 && !_secondaryRegionFailoverTimer.Enabled) { _secondaryRegionFailoverTimer.Start(); } // Failover to Secondary Region if available // Reaching maximum consecutive error counts or timeout if (throttle.ConsecutiveErrorCount >= _maxErrorsCountBeforeFailover || _secondaryRegionFailoverActivated) { _logger?.LogWarning($"FailoverSink id {Id} max consecutive errors count {throttle.ConsecutiveErrorCount}, trying to fail over to secondary region."); // Setup client with Secondary Region var client = _failoverSinkRegionStrategy.GetSecondaryRegionClient(); if (client is not null) { // Reset Throttle throttle.SetSuccess(); _logger?.LogInformation($"FailoverSink id {Id} after reaching max consecutive errors limit to {throttle.ConsecutiveErrorCount}, failed over successfully to secondary region {_failoverSinkRegionStrategy.GetCurrentRegion().Region.SystemName}."); return(client); } else { _logger?.LogError($"FailoverSink id {Id} fail over to secondary region unsuccessful, looks like all of secondary regions are currently down."); } } return(null); }