Skip to content

TopicSink

Source: src/AWS/SNS/TopicSink.ts

A batching sink over SNS PublishBatch (10 entries / 256 KiB per call). Per-entry failures with SenderFault: false (throttling, internal errors) are retried on a bounded schedule; SenderFault: true failures are permanent and dropped. Exhausting retries fails the sink with a typed BatchRetryExhaustedError carrying the stranded entries.

The binding grants the host function sns:Publish on the topic. Provide the TopicSinkHttp layer (which itself needs PublishBatchHttp) on the Function to implement the binding.

// init (provide SNS.TopicSinkHttp + SNS.PublishBatchHttp on the Function)
const sink = yield* SNS.TopicSink(topic);
// runtime: batching, size limits, and transient-failure retry are handled
// by the sink — each element is a PublishBatchRequestEntry minus `Id`.
yield* Stream.fromIterable(messages).pipe(
Stream.map((message) => ({ Message: message })),
Stream.run(sink),
);