/// <summary> /// Get the value for a specified key in async /// </summary> /// <returns>The value for the specified key</returns> /// <param name="key">Key for which value need to be fetched</param> public async Task <string> GetAsync(string key) { var rangeResponse = await _kvClient.RangeAsync(new RangeRequest { Key = ByteString.CopyFromUtf8(key) } , _headers); return(rangeResponse.Count != 0 ? rangeResponse.Kvs[0].Value.ToStringUtf8().Trim() : string.Empty); }
public async Task <string> Get(string key) { var resp = await kvClient.RangeAsync(new RangeRequest() { Key = ByteString.CopyFromUtf8(key) }); try { return(resp.Kvs[0].Value.ToStringUtf8()); } catch (Exception ex) { return(null); } }
public async Task <string> Get(string key) { var resp = await kvClient.RangeAsync(new RangeRequest() { Key = ByteString.CopyFromUtf8(key) }); try { return(resp.Kvs[0].Value.ToStringUtf8()); } catch (Exception ex) { throw new Exception($"Key {key} doesn't exist in etcd - {ex.Message}"); } }
/// <summary> /// Get the etcd response for a specified key in async /// </summary> /// <returns>The etcd response for the specified key</returns> /// <param name="key">Key for which value need to be fetched</param> public async Task <RangeResponse> GetAsync(string key) { RangeResponse rangeResponse = new RangeResponse(); try { rangeResponse = await _kvClient.RangeAsync(new RangeRequest { Key = ByteString.CopyFromUtf8(key) } , _headers); } catch (Grpc.Core.RpcException) { ResetConnection(); throw; } catch { throw; } return(rangeResponse); }