| 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 { StreamConsumer } from "./StreamConsumer.ts"; |
| 5 | |
| 6 | export interface SubscribeToShardRequest extends Omit< |
| 7 | Kinesis.SubscribeToShardInput, |
| 8 | "ConsumerARN" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `kinesis:SubscribeToShard` (enhanced fan-out). |
| 13 | * |
| 14 | * Bind this operation to a `StreamConsumer` (a registered enhanced fan-out |
| 15 | * consumer) to open a push-based subscription to a shard — the consumer ARN |
| 16 | * is injected automatically. Provide the implementation with |
| 17 | * `Effect.provide(AWS.Kinesis.SubscribeToShardHttp)`. |
| 18 | * ### Enhanced Fan-Out |
| 19 | * **Example:** Subscribe to a Shard |
| 20 | * ```typescript |
| 21 | * const consumer = yield* AWS.Kinesis.StreamConsumer("Analytics", { |
| 22 | * streamArn: stream.streamArn, |
| 23 | * }); |
| 24 | * // init — bind the operation to the registered consumer |
| 25 | * const subscribeToShard = yield* AWS.Kinesis.SubscribeToShard(consumer); |
| 26 | * |
| 27 | * // runtime — open the subscription |
| 28 | * const result = yield* subscribeToShard({ |
| 29 | * ShardId: shardId, |
| 30 | * StartingPosition: { Type: "LATEST" }, |
| 31 | * }); |
| 32 | * // result.EventStream delivers records for up to 5 minutes |
| 33 | * ``` |
| 34 | * |
| 35 | * @binding |
| 36 | */ |
| 37 | export interface SubscribeToShard extends Binding.Service< |
| 38 | SubscribeToShard, |
| 39 | "AWS.Kinesis.SubscribeToShard", |
| 40 | ( |
| 41 | consumer: StreamConsumer, |
| 42 | ) => Effect.Effect< |
| 43 | ( |
| 44 | request: SubscribeToShardRequest, |
| 45 | ) => Effect.Effect< |
| 46 | Kinesis.SubscribeToShardOutput, |
| 47 | Kinesis.SubscribeToShardError |
| 48 | > |
| 49 | > |
| 50 | > {} |
| 51 | |
| 52 | export const SubscribeToShard = Binding.Service<SubscribeToShard>( |
| 53 | "AWS.Kinesis.SubscribeToShard", |
| 54 | ); |