Ejemplo n.º 1
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)
 {
     return(await CallEtcdAsync(async (connection) => await connection.kvClient
                                .DeleteRangeAsync(request, headers, deadline, cancellationToken)));
 }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public Task <Unit> Handle(DeleteRangeRequest <T> request, CancellationToken cancellationToken, RequestHandlerDelegate <Unit> next)
        {
            if (request == default)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (next == default)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (!_options.UseScopedLogging)
            {
                return(Handle());
            }

            using (request.Scope)
            {
                return(Handle());
            }

            async Task <Unit> Handle()
            {
                var start = new DeleteRangeNotification <T>(request.Expressions, request.Logger);
                await _mediator.Publish(start, cancellationToken).ConfigureAwait(false);

                var response = await next().ConfigureAwait(false);

                var finish = new DeleteRangeNotification(request.Logger);
                await _mediator.Publish(finish, cancellationToken).ConfigureAwait(false);

                return(response);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Delete the specified key in etcd
 /// </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 DeleteRangeResponse Delete(DeleteRangeRequest request, Grpc.Core.Metadata headers = null,
                                   DateTime?deadline = null,
                                   CancellationToken cancellationToken = default)
 {
     return(CallEtcd((connection) => connection.kvClient
                     .DeleteRange(request, headers, deadline, cancellationToken)));
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
            RequestOp toRequestOp()
            {
                DeleteRangeRequest delete = new DeleteRangeRequest();

                delete.Key    = this.key;
                delete.PrevKv = this.option.IsPrevKV;
                if (this.option.EndKey.IsPresent)
                {
                    delete.RangeEnd = ByteString.CopyFrom(this.option.EndKey.GetBytes());
                }

                RequestOp op = new RequestOp();

                op.RequestDeleteRange = delete;
                return(op);
            }
Ejemplo n.º 7
0
 /// <summary>
 /// Delete the specified key in etcd in async
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <DeleteRangeResponse> DeleteAsync(DeleteRangeRequest request)
 {
     try
     {
         return(await _kvClient.DeleteRangeAsync(request, _headers));
     }
     catch (RpcException ex)
     {
         ResetConnection(ex);
         throw;
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Delete the specified key in etcd
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public DeleteRangeResponse Delete(DeleteRangeRequest request)
 {
     try
     {
         return(_kvClient.DeleteRange(request, _headers));
     }
     catch (RpcException ex)
     {
         ResetConnection(ex);
         throw;
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 9
0
        public DeleteRangeRequest AddDeleteRange(int sheetId, string shiftDimension = "ROWS")
        {
            var deleteRequest = new DeleteRangeRequest
            {
                Range = new GridRange
                {
                    SheetId = sheetId,
                },
                ShiftDimension = shiftDimension
            };

            this.Requests.Add(new Request {
                DeleteRange = deleteRequest
            });

            return(deleteRequest);
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> DeleteAssets(
            [SwaggerParameter("The Asset Ids", Required = true), FromQuery, Required] Guid[] ids,
            CancellationToken cancellationToken)
        {
            if (ids == default || ids.Length == 0)
            {
                ModelState.AddModelError(nameof(ids), "Ids are required");
                return(BadRequest(ModelState));
            }

            var expressions = ids.Select(id => (Expression <Func <Asset, bool> >)(asset => asset.Id == id));
            var request     = new DeleteRangeRequest <Asset>(nameof(MongoDB), expressions.ToArray(), _logger);
            await _mediator.Send(request, cancellationToken).ConfigureAwait(false);

            var notification = new DeleteRangeNotification <Guid>(ids);
            await _mediator.Publish(notification, cancellationToken).ConfigureAwait(false);

            return(NoContent());
        }
Ejemplo n.º 11
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)
 {
     return(await _balancer.GetConnection().kvClient.DeleteRangeAsync(request, headers));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Delete the specified key in etcd
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public DeleteRangeResponse Delete(DeleteRangeRequest request, Metadata headers = null)
 {
     return(_balancer.GetConnection().kvClient.DeleteRange(request, headers));
 }