Exemplo n.º 1
0
 public WatchRequest(IEtcdClient etcdClient, EndpointPool endpointPool, bool single, params string[] pathParts)
 {
     _etcdClient  = etcdClient;
     EndpointPool = endpointPool;
     PathParts    = pathParts;
     Single       = single;
 }
        public EtcdStreamDiscovery(string cluster)
        {
#if DEBUG
            _etcd = Etcd.ClientFor(new Uri("http://192.168.1.100:2379"));
            _key  = "/jellyfish/runtime/" + (cluster ?? "Local");
#else
            _etcd = Etcd.ClientFor(new Uri("http://local-etcd:2379"));
            _key  = "/jellyfish/runtime/" + (cluster ?? Environment.GetEnvironmentVariable("JELLYFISH_CLUSTER"));
#endif
            //Console.WriteLine("Reading " + _key);
        }
        public static IConfigurationBuilder AddEtcd(
            this IConfigurationBuilder configurationBuilder,
            IEtcdClient client,
            Action <EtcdOptions>?configureOptions = null)
        {
            var options = new EtcdOptions();

            configureOptions?.Invoke(options);

            return(configurationBuilder.Add(new EtcdConfigurationSource(options, client)));
        }
        internal override EtcdConfigurationChangeToken ProduceChangeToken(IEtcdClient client)
        {
            var changeToken = base.ProduceChangeToken(client);

            client.Watch(keyToMonitor, (oldValue, newValue) =>
            {
                if (callback(oldValue, newValue))
                {
                    Refresh();
                }
            });

            return(changeToken);
        }
 public EtcdConfigurationProvider(EtcdOptions options, IEtcdClient client)
 {
     this.options = options;
     this.client  = client;
     if (options.Refreshers.Any())
     {
         // Register refreshers
         foreach (var refresher in options.Refreshers)
         {
             refresherRegistrations.Add(ChangeToken.OnChange(
                                            () => refresher.ProduceChangeToken(client),
                                            () => Data.Clear()));
         }
     }
 }
Exemplo n.º 6
0
        public void Initialise(IConfigSource source)
        {
            if (source.Configs["Etcd"] == null)
            {
                return;
            }

            IConfig etcdConfig = source.Configs["Etcd"];

            string etcdUrls = etcdConfig.GetString("EtcdUrls", String.Empty);

            if (etcdUrls == String.Empty)
            {
                return;
            }

            m_etcdBasePath   = etcdConfig.GetString("BasePath", m_etcdBasePath);
            m_appendRegionID = etcdConfig.GetBoolean("AppendRegionID", m_appendRegionID);

            if (!m_etcdBasePath.EndsWith("/"))
            {
                m_etcdBasePath += "/";
            }

            try
            {
                string[]   endpoints = etcdUrls.Split(new char[] { ',' });
                List <Uri> uris      = new List <Uri>();
                foreach (string endpoint in endpoints)
                {
                    uris.Add(new Uri(endpoint.Trim()));
                }

                m_client = new EtcdClient(uris.ToArray(), new DefaultSerializer(), new DefaultSerializer());
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[ETCD]: Error initializing connection: " + e.ToString());
                return;
            }

            m_log.DebugFormat("[ETCD]: Etcd module configured");
            m_enabled = true;
        }
 internal virtual EtcdConfigurationChangeToken ProduceChangeToken(IEtcdClient client)
 {
     changeToken = new EtcdConfigurationChangeToken();
     return(changeToken);
 }
Exemplo n.º 8
0
 public DeleteMemberRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts) 
     : base(etcdClient, endpointPool, pathParts) {}
Exemplo n.º 9
0
 public GetVersionRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
 }
Exemplo n.º 10
0
 public CreateMemberRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
     Uris = new List <Uri>();
 }
Exemplo n.º 11
0
 public GetVersionRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts) {}
Exemplo n.º 12
0
 public CompareAndSwapRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts) {}
 public GetLeaderStatisticsRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts) : base(etcdClient, endpointPool, pathParts) {}
 public EtcdConfigurationSource(EtcdOptions options, IEtcdClient client)
 {
     this.options = options;
     this.client  = client;
 }
Exemplo n.º 15
0
 public CompareAndSwapRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
 }
Exemplo n.º 16
0
 public DeleteRequest(IEtcdClient etcdClient, EndpointPool endpointPool, bool isDirectory, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
     IsDirectory = isDirectory;
 }
Exemplo n.º 17
0
 public UpdateMemberPeerUrlsRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts) 
     : base(etcdClient, endpointPool, pathParts)
 {
     Uris = new List<Uri>();
 }
Exemplo n.º 18
0
 protected BaseRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
 {
     EtcdClient = etcdClient;
     _endpointPool = endpointPool;
     _pathParts = pathParts;
 }
Exemplo n.º 19
0
 public UpsertQueueRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
 }
Exemplo n.º 20
0
 public GetLeaderStatisticsRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts) : base(etcdClient, endpointPool, pathParts)
 {
 }
Exemplo n.º 21
0
 protected BaseRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
 {
     EtcdClient    = etcdClient;
     _endpointPool = endpointPool;
     _pathParts    = pathParts;
 }
Exemplo n.º 22
0
 public DeleteMemberRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
 }
Exemplo n.º 23
0
 public UpsertQueueRequest(IEtcdClient etcdClient, EndpointPool endpointPool, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts) {}
Exemplo n.º 24
0
        private void InitEtcdClients()
        {
            _clientWithNoCredentials = new EtcdClient(EtcdLocation);

            _owner = new EtcdClient(EtcdLocation);
            _owner.SetBasicAuthentication(USERNAME_OWNER, "123456");

            _writer = new EtcdClient(EtcdLocation);
            _writer.SetBasicAuthentication(USERNAME_WRITER, "123456");

            _reader = new EtcdClient(EtcdLocation);
            _reader.SetBasicAuthentication(USERNAME_READER, "123456");
        }
Exemplo n.º 25
0
 public DeleteRequest(IEtcdClient etcdClient, EndpointPool endpointPool, bool isDirectory, params string[] pathParts)
     : base(etcdClient, endpointPool, pathParts)
 {
     IsDirectory = isDirectory;
 }
Exemplo n.º 26
0
        public static async Task <T> ReceiveEtcdResponse <T>(this Task <HttpResponseMessage> This, IEtcdClient etcdClient)
            where T : IHaveResponseHeaders
        {
            var response = await This.ReceiveJson <T>();

            var vcResponse = response as IHaveAValueConverter;

            if (vcResponse != null)
            {
                var vc = etcdClient.Config.ValueConverter;
                vcResponse.ValueConverter = () => vc;
            }
            var httpMessage = await This;

            response.Headers = httpMessage.ParseResponseHeaders();
            return(response);
        }
Exemplo n.º 27
0
 public EtcdCompoundClient(IEtcdClient etcdClient, IDisposable disposable)
 {
     _etcdClient = etcdClient;
     _disposable = disposable;
 }