-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppSettings.cs
More file actions
64 lines (52 loc) · 2.1 KB
/
AppSettings.cs
File metadata and controls
64 lines (52 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Flash.Configuration.Core;
namespace Flash.Configuration.WebApi.Configuration;
[FlashOrder(1)]
[FlashConfig("AppSettings")]
[FlashConfig("AppSettings", environment: "Development")]
[FlashConfig("AppSettings", environment: "Staging")]
public class AppSettings
{
[FlashField("ApplicationName")] public readonly string ApplicationName = "MyTutorialApp";
[FlashField("Version")] public readonly string Version = "1.0.0";
[FlashProperty("Environment")]
[FlashValue("Development", "Development")]
[FlashValue("Staging", "Staging")]
public string Environment { get; set; } = string.Empty;
[FlashField("EnableFeatureX")] [FlashValue(false, "Development")] [FlashValue(true, "Staging")]
public readonly bool EnableFeatureX = true;
[FlashField("MaxRetryCount")] [FlashValue(2, "Development")] [FlashValue(4, "Staging")]
public readonly int MaxRetryCount = 3;
[FlashField("AllowedHosts")] public readonly string AllowedHosts = "*";
[FlashProperty("MiddlewareSettings", isComplex: true)]
[FlashValueIgnore("Development")]
[FlashValueIgnore("Staging")]
public Settings MiddlewareSettings { get; } = new()
{
SkipUrls = ["/health", "/live"],
HealthUrls = ["/health/ready", "/health/live"]
};
[FlashProperty("LoadBalancingType")]
[FlashValueIgnore("Development")]
[FlashValue(LoadBalancingType.RoundRobin, "Staging")]
public LoadBalancingType LoadBalancingType { get; } = LoadBalancingType.IPHashing;
[FlashProperty("Balancing")]
[FlashValue(LoadBalancingType.LeastConnections, "Development")]
[FlashValue(LoadBalancingType.Weighted, "Staging")]
[FlashEnum]
public LoadBalancingType Balancing { get; } = LoadBalancingType.LeastConnections;
}
[FlashSection]
public class Settings
{
[FlashProperty("Skip-urls")] public required string[] SkipUrls { get; set; }
[FlashProperty("Health-urls")] public required string[] HealthUrls { get; set; }
}
[FlashEnumString]
public enum LoadBalancingType
{
RoundRobin = 1,
LeastConnections = 2,
Weighted = 3,
IPHashing = 4,
Random = 5
}