Skip to content

BusSink

Source: src/AWS/EventBridge/BusSink.ts

A batching sink over EventBridge PutEvents (10 entries / 256 KiB per call). Per-entry failures with transient error codes (ThrottlingException, InternalFailure) are re-submitted on a bounded schedule; any other per-entry ErrorCode (e.g. MalformedDetail) is permanent — those entries are dropped and surfaced via a logged warning. Exhausting retries fails the sink with a typed BatchRetryExhaustedError carrying the stranded entries.

Omit the bus argument to publish to the account’s default event bus.

// init — bind the sink (provide AWS.EventBridge.BusSinkHttp on the Function)
const sink = yield* AWS.EventBridge.BusSink(bus);
return {
fetch: Effect.gen(function* () {
// runtime — publish a stream of raw PutEvents entries
const entries: AWS.EventBridge.BusSinkEntry[] = markers.map((marker) => ({
Source: "my.app",
DetailType: "MarkerSeen",
Detail: JSON.stringify({ marker }),
}));
yield* Stream.fromIterable(entries).pipe(Stream.run(sink));
return HttpServerResponse.json({ ok: true });
}),
};