示例#1
0
        public void PutGetDelete()
        {
            _client.Put("foo/bar", "barfoo");
            var getResult = _client.GetVal("foo/bar");

            Assert.AreEqual(getResult, "barfoo");
            _client.Delete("foo/bar");
        }
        public void CreateRequest()
        {
            string s = client.GetVal("req");

            if (s == null)
            {
                //ogranicenje, redom okidaj inicijalizaciju na cvorovima da ne dobijes 2 lidera
                client.Put("req", "");
                client.Put("leader", myId);
                IsLeader = true;
            }
            else
            {
                IsLeader = false;
            }
            ReqExists = true;
            client.Watch("leader", EtcdElected);
        }
示例#3
0
        /// <summary>
        /// 实现方法
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public string Get(string path)
        {
            var result = Cache.GetWithCache(path, (x) =>
            {
                return(etcdClient.GetVal(x));
            });

            if (result != null)
            {
                return(result);
            }
            throw new SettingException("配置节不存在!");
        }
        public string GetValue(string key)
        {
            DateTime?deadline = GetTimeOut();

            return(_etcdClient.GetVal(key, null, deadline));
        }
示例#5
0
        public string GetVal(string key)
        {
            var rsp = client.GetVal(key);

            return(rsp);
        }