WIP - Ein Versuch (vielleicht Unsinn)
[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.net.URI;
8 import java.nio.file.Paths;
9
10
11 @ConfigurationProperties("chat.backend")
12 @Getter
13 @Setter
14 public class ChatBackendProperties
15 {
16   private String instanceId = "DEV";
17   private String allowedOrigins = "http://localhost:4200";
18   private int chatroomBufferSize = 8;
19   private ServiceType services = ServiceType.inmemory;
20   private InMemoryServicesProperties inmemory = new InMemoryServicesProperties();
21   private KafkaServicesProperties kafka = new KafkaServicesProperties();
22   private String haproxyRuntimeApi = "haproxy:8401";
23   private String haproxyMap = "/usr/local/etc/haproxy/sharding.map";
24
25
26   @Getter
27   @Setter
28   public static class InMemoryServicesProperties
29   {
30     private ShardingStrategyType shardingStrategy = ShardingStrategyType.none;
31     private int numShards = 1;
32     private int[] ownedShards = new int[0];
33     private URI[] shardOwners = new URI[0];
34     private StorageStrategyType storageStrategy = StorageStrategyType.none;
35     private String storageDirectory = Paths.get(System.getProperty("java.io.tmpdir"),"chat", "backend").toString();
36   }
37
38   @Getter
39   @Setter
40   public static class KafkaServicesProperties
41   {
42     private URI instanceUri = URI.create("http://localhost:8080");
43     private String clientIdPrefix = "DEV";
44     private String bootstrapServers = ":9092";
45     private String infoChannelTopic = "info_channel";
46     private String dataChannelTopic = "data_channel";
47     private int numPartitions = 2;
48   }
49
50   public enum ServiceType { inmemory, kafka }
51   public enum StorageStrategyType { none, files, mongodb }
52   public enum ShardingStrategyType { none, kafkalike }
53 }