Esempio n. 1
0
        /// <inheritdoc />
        public ConsulNodeSourceFactory(ILog log, ConsulClient consulClient, Func <DeploymentIdentifier,
                                                                                  ConsulNodeSource> createConsulNodeSource, IDateTime dateTime, Func <ConsulConfig> getConfig, IHealthMonitor healthMonitor)
        {
            Log                    = log;
            ConsulClient           = consulClient;
            CreateConsulNodeSource = createConsulNodeSource;
            DateTime               = dateTime;
            GetConfig              = getConfig;

            _serviceListHealthMonitor = healthMonitor.SetHealthFunction("ConsulServiceList", () => new ValueTask <HealthCheckResult>(_healthStatus)); // nest under "Consul" along with other consul-related healths.
            Task.Run(() => GetAllLoop());
        }
Esempio n. 2
0
        public void Setup()
        {
            _dateTimeFake = new DateTimeFake();

            healthMonitor = Substitute.For <IHealthMonitor>();
            healthMonitor.SetHealthFunction(Arg.Any <string>(), Arg.Any <Func <HealthCheckResult> >(), Arg.Any <Func <Dictionary <string, string> > >())
            .Returns(c =>
            {
                _getHealthResult = c.Arg <Func <HealthCheckResult> >();
                return(new ComponentHealthMonitor(c.Arg <string>(), _getHealthResult));
            });
        }
Esempio n. 3
0
        public ConfigCache(IConfigItemsSource source, IConfigurationDataWatcher watcher, ILog log, IHealthMonitor healthMonitor)
        {
            Source = source;
            Log    = log;
            ConfigChangedBroadcastBlock = new BroadcastBlock <ConfigItemsCollection>(null);

            watcher.DataChanges.LinkTo(new ActionBlock <bool>(nothing => Refresh()));

            _healthMonitor = healthMonitor;
            _healthMonitor.SetHealthFunction(nameof(ConfigCache), HealthCheck);
            Refresh(false).GetAwaiter().GetResult();
        }
Esempio n. 4
0
        public ConfigObjectCreator(Type objectType, ConfigCache configCache, UsageTracking usageTracking, ILog log, IHealthMonitor healthMonitor)
        {
            UsageTracking = usageTracking;
            Log           = log;
            ObjectType    = objectType;
            ConfigCache   = configCache;
            ConfigPath    = GetConfigPath();
            Validator     = new DataAnnotationsValidator.DataAnnotationsValidator();

            Create();
            ConfigCache.ConfigChanged.LinkTo(new ActionBlock <ConfigItemsCollection>(c => Create()));
            InitializeBroadcast();

            healthMonitor.SetHealthFunction($"{ObjectType.Name} Configuration", HealthCheck);
        }
Esempio n. 5
0
 public LoadBalancer(
     IDiscovery discovery,
     DeploymentIdentifier deploymentIdentifier,
     ReachabilityCheck reachabilityCheck,
     TrafficRoutingStrategy trafficRoutingStrategy,
     Func <Node, DeploymentIdentifier, ReachabilityCheck, Action, NodeMonitoringState> createNodeMonitoringState,
     IHealthMonitor healthMonitor,
     IDateTime dateTime,
     ILog log)
 {
     DeploymentIdentifier      = deploymentIdentifier;
     Discovery                 = discovery;
     ReachabilityCheck         = reachabilityCheck;
     TrafficRoutingStrategy    = trafficRoutingStrategy;
     CreateNodeMonitoringState = createNodeMonitoringState;
     DateTime       = dateTime;
     Log            = log;
     _healthMonitor = healthMonitor.SetHealthFunction(DeploymentIdentifier.ToString(), () => new ValueTask <HealthCheckResult>(_healthStatus));
 }
Esempio n. 6
0
 public AggregatingHealthStatus(string componentName, IHealthMonitor healthMonitor)
 {
     healthMonitor.SetHealthFunction(componentName, HealthCheck);
 }
Esempio n. 7
0
 public PassiveAggregatingHealthCheck(IDateTime dateTime, string componentName, IHealthMonitor healthMonitor, ReportingStrategy reportingStrategy)
 {
     _reportingStrategy = reportingStrategy;
     DateTime           = dateTime;
     healthMonitor.SetHealthFunction(componentName, GetHealthStatusAndCleanup);
 }