public async Task <PutItemResult> PutItemUsingRetryPolicyAsync(PutItemRequest request, RetryPolicy retryPolicy) { var retryCount = 0; Exception lastError = null; do { try { return(await PutItemAsync(request).ConfigureAwait(false)); } catch (DynamoDbException ex) when(ex.IsTransient) { lastError = ex; } retryCount++; await Task.Delay(retryPolicy.GetDelay(retryCount)).ConfigureAwait(false); }while (retryPolicy.ShouldRetry(retryCount)); throw lastError; }
public Task <PutItemResult> PutAsync(T entity) { var request = new PutItemRequest(tableName, AttributeCollection.FromObject(entity, metadata)); return(client.PutItemWithRetryPolicy(request, retryPolicy)); }