Пример #1
0
 public async Task <IKeyEvent> Execute()
 {
     try
     {
         return(await TargetUrl
                .Conditionally(IsDirectory, x => x.SetQueryParam(Constants.Etcd.Parameter_Directory, Constants.Etcd.Parameter_True))
                .Conditionally(IsDirectory && Recursive.HasValue && Recursive.Value, x => x.SetQueryParam(Constants.Etcd.Parameter_Recursive, Constants.Etcd.Parameter_True))
                .DeleteAsync()
                .ReceiveEtcdResponse <KeyEvent>(EtcdClient));
     }
     catch (FlurlHttpException e)
     {
         throw e.ProcessException();
     }
 }
Пример #2
0
 private async Task <IKeyEvent> Execute(bool isByValue)
 {
     try
     {
         return(await TargetUrl
                .Conditionally(isByValue, x => x.SetQueryParam(Constants.Etcd.Parameter_PrevValue, ExpectedValue))
                .Conditionally(!isByValue, x => x.SetQueryParam(Constants.Etcd.Parameter_PrevIndex, ExpectedIndex))
                .DeleteAsync()
                .ReceiveEtcdResponse <KeyEvent>(EtcdClient));
     }
     catch (FlurlHttpException e)
     {
         throw e.ProcessException();
     }
 }
Пример #3
0
 public async Task <IKeyEvent> Execute()
 {
     try
     {
         return(await TargetUrl
                .Conditionally(Quorum.HasValue && Quorum.Value, x => x.SetQueryParam(Constants.Etcd.Parameter_Quorum, Constants.Etcd.Parameter_True))
                .Conditionally(Recursive.HasValue && Recursive.Value, x => x.SetQueryParam(Constants.Etcd.Parameter_Recursive, Constants.Etcd.Parameter_True))
                .Conditionally(HttpGetTimeout != null, x => x.WithTimeout(HttpGetTimeout.GetValueOrDefault()))
                .GetAsync()
                .ReceiveEtcdResponse <KeyEvent>(EtcdClient));
     }
     catch (FlurlHttpException e)
     {
         throw e.ProcessException();
     }
 }
Пример #4
0
        private async Task <IKeyEvent> Execute(bool isByValue)
        {
            var values = new FormBodyBuilder()
                         .Add(Constants.Etcd.Parameter_Value, Value)
                         // ReSharper disable once PossibleInvalidOperationException
                         .Add(Ttl.HasValue, Constants.Etcd.Parameter_Ttl, () => Ttl.Value)
                         .Build();

            try
            {
                return(await TargetUrl
                       .Conditionally(isByValue, x => x.SetQueryParam(Constants.Etcd.Parameter_PrevValue, ExpectedValue))
                       .Conditionally(!isByValue, x => x.SetQueryParam(Constants.Etcd.Parameter_PrevIndex, ExpectedIndex))
                       .SendUrlEncodedAsync(HttpMethod.Put, values)
                       .ReceiveEtcdResponse <KeyEvent>(EtcdClient));
            }
            catch (FlurlHttpException e)
            {
                throw e.ProcessException();
            }
        }
Пример #5
0
        public async Task <IKeyEvent> Execute()
        {
            var values = new FormBodyBuilder()
                         .Add(
                IsDirectory ? Constants.Etcd.Parameter_Directory : Constants.Etcd.Parameter_Value,
                IsDirectory ? Constants.Etcd.Parameter_True : Value
                )
                         // ReSharper disable once PossibleInvalidOperationException
                         .Add(Existing.HasValue, Constants.Etcd.Parameter_PrevExist, () => Existing.Value ? Constants.Etcd.Parameter_True : Constants.Etcd.Parameter_False)
                         // ReSharper disable once PossibleInvalidOperationException
                         .Add(Ttl.HasValue, Constants.Etcd.Parameter_Ttl, () => Ttl.Value)
                         .Build();

            try
            {
                return(await TargetUrl
                       .Conditionally(IsQueue, values, (x, v) => x.PostUrlEncodedAsync(v), (x, v) => x.SendUrlEncodedAsync(HttpMethod.Put, v))
                       .ReceiveEtcdResponse <KeyEvent>(EtcdClient));
            }
            catch (FlurlHttpException e)
            {
                throw e.ProcessException();
            }
        }