From: Kai Moritz Date: Fri, 15 Sep 2023 08:48:28 +0000 (+0200) Subject: refactor: Extracted interface `WorkAssignor` into separate file X-Git-Tag: rebase--2024-02-20--15-07~49 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=5893c8aa8ca4b3cb4d85dd11daa48ddc0acfd759;p=demos%2Fkafka%2Fchat refactor: Extracted interface `WorkAssignor` into separate file --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/ConsumerTaskExecutor.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/ConsumerTaskExecutor.java index 881dd293..9425bdf4 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/ConsumerTaskExecutor.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/ConsumerTaskExecutor.java @@ -44,10 +44,4 @@ public class ConsumerTaskExecutor consumerTaskJob.join(); log.info("Joined the consumer-task for {}", consumerTask); } - - - public interface WorkAssignor - { - void assignWork(Consumer consumer); - } } 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 5bde07cd..b5bac470 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 @@ -51,7 +51,7 @@ public class KafkaServicesConfiguration ThreadPoolTaskExecutor taskExecutor, InfoChannel infoChannel, Consumer infoChannelConsumer, - ConsumerTaskExecutor.WorkAssignor infoChannelWorkAssignor) + WorkAssignor infoChannelWorkAssignor) { return new ConsumerTaskExecutor( taskExecutor, @@ -61,8 +61,7 @@ public class KafkaServicesConfiguration } @Bean - ConsumerTaskExecutor.WorkAssignor infoChannelWorkAssignor( - ChatBackendProperties properties) + WorkAssignor infoChannelWorkAssignor(ChatBackendProperties properties) { return consumer -> { @@ -82,7 +81,7 @@ public class KafkaServicesConfiguration ThreadPoolTaskExecutor taskExecutor, DataChannel dataChannel, Consumer dataChannelConsumer, - ConsumerTaskExecutor.WorkAssignor dataChannelWorkAssignor) + WorkAssignor dataChannelWorkAssignor) { return new ConsumerTaskExecutor( taskExecutor, @@ -92,7 +91,7 @@ public class KafkaServicesConfiguration } @Bean - ConsumerTaskExecutor.WorkAssignor dataChannelWorkAssignor( + WorkAssignor dataChannelWorkAssignor( ChatBackendProperties properties, DataChannel dataChannel) { diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/WorkAssignor.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/WorkAssignor.java new file mode 100644 index 00000000..2335e53e --- /dev/null +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/WorkAssignor.java @@ -0,0 +1,9 @@ +package de.juplo.kafka.chat.backend.implementation.kafka; + +import org.apache.kafka.clients.consumer.Consumer; + + +public interface WorkAssignor +{ + void assignWork(Consumer consumer); +} diff --git a/src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java b/src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java index 8fbc557c..a3d60758 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java @@ -90,7 +90,7 @@ class KafkaConfigurationIT extends AbstractConfigurationWithShardingIT static class KafkaConfigurationITConfiguration { @Bean - ConsumerTaskExecutor.WorkAssignor dataChannelWorkAssignor( + WorkAssignor dataChannelWorkAssignor( DataChannel dataChannel) { return consumer -> diff --git a/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java b/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java index 23c1751a..434d997d 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java @@ -59,8 +59,7 @@ public class KafkaChatHomeServiceTest extends ChatHomeServiceWithShardsTest static class KafkaChatHomeTestConfiguration { @Bean - ConsumerTaskExecutor.WorkAssignor dataChannelWorkAssignor( - DataChannel dataChannel) + WorkAssignor dataChannelWorkAssignor(DataChannel dataChannel) { return consumer -> {