Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BatchWrite

Puts or deletes items from DynamoDB in batches of 25 or fewer via one or more BatchWriteItem operations. The items may belong to any number of tables.

The iterable of writes to perform may be synchronous or asynchronous and is expected to yield tuples describing the writes to be performed. The first member should be the table name, and the second should be {WriteRequest} object that defines either a put request or a delete request.

This method will automatically retry any write requests returned by DynamoDB as unprocessed. Exponential backoff on unprocessed items is employed on a per-table basis.

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected batchSize

batchSize: 25 = MAX_WRITE_BATCH_SIZE

Protected client

client: DynamoDB

The AWS SDK client with which to communicate with DynamoDB.

Protected pending

pending: Array<[string, WriteRequest]> = []

Items that have been retrieved and are ready to be returned.

Protected state

A mapping of table names to table-specific operation state (e.g., the number of throttling events experienced, etc.)

Protected toSend

toSend: Array<[string, WriteRequest]> = []

Input elements that are prepared for immediate dispatch

Methods

__@asyncIterator

  • __@asyncIterator(): this

Protected doBatchRequest

  • doBatchRequest(): Promise<void>

Protected getInitialTableState

Protected handleThrottled

  • handleThrottled(tableName: string, unprocessed: Array<WriteRequest>): void
  • Accept an array of unprocessed items belonging to a single table and re-enqueue it for submission, making sure the appropriate level of backoff is applied to future operations on the same table.

    Parameters

    • tableName: string

      The table to which the unprocessed elements belong.

    • unprocessed: Array<WriteRequest>

      Elements returned by DynamoDB as not yet processed. The elements should not be unmarshalled, but they should be reverted to the form used for elements that have not yet been sent.

    Returns void

Protected movePendingToThrottled

  • movePendingToThrottled(unprocessedTables: Set<string>): void
  • Iterate over all pending writes and move those targeting throttled tables into the throttled queue.

    Parameters

    • unprocessedTables: Set<string>

      A set of tables for which some items were returned without being processed.

    Returns void

next