| 1 | import * as Kinesis from "@distilled.cloud/aws/kinesis"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Stream } from "./Stream.ts"; |
| 5 | |
| 6 | export interface GetShardIteratorRequest extends Omit< |
| 7 | Kinesis.GetShardIteratorInput, |
| 8 | "StreamName" | "StreamARN" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `kinesis:GetShardIterator`. |
| 13 | * |
| 14 | * Bind this operation to a `Stream` to obtain a shard iterator — the starting |
| 15 | * position for reading records with `AWS.Kinesis.GetRecords`. The stream name |
| 16 | * is injected automatically. Provide the implementation with |
| 17 | * `Effect.provide(AWS.Kinesis.GetShardIteratorHttp)`. |
| 18 | * ### Reading Records |
| 19 | * **Example:** Obtain an Iterator for the Latest Position |
| 20 | * ```typescript |
| 21 | * // init |
| 22 | * const getShardIterator = yield* AWS.Kinesis.GetShardIterator(stream); |
| 23 | * |
| 24 | * // runtime |
| 25 | * const iterator = yield* getShardIterator({ |
| 26 | * ShardId: shardId, |
| 27 | * ShardIteratorType: "LATEST", |
| 28 | * }); |
| 29 | * // pass iterator.ShardIterator to getRecords |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | */ |
| 34 | export interface GetShardIterator extends Binding.Service< |
| 35 | GetShardIterator, |
| 36 | "AWS.Kinesis.GetShardIterator", |
| 37 | ( |
| 38 | stream: Stream, |
| 39 | ) => Effect.Effect< |
| 40 | ( |
| 41 | request: GetShardIteratorRequest, |
| 42 | ) => Effect.Effect< |
| 43 | Kinesis.GetShardIteratorOutput, |
| 44 | Kinesis.GetShardIteratorError |
| 45 | > |
| 46 | > |
| 47 | > {} |
| 48 | |
| 49 | export const GetShardIterator = Binding.Service<GetShardIterator>( |
| 50 | "AWS.Kinesis.GetShardIterator", |
| 51 | ); |