-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuntimeStateOptions.cs
More file actions
59 lines (43 loc) · 1.66 KB
/
RuntimeStateOptions.cs
File metadata and controls
59 lines (43 loc) · 1.66 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
namespace ApiHealthDashboard.Configuration;
public sealed class RuntimeStateOptions
{
public const string SectionName = "RuntimeState";
public bool Enabled { get; set; } = true;
public string DirectoryPath { get; set; } = "runtime-state/endpoints";
public bool CleanupEnabled { get; set; } = true;
public double CleanupIntervalMinutes { get; set; } = 30;
public bool DeleteOrphanedStateFiles { get; set; } = true;
public double OrphanedStateFileRetentionHours { get; set; } = 5;
public int RecentSampleLimit { get; set; } = 25;
public int NotificationHistoryLimit { get; set; } = 20;
public string ResolveDirectoryPath(string contentRootPath)
{
ArgumentException.ThrowIfNullOrWhiteSpace(contentRootPath);
var configuredPath = string.IsNullOrWhiteSpace(DirectoryPath)
? "runtime-state/endpoints"
: DirectoryPath;
return Path.IsPathRooted(configuredPath)
? Path.GetFullPath(configuredPath)
: Path.GetFullPath(Path.Combine(contentRootPath, configuredPath));
}
public TimeSpan GetCleanupInterval()
{
return CleanupIntervalMinutes <= 0
? TimeSpan.Zero
: TimeSpan.FromMinutes(CleanupIntervalMinutes);
}
public TimeSpan GetOrphanedStateFileRetention()
{
return OrphanedStateFileRetentionHours <= 0
? TimeSpan.Zero
: TimeSpan.FromHours(OrphanedStateFileRetentionHours);
}
public int GetRecentSampleLimit()
{
return Math.Max(RecentSampleLimit, 0);
}
public int GetNotificationHistoryLimit()
{
return Math.Max(NotificationHistoryLimit, 0);
}
}