pl.allegro.tech.hermes.management.config.kafka.MultipleDcKafkaNamesMappersFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hermes-management Show documentation
Show all versions of hermes-management Show documentation
Fast and reliable message broker built on top of Kafka.
package pl.allegro.tech.hermes.management.config.kafka;
import static java.util.stream.Collectors.toMap;
import java.util.Map;
import java.util.function.Function;
import pl.allegro.tech.hermes.common.kafka.KafkaNamesMapper;
import pl.allegro.tech.hermes.common.kafka.NamespaceKafkaNamesMapper;
public interface MultipleDcKafkaNamesMappersFactory {
default KafkaNamesMappers createDefaultKafkaNamesMapper(
KafkaClustersProperties clustersProperties) {
return createKafkaNamesMapper(
clustersProperties,
namespace ->
new NamespaceKafkaNamesMapper(namespace, clustersProperties.getNamespaceSeparator()));
}
default KafkaNamesMappers createKafkaNamesMapper(
KafkaClustersProperties clustersProperties,
Function factoryFunction) {
Map mappers =
clustersProperties.getClusters().stream()
.filter(c -> c.getNamespace().isEmpty())
.collect(
toMap(
KafkaProperties::getQualifiedClusterName,
kafkaProperties ->
factoryFunction.apply(clustersProperties.getDefaultNamespace())));
mappers.putAll(
clustersProperties.getClusters().stream()
.filter(c -> !c.getNamespace().isEmpty())
.collect(
toMap(
KafkaProperties::getQualifiedClusterName,
kafkaProperties -> factoryFunction.apply(kafkaProperties.getNamespace()))));
return new KafkaNamesMappers(mappers);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy