@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

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