ba794523eedfcce7eccb6737fdd22551cdcdd82e
[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 import java.time.Duration;
10 import java.util.logging.Level;
11
12
13 @ConfigurationProperties("chat.backend")
14 @Getter
15 @Setter
16 public class ChatBackendProperties
17 {
18   private String instanceId = "DEV";
19   private String allowedOrigins = "http://localhost:4200";
20   private int chatroomHistoryLimit = 100;
21   private ServiceType services = ServiceType.inmemory;
22   private InMemoryServicesProperties inmemory = new InMemoryServicesProperties();
23   private KafkaServicesProperties kafka = new KafkaServicesProperties();
24   private ProjectreactorProperties projectreactor = new ProjectreactorProperties();
25
26
27   @Getter
28   @Setter
29   public static class InMemoryServicesProperties
30   {
31     private ShardingStrategyType shardingStrategy = ShardingStrategyType.none;
32     private int numShards = 1;
33     private int[] ownedShards = new int[0];
34     private URI[] shardOwners = new URI[0];
35     private StorageStrategyType storageStrategy = StorageStrategyType.none;
36     private String storageDirectory = Paths.get(System.getProperty("java.io.tmpdir"),"chat", "backend").toString();
37   }
38
39   @Getter
40   @Setter
41   public static class KafkaServicesProperties
42   {
43     private URI instanceUri = URI.create("http://localhost:8080");
44     private String clientIdPrefix = "DEV";
45     private String bootstrapServers = ":9092";
46     private String infoChannelTopic = "info_channel";
47     private String dataChannelTopic = "data_channel";
48     private int numPartitions = 2;
49     private Duration pollingInterval = Duration.ofSeconds(1);
50     private String haproxyRuntimeApi = "haproxy:8401";
51     private String haproxyMap = "/usr/local/etc/haproxy/sharding.map";
52   }
53
54   @Getter
55   @Setter
56   public static class ProjectreactorProperties
57   {
58     private Level loggingLevel = Level.FINE;
59     private boolean showOperatorLine = true;
60   }
61   public enum ServiceType { inmemory, kafka }
62   public enum StorageStrategyType { none, files, mongodb }
63   public enum ShardingStrategyType { none, kafkalike }
64 }