UNPKG

@message-queue-toolkit/kafka

Version:
18 lines (17 loc) 1.29 kB
import { type MessageToProduce, type ProduceOptions } from '@platformatic/kafka'; import { AbstractKafkaService, type BaseKafkaOptions } from './AbstractKafkaService.ts'; import type { KafkaDependencies, RequestContext, SupportedMessageValuesInputForTopic, SupportedTopics, TopicConfig } from './types.ts'; export type KafkaPublisherOptions<TopicsConfig extends TopicConfig[]> = BaseKafkaOptions & Omit<ProduceOptions<string, object, string, string>, 'serializers'> & { topicsConfig: TopicsConfig; }; export type KafkaMessageOptions = Omit<MessageToProduce<string, object, string, string>, 'topic' | 'value'>; export declare abstract class AbstractKafkaPublisher<TopicsConfig extends TopicConfig[]> extends AbstractKafkaService<TopicsConfig, KafkaPublisherOptions<TopicsConfig>> { private readonly topicsConfig; private readonly schemaContainers; private readonly producer; private isInitiated; constructor(dependencies: KafkaDependencies, options: KafkaPublisherOptions<TopicsConfig>); init(): Promise<void>; close(): Promise<void>; publish<Topic extends SupportedTopics<TopicsConfig>>(topic: Topic, message: SupportedMessageValuesInputForTopic<TopicsConfig, Topic>, requestContext?: RequestContext, options?: KafkaMessageOptions): Promise<void>; }