getRecords method

Future<GetRecordsOutput> getRecords({
  1. required String shardIterator,
  2. int? limit,
})

Retrieves the stream records from a given shard.

Specify a shard iterator using the ShardIterator parameter. The shard iterator specifies the position in the shard from which you want to start reading stream records sequentially. If there are no stream records available in the portion of the shard that the iterator points to, GetRecords returns an empty list. Note that it might take multiple calls to get to a portion of the shard that contains stream records.

May throw ResourceNotFoundException. May throw LimitExceededException. May throw InternalServerError. May throw ExpiredIteratorException. May throw TrimmedDataAccessException.

Parameter shardIterator : A shard iterator that was retrieved from a previous GetShardIterator operation. This iterator can be used to access the stream records in this shard.

Parameter limit : The maximum number of records to return from the shard. The upper limit is 1000.

Implementation

Future<GetRecordsOutput> getRecords({
  required String shardIterator,
  int? limit,
}) async {
  ArgumentError.checkNotNull(shardIterator, 'shardIterator');
  _s.validateStringLength(
    'shardIterator',
    shardIterator,
    1,
    2048,
    isRequired: true,
  );
  _s.validateNumRange(
    'limit',
    limit,
    1,
    1152921504606846976,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDBStreams_20120810.GetRecords'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ShardIterator': shardIterator,
      if (limit != null) 'Limit': limit,
    },
  );

  return GetRecordsOutput.fromJson(jsonResponse.body);
}