Ejemplo n.º 1
0
 public Etcd(EtcdRegistryConfiguration config, IOcelotLoggerFactory factory, IEtcdClientFactory clientFactory)
 {
     logger                 = factory.CreateLogger <Etcd>();
     this.config            = config;
     this.etcdClientFactory = clientFactory;
     Services               = new List <Service>();
 }
Ejemplo n.º 2
0
        public EtcdFileConfigurationRepository(
            Cache.IOcelotCache <FileConfiguration> cache,
            IInternalConfigurationRepository repo,
            IEtcdClientFactory factory,
            IOcelotLoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger <EtcdFileConfigurationRepository>();
            _cache  = cache;

            var internalConfig = repo.Get();

            _configurationKey = "InternalConfiguration";

            string token = null;

            if (!internalConfig.IsError)
            {
                token             = internalConfig.Data.ServiceProviderConfiguration.Token;
                _configurationKey = !string.IsNullOrEmpty(internalConfig.Data.ServiceProviderConfiguration.ConfigurationKey) ?
                                    internalConfig.Data.ServiceProviderConfiguration.ConfigurationKey : _configurationKey;
            }

            var config = new EtcdRegistryConfiguration(
                internalConfig.Data.ServiceProviderConfiguration.Host,
                internalConfig.Data.ServiceProviderConfiguration.Port, _configurationKey);

            _etcdClient = factory.Get(config);
        }
Ejemplo n.º 3
0
        public EtcdClient Get(EtcdRegistryConfiguration config)
        {
            if (config.Host != this.host || config.Port != this.port)
            {
                this.host   = config.Host;
                this.port   = config.Port;
                this.client = new EtcdClient(config.Host, config.Port);
            }

            return(client.GetEtcdClient().GetClient());
        }