/// <summary> /// Stores the given cells in the supplied table. /// </summary> /// <param name="table">the table</param> /// <param name="cells">the cells to insert</param> /// <returns>a task that is awaitable, signifying the end of this operation</returns> public Task StoreCellsAsync(string table, CellSet cells) { table.ArgumentNotNullNorEmpty(nameof(table)); cells.ArgumentNotNull(nameof(cells)); return(StoreCellsAsyncInternal(table, cells)); }
/// <summary> /// Stores the given cells in the supplied table. /// </summary> /// <param name="table">the table</param> /// <param name="cells">the cells to insert</param> /// <returns>a task that is awaitable, signifying the end of this operation</returns> public async Task StoreCellsAsync(string table, CellSet cells, RequestOptions options = null) { table.ArgumentNotNullNorEmpty("table"); cells.ArgumentNotNull("cells"); var optionToUse = options ?? _globalRequestOptions; await optionToUse.RetryPolicy.ExecuteAsync(() => StoreCellsAsyncInternal(table, cells, optionToUse)); }
private async Task StoreCellsAsyncInternal(string table, CellSet cells, string alternativeEndpointBase = null) { table.ArgumentNotNullNorEmpty("table"); cells.ArgumentNotNull("cells"); while (true) { IRetryPolicy retryPolicy = _retryPolicyFactory.Create(); try { // note the fake row key to insert a set of cells using (HttpWebResponse webResponse = await PutRequestAsync(table + "/somefalsekey", cells, alternativeEndpointBase)) { if (webResponse.StatusCode != HttpStatusCode.OK) { using (var output = new StreamReader(webResponse.GetResponseStream())) { string message = output.ReadToEnd(); throw new WebException( string.Format( "Couldn't insert into table {0}! Response code was: {1}, expected 200! Response body was: {2}", table, webResponse.StatusCode, message)); } } else { return; } } } catch (Exception e) { if (!retryPolicy.ShouldRetryAttempt(e)) { throw; } } } }