//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.base.orbit.mq.kafka;

import com.base.orbit.mq.MqClient;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;

import java.util.List;

public class KafkaMqClient implements MqClient {
    private static final Logger logger = LoggerFactory.getLogger(KafkaMqClient.class);
    private KafkaProducer<String, String> producer;

    public KafkaMqClient(KafkaProducer<String, String> producer) {
        this.producer = producer;
    }

    public void push(String topic, String key, List<String> list) {
        if (!CollectionUtils.isEmpty(list)) {
            list.forEach((value) -> {
                ProducerRecord<String, String> record = new ProducerRecord(topic, key, value);
                this.producer.send(record);
            });
        }
    }

    public void push(String topic, String key, String value) {
        ProducerRecord<String, String> record = new ProducerRecord(topic, key, value);
        this.producer.send(record);
    }
}
