| 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 PutRecordsRequest extends Omit< |
| 7 | Kinesis.PutRecordsInput, |
| 8 | "StreamName" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `kinesis:PutRecords`. |
| 13 | * |
| 14 | * Bind this operation to a `Stream` to write up to 500 records per call — |
| 15 | * the stream name is injected automatically and `kinesis:PutRecords` is |
| 16 | * granted on the stream. Provide the implementation with |
| 17 | * `Effect.provide(AWS.Kinesis.PutRecordsHttp)`. For unbounded batching with |
| 18 | * automatic partial-failure retry, use `AWS.Kinesis.StreamSink` instead. |
| 19 | * ### Writing Batches |
| 20 | * **Example:** Put a Batch of Records |
| 21 | * ```typescript |
| 22 | * // init — bind the operation to the stream |
| 23 | * const putRecords = yield* AWS.Kinesis.PutRecords(stream); |
| 24 | * |
| 25 | * // runtime — write a batch from a handler |
| 26 | * const result = yield* putRecords({ |
| 27 | * Records: orders.map((order) => ({ |
| 28 | * PartitionKey: order.id, |
| 29 | * Data: new TextEncoder().encode(JSON.stringify(order)), |
| 30 | * })), |
| 31 | * }); |
| 32 | * // result.FailedRecordCount > 0 means some entries need re-submission |
| 33 | * ``` |
| 34 | * |
| 35 | * @binding |
| 36 | */ |
| 37 | export interface PutRecords extends Binding.Service< |
| 38 | PutRecords, |
| 39 | "AWS.Kinesis.PutRecords", |
| 40 | ( |
| 41 | stream: Stream, |
| 42 | ) => Effect.Effect< |
| 43 | ( |
| 44 | request: PutRecordsRequest, |
| 45 | ) => Effect.Effect<Kinesis.PutRecordsOutput, Kinesis.PutRecordsError> |
| 46 | > |
| 47 | > {} |
| 48 | |
| 49 | export const PutRecords = Binding.Service<PutRecords>("AWS.Kinesis.PutRecords"); |