Skip to content

DeliveryStreamSink

Source: src/AWS/Firehose/DeliveryStreamSink.ts

A batching sink over Firehose PutRecordBatch (500 records / 4 MiB per call).

Each input element is a raw Firehose.Record ({ Data: Uint8Array }), so callers stay in control of encoding and record framing.

Even a 200 response can carry per-record failures (FailedPutCount > 0, per-record ErrorCodeServiceUnavailableException / internal failure). All of them are transient, so the failed subset is re-submitted in input order on a bounded schedule; exhausting retries fails the sink with a typed BatchRetryExhaustedError carrying the stranded records.

// init — bind the sink (provide AWS.Firehose.DeliveryStreamSinkHttp on the Function)
const sink = yield* AWS.Firehose.DeliveryStreamSink(deliveryStream);
return {
fetch: Effect.gen(function* () {
// runtime — stream newline-framed records into Firehose
yield* Stream.fromIterable(lines).pipe(
Stream.map((line) => ({
Data: new TextEncoder().encode(`${line}\n`),
})),
Stream.run(sink),
);
return HttpServerResponse.json({ ok: true });
}),
};