refactor: Extracted interface `WorkAssignor` into separate file
authorKai Moritz <kai@juplo.de>
Fri, 15 Sep 2023 08:48:28 +0000 (10:48 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 27 Jan 2024 14:16:23 +0000 (15:16 +0100)
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/ConsumerTaskExecutor.java
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesConfiguration.java
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/WorkAssignor.java [new file with mode: 0644]
src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java
src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java

index 881dd29..9425bdf 100644 (file)
@@ -44,10 +44,4 @@ public class ConsumerTaskExecutor
     consumerTaskJob.join();
     log.info("Joined the consumer-task for {}", consumerTask);
   }
-
-
-  public interface WorkAssignor
-  {
-    void assignWork(Consumer<?, ?> consumer);
-  }
 }
index 5bde07c..b5bac47 100644 (file)
@@ -51,7 +51,7 @@ public class KafkaServicesConfiguration
       ThreadPoolTaskExecutor taskExecutor,
       InfoChannel infoChannel,
       Consumer<String, AbstractMessageTo> 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<String, AbstractMessageTo> 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 (file)
index 0000000..2335e53
--- /dev/null
@@ -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);
+}
index 8fbc557..a3d6075 100644 (file)
@@ -90,7 +90,7 @@ class KafkaConfigurationIT extends AbstractConfigurationWithShardingIT
   static class KafkaConfigurationITConfiguration
   {
     @Bean
-    ConsumerTaskExecutor.WorkAssignor dataChannelWorkAssignor(
+    WorkAssignor dataChannelWorkAssignor(
         DataChannel dataChannel)
     {
       return consumer ->
index 23c1751..434d997 100644 (file)
@@ -59,8 +59,7 @@ public class KafkaChatHomeServiceTest extends ChatHomeServiceWithShardsTest
   static class KafkaChatHomeTestConfiguration
   {
     @Bean
-    ConsumerTaskExecutor.WorkAssignor dataChannelWorkAssignor(
-        DataChannel dataChannel)
+    WorkAssignor dataChannelWorkAssignor(DataChannel dataChannel)
     {
       return consumer ->
       {