getShardIterator method
Returns a shard iterator that serves as a bookmark for reading data from a specific position in an Amazon Keyspaces data stream's shard. The shard iterator specifies the shard position from which to start reading data records sequentially. You can specify whether to begin reading at the latest record, the oldest record, or at a particular sequence number within the shard.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
May throw ValidationException.
Parameter shardId :
The identifier of the shard within the stream. The shard ID uniquely
identifies a subset of the stream's data records that you want to access.
Parameter shardIteratorType :
Determines how the shard iterator is positioned. Must be one of the
following:
-
TRIM_HORIZON- Start reading at the last untrimmed record in the shard, which is the oldest data record in the shard. -
AT_SEQUENCE_NUMBER- Start reading exactly from the specified sequence number. -
AFTER_SEQUENCE_NUMBER- Start reading right after the specified sequence number. -
LATEST- Start reading just after the most recent record in the shard, so that you always read the most recent data.
Parameter streamArn :
The Amazon Resource Name (ARN) of the stream for which to get the shard
iterator. The ARN uniquely identifies the stream within Amazon Keyspaces.
Parameter sequenceNumber :
The sequence number of the data record in the shard from which to start
reading. Required if ShardIteratorType is
AT_SEQUENCE_NUMBER or AFTER_SEQUENCE_NUMBER.
This parameter is ignored for other iterator types.
Implementation
Future<GetShardIteratorOutput> getShardIterator({
required String shardId,
required ShardIteratorType shardIteratorType,
required String streamArn,
String? sequenceNumber,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'KeyspacesStreams.GetShardIterator'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'shardId': shardId,
'shardIteratorType': shardIteratorType.value,
'streamArn': streamArn,
if (sequenceNumber != null) 'sequenceNumber': sequenceNumber,
},
);
return GetShardIteratorOutput.fromJson(jsonResponse.body);
}