Skip to main content

dynamodb_batch_write

Function dynamodb_batch_write 

Source
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 BatchWriteItem call).
  • 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::FailedBatchWrite containing the unprocessed WriteRequests.

Build WriteRequest values using DynamoDBItemBatchOp::batch_put, DynamoDBItemBatchOp::batch_delete, batch_put, or batch_delete.

§Errors

§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?;