NEU
[demos/kafka/chat] / src / main / java / de / juplo / kafka / chat / backend / ChatBackendProperties.java
1 package de.juplo.kafka.chat.backend;
2
3 import lombok.Getter;
4 import lombok.Setter;
5 import org.springframework.boot.context.properties.ConfigurationProperties;
6
7 import java.nio.file.Paths;
8
9
10 @ConfigurationProperties("chat.backend")
11 @Getter
12 @Setter
13 public class ChatBackendProperties
14 {
15   private String allowedOrigins = "http://localhost:4200";
16   private int chatroomBufferSize = 8;
17   private ServiceType services = ServiceType.inmemory;
18   private InMemoryServicesProperties inmemory = new InMemoryServicesProperties();
19   private KafkaServicesProperties kafka = new KafkaServicesProperties();
20
21
22   @Getter
23   @Setter
24   public static class InMemoryServicesProperties
25   {
26     private ShardingStrategyType shardingStrategy = ShardingStrategyType.none;
27     private int numShards = 1;
28     private int[] ownedShards = new int[] { 0 };
29     private StorageStrategyType storageStrategy = StorageStrategyType.files;
30     private String storageDirectory = Paths.get(System.getProperty("java.io.tmpdir"),"chat", "backend").toString();
31   }
32
33   @Getter
34   @Setter
35   public static class KafkaServicesProperties
36   {
37     private String clientId;
38     private String bootstrapServers = ":9092";
39     private String topic = "test";
40     private int numPartitions = 2;
41   }
42
43   public enum ServiceType { inmemory }
44   public enum StorageStrategyType { files, mongodb }
45   public enum ShardingStrategyType { none, kafkalike }
46 }