WIP:haproxy
authorKai Moritz <kai@juplo.de>
Sun, 17 Sep 2023 10:10:13 +0000 (12:10 +0200)
committerKai Moritz <kai@juplo.de>
Sun, 17 Sep 2023 10:10:13 +0000 (12:10 +0200)
src/main/java/de/juplo/kafka/chat/backend/ChatBackendProperties.java
src/main/java/de/juplo/kafka/chat/backend/implementation/haproxy/HaproxyShardingPublisherStrategy.java
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java

index de2dc0d..8f151e2 100644 (file)
@@ -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";
 
 
index 5991709..e22d75f 100644 (file)
@@ -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
index a575e07..c6822d6 100644 (file)
@@ -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