UNPKG

@arturwojnar/hermes-postgresql

Version:

Production-Ready TypeScript Outbox Pattern for PostgreSQL

21 lines (20 loc) 913 B
import { Duration } from '@arturwojnar/hermes'; import { JSONValue, Options, PostgresType } from 'postgres'; import { AsyncOrSync } from 'ts-essentials'; import { UseAsyncOutboxPolicy } from '../policies/useBasicAsyncStoragePolicy.js'; import { HermesMessageEnvelope, NowFunction } from './types.js'; type ConsumerCreationParams<Message extends JSONValue> = { getOptions: () => Options<Record<string, PostgresType>>; publish: (message: HermesMessageEnvelope<Message> | HermesMessageEnvelope<Message>[]) => AsyncOrSync<void> | never; consumerName: string; partitionKey?: string; waitAfterFailedPublish?: Duration; shouldDisposeOnSigterm?: boolean; saveTimestamps?: boolean; serialization?: boolean; onFailedPublish?: ErrorCallback; onDbError?: ErrorCallback; now?: NowFunction; asyncOutbox?: UseAsyncOutboxPolicy<Message>; }; export type { ConsumerCreationParams };