1import * as Kinesis from "@distilled.cloud/aws/kinesis";
2import * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Stream } from "./Stream.ts";
5
6export interface GetRecordsRequest extends Omit<
7 Kinesis.GetRecordsInput,
8 "StreamARN"
9> {}
10
11/**
12 * Runtime binding for `kinesis:GetRecords`.
13 *
14 * Bind this operation to a `Stream` to read records from a shard using an
15 * iterator obtained via `AWS.Kinesis.GetShardIterator`. Provide the
16 * implementation with `Effect.provide(AWS.Kinesis.GetRecordsHttp)`. For
17 * push-based processing, prefer `consumeStreamRecords` (a Lambda event
18 * source) over manual polling.
19 * ### Reading Records
20 * **Example:** Read Records from a Shard
21 * ```typescript
22 * // init — bind the operations to the stream
23 * const getShardIterator = yield* AWS.Kinesis.GetShardIterator(stream);
24 * const getRecords = yield* AWS.Kinesis.GetRecords(stream);
25 *
26 * // runtime — obtain an iterator, then read
27 * const iterator = yield* getShardIterator({
28 * ShardId: shardId,
29 * ShardIteratorType: "TRIM_HORIZON",
30 * });
31 * const result = yield* getRecords({
32 * ShardIterator: iterator.ShardIterator!,
33 * });
34 * for (const record of result.Records ?? []) {
35 * yield* Effect.log(record.PartitionKey);
36 * }
37 * ```
38 *
39 * @binding
40 */
41export interface GetRecords extends Binding.Service<
42 GetRecords,
43 "AWS.Kinesis.GetRecords",
44 (
45 stream: Stream,
46 ) => Effect.Effect<
47 (
48 request: GetRecordsRequest,
49 ) => Effect.Effect<Kinesis.GetRecordsOutput, Kinesis.GetRecordsError>
50 >
51> {}
52
53export const GetRecords = Binding.Service<GetRecords>("AWS.Kinesis.GetRecords");