From: Kai Moritz Date: Sun, 17 Sep 2023 10:10:13 +0000 (+0200) Subject: WIP:haproxy X-Git-Tag: rebase--2024-01-26--18-11~9 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=b69babb1f701629e4460f390997f42150edfb7c1;p=demos%2Fkafka%2Fchat WIP:haproxy --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/ChatBackendProperties.java b/src/main/java/de/juplo/kafka/chat/backend/ChatBackendProperties.java index de2dc0d9..8f151e2c 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/ChatBackendProperties.java +++ b/src/main/java/de/juplo/kafka/chat/backend/ChatBackendProperties.java @@ -18,7 +18,7 @@ public class ChatBackendProperties private ServiceType services = ServiceType.inmemory; private InMemoryServicesProperties inmemory = new InMemoryServicesProperties(); private KafkaServicesProperties kafka = new KafkaServicesProperties(); - private URI haproxyRuntimeApiUri = URI.create("haproxy:8401"); + private String haproxyRuntimeApi = "haproxy:8401"; private String haproxyInstanceId = "DEV"; diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/haproxy/HaproxyShardingPublisherStrategy.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/haproxy/HaproxyShardingPublisherStrategy.java index 59917091..e22d75f8 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/haproxy/HaproxyShardingPublisherStrategy.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/haproxy/HaproxyShardingPublisherStrategy.java @@ -3,18 +3,16 @@ package de.juplo.kafka.chat.backend.implementation.haproxy; import de.juplo.kafka.chat.backend.domain.ShardingPublisherStrategy; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; -import java.net.URI; - @RequiredArgsConstructor @Slf4j public class HaproxyShardingPublisherStrategy implements ShardingPublisherStrategy { + private final String host; + private final int port; private final String instanceId; - private final WebClient webClient; @Override diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java index a575e07d..c6822d67 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java @@ -284,14 +284,13 @@ public class KafkaServicesConfiguration @Bean ShardingPublisherStrategy shardingPublisherStrategy( - ChatBackendProperties properties, - WebClient.Builder webClientBuilder) + ChatBackendProperties properties) { - String baseUrl = properties.getHaproxyRuntimeApiUri().toASCIIString(); - WebClient webClient = webClientBuilder.baseUrl(baseUrl).build(); + String[] parts = properties.getHaproxyRuntimeApi().split(":"); return new HaproxyShardingPublisherStrategy( - properties.getHaproxyInstanceId(), - webClient); + parts[0], + Integer.valueOf(parts[1]), + properties.getHaproxyInstanceId()); } @Bean