/// <summary> /// This method is called when all calls to <see cref="SetStatus(MutateRowsResponse)"/> are complete. /// </summary> /// <returns> /// ProcessingStatus of the accumulated responses - invalid, retryable, non-retryable. /// </returns> internal ProcessingStatus OnOk() { // Sanity check to make sure that every mutation received a response. _messageIsInvalid = _messageIsInvalid || _results.Any(result => result == null); // There was a problem in the data found in SetStatus(), so fail the RPC. if (_messageIsInvalid) { return(ProcessingStatus.Invalid); } // This list hold indices of entries to be included in retry request List <int> toRetry = null; ProcessingStatus processingStatus = ProcessingStatus.NotRetryable; // Check the current state to determine the state of the results. // There are three states: OK, Fail, or Partial Retry. for (int i = 0; i < _results.Length; i++) { Rpc.Status status = _results[i]; if (status.Code == (int)StatusCode.OK) { continue; } if (_retryableCodes.Contains(status.Code)) { if (toRetry == null) { toRetry = new List <int>(); } // An individual mutation failed with a retryable code, usually DEADLINE_EXCEEDED. toRetry.Add(i); processingStatus = ProcessingStatus.Retryable; } else { // Don't retry if even a single response is not retryable. processingStatus = ProcessingStatus.NotRetryable; break; } } if (processingStatus == ProcessingStatus.Retryable) { CreateRetryRequest(toRetry); } else { RetryRequest = null; } return(processingStatus); }
/// <summary> /// Wraps a <see cref="GoogleAdsFailure"/> in an Rpc.Status object. /// </summary> /// <param name="failure">The failure.</param> /// <returns>The wrapped Rpc.Status.</returns> private static Rpc.Status GetStatus(GoogleAdsFailure failure) { Rpc.Status status = new Rpc.Status(); status.Details.Add(Any.Pack(failure)); return(status); }
private static MutateRowsResponse.Types.Entry CreateEntry(int i, Rpc.Status status) => new MutateRowsResponse.Types.Entry { Index = i, Status = status };