Skip to content

GetRecords

Source: src/AWS/Kinesis/GetRecords.ts

Runtime binding for kinesis:GetRecords.

Bind this operation to a Stream to read records from a shard using an iterator obtained via AWS.Kinesis.GetShardIterator. Provide the implementation with Effect.provide(AWS.Kinesis.GetRecordsHttp). For push-based processing, prefer consumeStreamRecords (a Lambda event source) over manual polling.

// init — bind the operations to the stream
const getShardIterator = yield* AWS.Kinesis.GetShardIterator(stream);
const getRecords = yield* AWS.Kinesis.GetRecords(stream);
// runtime — obtain an iterator, then read
const iterator = yield* getShardIterator({
ShardId: shardId,
ShardIteratorType: "TRIM_HORIZON",
});
const result = yield* getRecords({
ShardIterator: iterator.ShardIterator!,
});
for (const record of result.Records ?? []) {
yield* Effect.log(record.PartitionKey);
}