/** * Send a record to a Kafka topic with new image version details. * * @param image the image * @returns {Promise<void>} */ async notify(image) { const producer = this.kafka.producer(); await producer.connect(); return producer.send({ topic: this.configuration.topic, messages: [{ value: JSON.stringify(image) }], }); }
/** * Creates a new instance of the Consumer * * @param brokers - List of brokers to connect to * @param topics - List of topics to consume * @param kafkaConfig - Kafka client configuration * @param consumerConfig - Consumer configuration */ constructor( brokers: string[], topics = [DEFAULT_TOPIC_TX_DECODED, DEFAULT_TOPIC_TX_RECOVER], kafkaConfig?: Omit<KakfaJS.KafkaConfig, 'brokers'>, consumerConfig?: KakfaJS.ConsumerConfig ) { super({ clientId: 'orchestrate-sdk-consumer', ...kafkaConfig, brokers }) this.topics = topics this.consumer = this.kafka.consumer({ groupId: 'orchestrate-sdk-consumer', ...consumerConfig }) }
/** * Creates a new instance of the Producer * * @param brokers - List of brokers to connect to * @param kafkaConfig - Kafka client configuration * @param producerConfig - Producer configuration */ constructor( brokers: string[], kafkaConfig?: Omit<KakfaJS.KafkaConfig, 'brokers'>, producerConfig?: KakfaJS.ProducerConfig ) { super({ clientId: 'orchestrate-sdk-producer', ...kafkaConfig, brokers }) this.producer = this.kafka.producer(producerConfig) }