public async Task HardDeleteAsync(ResourceKey key, CancellationToken cancellationToken) { EnsureArg.IsNotNull(key, nameof(key)); try { _logger.LogDebug($"Obliterating {key.ResourceType}/{key.Id}"); StoredProcedureResponse <IList <string> > response = await _retryExceptionPolicyFactory.CreateRetryPolicy().ExecuteAsync( async ct => await _hardDelete.Execute( _documentClientScope.Value, CollectionUri, key, ct), cancellationToken); _logger.LogDebug($"Hard-deleted {response.Response.Count} documents, which consumed {response.RequestCharge} RUs. The list of hard-deleted documents: {string.Join(", ", response.Response)}."); } catch (DocumentClientException dce) { if (dce.GetSubStatusCode() == HttpStatusCode.RequestEntityTooLarge) { throw new RequestRateExceededException(dce.RetryAfter); } _logger.LogError(dce, "Unhandled Document Client Exception"); throw; } }
public async Task HardDeleteAsync(ResourceKey key, CancellationToken cancellationToken = default(CancellationToken)) { EnsureArg.IsNotNull(key, nameof(key)); try { _logger.LogDebug($"Obliterating {key.ResourceType}/{key.Id}"); StoredProcedureResponse <IList <string> > response = await _retryExceptionPolicyFactory.CreateRetryPolicy().ExecuteAsync( async() => await _hardDelete.Execute( _documentClient, _collectionUri, key), cancellationToken); _logger.LogDebug($"Hard-deleted {response.Response.Count} documents, which consumed {response.RequestCharge} RUs. The list of hard-deleted documents: {string.Join(", ", response.Response)}."); } catch (DocumentClientException dce) { if (dce.Error?.Message?.Contains(GetValue(HttpStatusCode.RequestEntityTooLarge), StringComparison.Ordinal) == true) { // TODO: Eventually, we might want to have our own RequestTooLargeException? throw new ServiceUnavailableException(); } _logger.LogError(dce, "Unhandled Document Client Exception"); throw; } }
public async Task HardDeleteAsync(ResourceKey key, CancellationToken cancellationToken) { EnsureArg.IsNotNull(key, nameof(key)); try { _logger.LogDebug($"Obliterating {key.ResourceType}/{key.Id}"); StoredProcedureExecuteResponse <IList <string> > response = await _retryExceptionPolicyFactory.CreateRetryPolicy().ExecuteAsync( async ct => await _hardDelete.Execute( _containerScope.Value.Scripts, key, ct), cancellationToken); _logger.LogDebug($"Hard-deleted {response.Resource.Count} documents, which consumed {response.RequestCharge} RUs. The list of hard-deleted documents: {string.Join(", ", response.Resource)}."); } catch (CosmosException exception) { if (exception.IsRequestEntityTooLarge()) { throw; } _logger.LogError(exception, "Unhandled Document Client Exception"); throw; } }