@hotmeshio/hotmesh
Version:
Permanent-Memory Workflows & AI Agents
57 lines (56 loc) • 2.65 kB
TypeScript
import { ILogger } from '../../../logger';
import { PostgresClientType } from '../../../../types/postgres';
import { PublishMessageConfig, StreamMessage } from '../../../../types/stream';
import { ProviderClient, ProviderTransaction } from '../../../../types/provider';
/**
* Publish messages to a stream. Can be used within a transaction.
*
* When a transaction is provided, the SQL is added to the transaction
* and executed atomically with other operations.
*/
export declare function publishMessages(client: PostgresClientType & ProviderClient, tableName: string, streamName: string, messages: string[], options: PublishMessageConfig | undefined, logger: ILogger): Promise<string[] | ProviderTransaction>;
/**
* Build SQL for publishing messages with retry policies and visibility delays.
* Optimizes the INSERT statement based on whether retry config is present.
*/
export declare function buildPublishSQL(tableName: string, streamName: string, messages: string[], options?: PublishMessageConfig): {
sql: string;
params: any[];
};
/**
* Fetch messages from the stream with optional exponential backoff.
* Uses SKIP LOCKED for high-concurrency consumption.
*/
export declare function fetchMessages(client: PostgresClientType & ProviderClient, tableName: string, streamName: string, groupName: string, consumerName: string, options: {
batchSize?: number;
blockTimeout?: number;
autoAck?: boolean;
reservationTimeout?: number;
enableBackoff?: boolean;
initialBackoff?: number;
maxBackoff?: number;
maxRetries?: number;
}, logger: ILogger): Promise<StreamMessage[]>;
/**
* Acknowledge messages (no-op for PostgreSQL - uses soft delete pattern).
*/
export declare function acknowledgeMessages(messageIds: string[]): Promise<number>;
/**
* Delete messages by soft-deleting them (setting expired_at).
*/
export declare function deleteMessages(client: PostgresClientType & ProviderClient, tableName: string, streamName: string, groupName: string, messageIds: string[], logger: ILogger): Promise<number>;
/**
* Acknowledge and delete messages in one operation.
*/
export declare function ackAndDelete(client: PostgresClientType & ProviderClient, tableName: string, streamName: string, groupName: string, messageIds: string[], logger: ILogger): Promise<number>;
/**
* Retry messages (placeholder for future implementation).
*/
export declare function retryMessages(streamName: string, groupName: string, options?: {
consumerName?: string;
minIdleTime?: number;
messageIds?: string[];
delay?: number;
maxRetries?: number;
limit?: number;
}): Promise<StreamMessage[]>;