Пример #1
0
        /// <summary>
        /// Get the value for a specified key
        /// </summary>
        /// <returns>The value for the specified key</returns>
        /// <param name="key">Key for which value need to be fetched</param>
        public string Get(string key)
        {
            var rangeResponse = _kvClient.Range(new RangeRequest
            {
                Key = ByteString.CopyFromUtf8(key)
            }, _headers);

            return(rangeResponse.Count != 0 ? rangeResponse.Kvs[0].Value.ToStringUtf8().Trim() : string.Empty);
        }
Пример #2
0
        /// <summary>
        /// Get the etcd response for a specified key
        /// </summary>
        /// <returns>The etcd response for the specified key</returns>
        /// <param name="key">Key for which value need to be fetched</param>
        public RangeResponse Get(string key)
        {
            RangeResponse rangeResponse = new RangeResponse();

            try
            {
                rangeResponse = _kvClient.Range(new RangeRequest
                {
                    Key = ByteString.CopyFromUtf8(key)
                }, _headers);
            }
            catch (Grpc.Core.RpcException)
            {
                ResetConnection();
                throw;
            }
            catch
            {
                throw;
            }

            return(rangeResponse);
        }