pub async fn dynamodb_batch_write<TD: TableDefinition>(
client: Client,
batch_write_requests: Vec<WriteRequest>,
) -> Result<()>Expand description
Executes a batch of WriteRequests against a DynamoDB table.
Handles all the complexity of the DynamoDB batch write API:
- Chunking — automatically splits the input into chunks of 25 items
(the DynamoDB maximum per
BatchWriteItemcall). - Parallelism — each chunk is sent concurrently via
tokio::spawn. - Retry — any unprocessed items returned by DynamoDB are retried up
to 3 times total. If items remain unprocessed after all attempts, the
function returns
Error::FailedBatchWritecontaining the unprocessedWriteRequests.
Build WriteRequest values using DynamoDBItemBatchOp::batch_put,
DynamoDBItemBatchOp::batch_delete, batch_put, or batch_delete.
§Errors
- Returns
Error::FailedBatchWriteif items remain unprocessed after 3 retry attempts. - Returns
Error::DynamoDBif any individualBatchWriteItemSDK call fails with a non-retryable error.
§Examples
use dynamodb_facade::{DynamoDBItemBatchOp, dynamodb_batch_write};
// Batch put a large collection — chunking and retries are handled automatically
let requests: Vec<_> = enrollments.iter().map(|e| e.batch_put()).collect();
dynamodb_batch_write::<PlatformTable>(client, requests).await?;