9a73f6f173cb85e0a227ea10f6e6eaf7250c905e
[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
23
24   @Getter
25   @Setter
26   public static class InMemoryServicesProperties
27   {
28     private ShardingStrategyType shardingStrategy = ShardingStrategyType.none;
29     private int numShards = 1;
30     private int[] ownedShards = new int[0];
31     private URI[] shardOwners = new URI[0];
32     private StorageStrategyType storageStrategy = StorageStrategyType.none;
33     private String storageDirectory = Paths.get(System.getProperty("java.io.tmpdir"),"chat", "backend").toString();
34   }
35
36   @Getter
37   @Setter
38   public static class KafkaServicesProperties
39   {
40     private URI instanceUri = URI.create("http://localhost:8080");
41     private String clientIdPrefix = "DEV";
42     private String bootstrapServers = ":9092";
43     private String infoChannelTopic = "info_channel";
44     private String dataChannelTopic = "data_channel";
45     private int numPartitions = 2;
46     private String haproxyRuntimeApi = "haproxy:8401";
47     private String haproxyMap = "/usr/local/etc/haproxy/sharding.map";
48   }
49
50   public enum ServiceType { inmemory, kafka }
51   public enum StorageStrategyType { none, files, mongodb }
52   public enum ShardingStrategyType { none, kafkalike }
53 }