예제 #1
0
        /// <summary>
        /// Creates a new RemoteHostPool using the specified system name and liveliness checker.
        /// </summary>
        /// <param name="reachabilityChecker">A delegate that checks if a given host is reachable or not. Used for background checks of unreachable hosts.
        /// Should return true if the host is reachable, or false if it is unreachable. It should not throw an exception.</param>
        /// <param name="log">An implementation of <see cref="ILog"/> used for logging.</param>
        public RemoteHostPool(
            DeploymentIdentifier deploymentIdentifier
            , IServiceDiscoverySource discovery
            , ReachabilityChecker reachabilityChecker
            , Func <DiscoveryConfig> getDiscoveryConfig
            , ILog log
            , HealthMonitor healthMonitor
            , MetricsContext metrics
            )
        {
            DiscoverySource      = discovery;
            DeploymentIdentifier = deploymentIdentifier;
            ReachabilityChecker  = reachabilityChecker;
            GetDiscoveryConfig   = getDiscoveryConfig;
            Log = log;
            ReachabilityBroadcaster = new BroadcastBlock <ServiceReachabilityStatus>(null);
            Health = healthMonitor.Get(discovery.Deployment);
            Health.SetHealthData(HealthData);

            ReachableHosts            = new List <RemoteHost>();
            UnreachableHosts          = new List <RemoteHost>();
            EndPointsChangedBlockLink = discovery.EndPointsChanged.LinkTo(new ActionBlock <EndPointsResult>(_ => ReloadEndpoints(_)));
            ReloadEndpoints(discovery.Result);
            Metrics = metrics;
            var metricsContext = Metrics.Context(DiscoverySource.Deployment);

            metricsContext.Gauge("ReachableHosts", () => ReachableHosts.Count, Unit.Custom("EndPoints"));
            metricsContext.Gauge("UnreachableHosts", () => UnreachableHosts.Count, Unit.Custom("EndPoints"));
        }
예제 #2
0
        /// <summary>
        /// Creates a new RemoteHostPool using the specified system name and liveliness checker.
        /// </summary>
        /// <param name="reachabilityChecker">A delegate that checks if a given host is reachable or not. Used for background checks of unreachable hosts.
        /// Should return true if the host is reachable, or false if it is unreachable. It should not throw an exception.</param>
        /// <param name="log">An implementation of <see cref="ILog"/> used for logging.</param>
        public RemoteHostPool(
            DeploymentIdentifier deploymentIdentifier
            , IServiceDiscoverySource discovery
            , ReachabilityChecker reachabilityChecker
            , Func <DiscoveryConfig> getDiscoveryConfig
            , ILog log
            , HealthMonitor healthMonitor
            )
        {
            DiscoverySource      = discovery;
            DeploymentIdentifier = deploymentIdentifier;
            ReachabilityChecker  = reachabilityChecker;
            GetDiscoveryConfig   = getDiscoveryConfig;
            Log = log;
            ReachabilityBroadcaster = new BroadcastBlock <ServiceReachabilityStatus>(null);
            Health = healthMonitor.Get(discovery.Deployment);
            Health.SetHealthData(HealthData);

            ReachableHosts            = new List <RemoteHost>();
            UnreachableHosts          = new List <RemoteHost>();
            EndPointsChangedBlockLink = discovery.EndPointsChanged.LinkTo(new ActionBlock <EndPointsResult>(_ => ReloadEndpoints(_)));
            ReloadEndpoints(discovery.Result);
        }