no.nav.familie.topic.Topic Maven / Gradle / Ivy
package no.nav.familie.topic;
import java.util.Objects;
import org.apache.kafka.common.serialization.Serde;
@SuppressWarnings("rawtypes")
public class Topic {
private final String topic;
private final Serde serdeKey;
private final Serde serdeValue;
Topic(String topic, Serde serdeKey, Serde serdeValue) {
Objects.requireNonNull(topic, "topic");
Objects.requireNonNull(serdeKey, "serdeKey");
Objects.requireNonNull(serdeValue, "serdeValue");
this.topic = topic;
this.serdeKey = serdeKey;
this.serdeValue = serdeValue;
}
public String getTopic() {
return topic;
}
public String getTopicWithEnv(String env) {
Environment environment = Environment.valueOf(env);
return topic + "-" + environment.name();
}
public Serde getSerdeKey() {
return serdeKey;
}
public Serde getSerdeValue() {
return serdeValue;
}
/**
* Genererer clientId basert på standard definert på https://confluence.adeo.no/display/AURA/Kafka#Kafka-TopicogSikkerhetskonfigurasjon
*
* @return clientId
*/
public String getProducerClientId() {
return "KP-" + topic;
}
/**
* Genererer clientId basert på standard definert på https://confluence.adeo.no/display/AURA/Kafka#Kafka-TopicogSikkerhetskonfigurasjon
*
* @return clientId
*/
public String getConsumerClientId() {
return "KC-" + topic;
}
@Override
public String toString() {
return "Topic{" +
"topic='" + topic + '\'' +
", serdeKey=" + serdeKey +
", serdeValue=" + serdeValue +
'}';
}
}