Options
All
  • Public
  • Public/Protected
  • All
Menu

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

  • BatchOperation<WriteRequest>
    • BatchWrite

Index

Constructors

constructor

  • Parameters

    • client: DynamoDBClient

      The AWS SDK client with which to communicate with DynamoDB.

    • items: SyncOrAsyncIterable<[string, WriteRequest]>

      A synchronous or asynchronous iterable of tuples describing the operations to execute. The first member of the tuple should be the name of the table targeted by the operation.

    Returns BatchWrite

Properties

Protected Readonly batchSize

batchSize: 25 = MAX_WRITE_BATCH_SIZE

Protected Readonly client

client: DynamoDBClient

Protected Readonly pending

pending: [string, WriteRequest][] = []

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

Protected Readonly state

state: BatchState<WriteRequest> = {}

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

Protected Readonly toSend

toSend: [string, WriteRequest][] = []

Input elements that are prepared for immediate dispatch

Methods

[asyncIterator]

Protected doBatchRequest

  • doBatchRequest(): Promise<void>
  • Returns Promise<void>

Protected getInitialTableState

  • getInitialTableState(tableName: string): TableState<WriteRequest>
  • Create and return the initial state object for a given DynamoDB table.

    Parameters

    • tableName: string

      The name of the table whose initial state should be returned.

    Returns TableState<WriteRequest>

Protected handleThrottled

  • handleThrottled(tableName: string, unprocessed: 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: 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

  • next(): Promise<IteratorResult<[string, WriteRequest], any>>
  • Returns Promise<IteratorResult<[string, WriteRequest], any>>