Exemplo n.º 1
0
        private IServiceDiscoveryProvider GetServiceDiscoveryProvider(ServiceProviderConfiguration serviceConfig, string serviceName)
        {
            if (serviceConfig.Type == "ServiceFabric")
            {
                var config = new ServiceFabricConfiguration(serviceConfig.Host, serviceConfig.Port, serviceName);
                return(new ServiceFabricServiceDiscoveryProvider(config));
            }

            var consulRegistryConfiguration = new ConsulRegistryConfiguration(serviceConfig.Host, serviceConfig.Port, serviceName);

            return(new ConsulServiceDiscoveryProvider(consulRegistryConfiguration, _factory));
        }
        private IServiceDiscoveryProvider GetServiceDiscoveryProvider(ServiceProviderConfiguration serviceConfig, string serviceName)
        {
            if (serviceConfig.Type?.ToLower() == "servicefabric")
            {
                var config = new ServiceFabricConfiguration(serviceConfig.Host, serviceConfig.Port, serviceName);
                return(new ServiceFabricServiceDiscoveryProvider(config));
            }

            if (serviceConfig.Type?.ToLower() == "eureka")
            {
                return(new EurekaServiceDiscoveryProvider(serviceName, _eurekaClient));
            }

            var consulRegistryConfiguration = new ConsulRegistryConfiguration(serviceConfig.Host, serviceConfig.Port, serviceName, serviceConfig.Token);

            return(new ConsulServiceDiscoveryProvider(consulRegistryConfiguration, _factory, _consulFactory));
        }
        private IServiceDiscoveryProvider GetServiceDiscoveryProvider(ServiceProviderConfiguration serviceConfig, string serviceName)
        {
            if (serviceConfig.Type == "ServiceFabric")
            {
                var config = new ServiceFabricConfiguration(serviceConfig.Host, serviceConfig.Port, serviceName);
                return(new ServiceFabricServiceDiscoveryProvider(config));
            }

            //if (serviceConfig.Type == "Steeltoe")
            //{
            //    var steeltoeConfig = new Steeltoe.SteeltoeRegistryConfiguration(serviceConfig.Host, serviceConfig.Port, serviceName);
            //    return new Steeltoe.SteeltoeServiceDiscoveryProvider(steeltoeConfig, _factory);
            //}

            var consulRegistryConfiguration = new ConsulRegistryConfiguration(serviceConfig.Host, serviceConfig.Port, serviceName);

            return(new ConsulServiceDiscoveryProvider(consulRegistryConfiguration, _factory));
        }
Exemplo n.º 4
0
        private IServiceDiscoveryProvider GetServiceDiscoveryProvider(ServiceProviderConfiguration config, string key)
        {
            if (config.Type?.ToLower() == "servicefabric")
            {
                var sfConfig = new ServiceFabricConfiguration(config.Host, config.Port, key);
                return(new ServiceFabricServiceDiscoveryProvider(sfConfig));
            }

            foreach (var serviceDiscoveryFinderDelegate in _delegates)
            {
                var provider = serviceDiscoveryFinderDelegate?.Invoke(_provider, config, key);
                if (provider != null)
                {
                    return(provider);
                }
            }

            return(null);
        }
Exemplo n.º 5
0
        private Response <IServiceDiscoveryProvider> GetServiceDiscoveryProvider(ServiceProviderConfiguration config, DownstreamReRoute reRoute)
        {
            if (config.Type?.ToLower() == "servicefabric")
            {
                var sfConfig = new ServiceFabricConfiguration(config.Host, config.Port, reRoute.ServiceName);
                return(new OkResponse <IServiceDiscoveryProvider>(new ServiceFabricServiceDiscoveryProvider(sfConfig)));
            }

            if (_delegates != null)
            {
                var provider = _delegates?.Invoke(_provider, config, reRoute);

                if (provider.GetType().Name.ToLower() == config.Type.ToLower())
                {
                    return(new OkResponse <IServiceDiscoveryProvider>(provider));
                }
            }

            return(new ErrorResponse <IServiceDiscoveryProvider>(new UnableToFindServiceDiscoveryProviderError($"Unable to find service discovery provider for type: {config.Type}")));
        }
Exemplo n.º 6
0
 public ServiceFabricServiceDiscoveryProvider(ServiceFabricConfiguration configuration)
 {
     _configuration = configuration;
 }