Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public FailoverMonitor(HotSwapInternalConfiguration <TInterface> config)
 {
     this.config = config;
 }