public ImplementationTypeDescriptor Resolve <T>(HotSwapInternalConfiguration <T> config) where T : class { // If none are active/ default, set one if (!config.ImplementationTypes.Any(x => x.IsActive)) { config.ImplementationTypes.OrderBy(x => x.Priority).FirstOrDefault().IsActive = true; } if (config.Flags.AutoRecoveryConfiguration.IsStable(config.ActiveImplementation.Type)) { // Active is stable... return(config.ActiveImplementation); } else { // Active is not stable... config.Flags.AutoRecoveryConfiguration.FailedServices.Add(config.ActiveImplementation.Type); // Find one that is! var next = config.ImplementationTypes // Where not excluded from failover, .Where(x => !x.ExcludeFromFailover) // Where not failed already, .Where(x => !config.Flags.AutoRecoveryConfiguration.FailedServices.Contains(x.Type)) // and then Ordered by priority. .OrderBy(x => x.Priority) .FirstOrDefault(); config.SetActive(next); return(next); } }
public ImplementationTypeDescriptor Resolve <T>(HotSwapInternalConfiguration <T> config) where T : class { // If we don't have a default service, set one if (config.ImplementationTypes.All(x => !x.IsActive)) { config.ImplementationTypes.First().IsActive = true; config.ImplementationTypes.First().IsDefault = true; } return(config.ImplementationTypes.Single(x => x.IsActive)); }
public ImplementationTypeDescriptor Resolve <T>(HotSwapInternalConfiguration <T> config) where T : class { var impl = config.ImplementationTypes.ElementAt(config.Flags.RoundRobinConfiguration.IndexCurrent); if (config.Flags.RoundRobinConfiguration.IsAtMax) { config.Flags.RoundRobinConfiguration.IndexCurrent = 0; } else { config.Flags.RoundRobinConfiguration.IndexCurrent++; } return(impl); }
public FailoverMonitor(HotSwapInternalConfiguration <TInterface> config) { this.config = config; }