Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { Thread } from "@intx/types/runtime";
import type { MailboxDb } from "./db.js";
import type { NativeMailboxStore } from "./native-store.js";
import {
createInMemoryMailboxEventBus,
publishMailboxEvent,
type MailboxEvent,
type MailboxEventBus,
Expand All @@ -30,7 +31,12 @@ export type OutgoingMailboxMessage = {

export type MountMailboxOpts = {
db: MailboxDb;
bus: MailboxEventBus;
/**
* SSE live-update bus only. Mail is Postgres. Defaults to an in-process
* bus (one hub process). Pass a shared bus if several hub processes must
* fan the same inbox events.
*/
bus?: MailboxEventBus;
resolvePrincipal: (
ctx: unknown,
) => Promise<ResolvedPrincipal | null> | ResolvedPrincipal | null;
Expand Down Expand Up @@ -202,7 +208,8 @@ export function mountMailbox<E extends Env>(
app: Hono<E>,
opts: MountMailboxOpts,
): Hono<E> {
const { db, bus, resolvePrincipal, senderAddressFor, deliver } = opts;
const { db, resolvePrincipal, senderAddressFor, deliver } = opts;
const bus = opts.bus ?? createInMemoryMailboxEventBus();
const heartbeatIntervalMs =
opts.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS;
if (!Number.isFinite(heartbeatIntervalMs) || heartbeatIntervalMs <= 0) {
Expand Down
Loading