Ejemplo n.º 1
0
 public void Dispose()
 {
     MasterEnvironmentLoadBalancer.Dispose();
     OriginatingEnvironmentLoadBalancer.Dispose();
     _configBlockLink?.Dispose();
     _healthCheck.Dispose();
 }
Ejemplo n.º 2
0
        public async Task <Node> GetNode()
        {
            await _initTask.ConfigureAwait(false);

            var node = await OriginatingEnvironmentLoadBalancer.GetNode().ConfigureAwait(false);

            if (node != null)
            {
                _getHealthStatus = () => HealthCheckResult.Healthy($"Discovered on '{_originatingEnvironmentDeployment.DeploymentEnvironment}'");
                return(node);
            }

            if (!GetConfig().EnvironmentFallbackEnabled)
            {
                _getHealthStatus = BadHealthForLimitedPeriod(HealthCheckResult.Unhealthy($"Not deployed on '{_originatingEnvironmentDeployment.DeploymentEnvironment}'. Deployement on '{_masterDeployment.DeploymentEnvironment}' is not used, because fallback is disabled by configuration"));
                throw new ServiceUnreachableException("Service is not deployed", unencrypted: new Tags {
                    { "serviceName", _serviceName }, { "environment", _originatingEnvironmentDeployment.DeploymentEnvironment }
                });
            }

            node = await MasterEnvironmentLoadBalancer.GetNode().ConfigureAwait(false);

            if (node != null)
            {
                _getHealthStatus = () => HealthCheckResult.Healthy($"Discovered on '{_masterDeployment.DeploymentEnvironment}'");
                return(node);
            }

            _getHealthStatus = BadHealthForLimitedPeriod(HealthCheckResult.Unhealthy($"Not deployed neither on '{_originatingEnvironmentDeployment.DeploymentEnvironment}' or '{_masterDeployment.DeploymentEnvironment}'"));
            throw new ServiceUnreachableException("Service is not deployed", unencrypted: new Tags {
                { "serviceName", _serviceName }, { "environment", _originatingEnvironmentDeployment.DeploymentEnvironment }, { "masterEnvironment", _masterDeployment.DeploymentEnvironment }
            });
        }