Exemplo n.º 1
0
        /// <summary>
        /// Delete the specified key in etcd in async
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <DeleteRangeResponse> DeleteAsync(DeleteRangeRequest request, Metadata headers = null)
        {
            DeleteRangeResponse response = new DeleteRangeResponse();
            bool success    = false;
            int  retryCount = 0;

            while (!success)
            {
                try
                {
                    response = await _balancer.GetConnection().kvClient.DeleteRangeAsync(request, headers);

                    success = true;
                }
                catch (RpcException ex) when(ex.StatusCode == StatusCode.Unavailable)
                {
                    retryCount++;
                    if (retryCount >= _balancer._numNodes)
                    {
                        throw ex;
                    }
                }
            }
            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Delete the specified key in etcd in async
        /// </summary>
        /// <param name="request">The request to send to the server.</param>
        /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
        /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
        /// <param name="cancellationToken">An optional token for canceling the call.</param>
        /// <returns>The response received from the server.</returns>
        public async Task <DeleteRangeResponse> DeleteAsync(DeleteRangeRequest request,
                                                            Grpc.Core.Metadata headers          = null, DateTime?deadline = null,
                                                            CancellationToken cancellationToken = default)
        {
            DeleteRangeResponse response = new DeleteRangeResponse();
            bool success    = false;
            int  retryCount = 0;

            while (!success)
            {
                try
                {
                    response = await _balancer.GetConnection().kvClient
                               .DeleteRangeAsync(request, headers, deadline, cancellationToken);

                    success = true;
                }
                catch (RpcException ex) when(ex.StatusCode == StatusCode.Unavailable)
                {
                    retryCount++;
                    if (retryCount >= _balancer._numNodes)
                    {
                        throw;
                    }
                }
            }

            return(response);
        }
Exemplo n.º 3
0
        public static Entity.DeleteRangeResponse FromProto(this DeleteRangeResponse response)
        {
            return(new Entity.DeleteRangeResponse()
            {
                Deleted = response.Deleted,
                Header = response.Header.FromProto(),

                PrevKvs = response.PrevKvs.FromProto()
                ,
                CalculateSize = response.CalculateSize()
            });
        }