From b69babb1f701629e4460f390997f42150edfb7c1 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 17 Sep 2023 12:10:13 +0200 Subject: [PATCH] WIP:haproxy --- .../kafka/chat/backend/ChatBackendProperties.java | 2 +- .../haproxy/HaproxyShardingPublisherStrategy.java | 6 ++---- .../kafka/KafkaServicesConfiguration.java | 11 +++++------ 3 files changed, 8 insertions(+), 11 deletions(-) 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 -- 2.20.1