///
import { Sql } from "postgres";
import { MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
//#region src/mq.d.ts
/**
* Options for the PostgreSQL message queue.
*/
interface PostgresMessageQueueOptions {
/**
* The table name to use for the message queue.
* `"fedify_message_v2"` by default.
* @default `"fedify_message_v2"`
*/
readonly tableName?: string;
/**
* The channel name to use for the message queue.
* `"fedify_channel"` by default.
* @default `"fedify_channel"`
*/
readonly channelName?: string;
/**
* Whether the table has been initialized. `false` by default.
* @default `false`
*/
readonly initialized?: boolean;
/**
* The poll interval for the message queue. 5 seconds by default.
* @default `{ seconds: 5 }`
*/
readonly pollInterval?: Temporal.Duration | Temporal.DurationLike;
/**
* The maximum time to wait for a message handler to complete before
* considering it hung. When a handler exceeds this timeout, it is
* treated as an error and the poll loop moves on to the next message,
* preventing a single hung handler from permanently blocking the queue.
*
* Set to zero to disable the timeout (not recommended in production).
*
* 60 seconds by default.
* @default `{ seconds: 60 }`
* @since 2.0.3
*/
readonly handlerTimeout?: Temporal.Duration | Temporal.DurationLike;
}
/**
* A message queue that uses PostgreSQL as the underlying storage.
*
* @example
* ```ts
* import { createFederation } from "@fedify/fedify";
* import { PostgresKvStore, PostgresMessageQueue } from "@fedify/postgres";
* import postgres from "postgres";
*
* const sql = postgres("postgres://user:pass@localhost/db");
*
* const federation = createFederation({
* kv: new PostgresKvStore(sql),
* queue: new PostgresMessageQueue(sql),
* });
* ```
*/
declare class PostgresMessageQueue implements MessageQueue {
#private;
constructor(sql: Sql<{}>, options?: PostgresMessageQueueOptions);
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise;
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise;
getDepth(): Promise;
listen(handler: (message: any) => void | Promise, options?: MessageQueueListenOptions): Promise;
/**
* Initializes the message queue table if it does not already exist.
*/
initialize(): Promise;
/**
* Drops the message queue table if it exists.
*/
drop(): Promise;
}
//#endregion
export { PostgresMessageQueue, PostgresMessageQueueOptions };