Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit a3b623c

Browse files
committed
Additions to the OptionsDescription model. Closes GH-12. Closes GH-13. Closes GH-14
1 parent 3c8eb3d commit a3b623c

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace JasperFx.Core.Descriptions;
2+
3+
public enum MetricsType
4+
{
5+
Histogram,
6+
Counter,
7+
ObservableGauge
8+
}
9+
10+
public class MetricDescription
11+
{
12+
public string Name { get; }
13+
public MetricsType Type { get; }
14+
15+
public MetricDescription(string name, MetricsType type)
16+
{
17+
Name = name;
18+
Type = type;
19+
}
20+
21+
public string Units { get; set; } = "Number";
22+
23+
public Dictionary<string, string> Tags = new();
24+
}

src/JasperFx.Core/Descriptions/OptionsDescription.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ public interface IDescribeMyself
1010
OptionsDescription ToDescription();
1111
}
1212

13+
public class OptionSet
14+
{
15+
public string Subject { get; set; }
16+
public string[] SummaryColumns { get; set; } = Array.Empty<string>();
17+
public List<OptionsDescription> Rows { get; set; } = new();
18+
}
19+
1320
/// <summary>
1421
/// Just a serializable, readonly view of system configuration to be used for diagnostic purposes
1522
/// </summary>
@@ -19,6 +26,11 @@ public class OptionsDescription
1926
public List<OptionsValue> Properties { get; set; } = new();
2027

2128
public Dictionary<string, OptionsDescription> Children = new();
29+
30+
/// <summary>
31+
/// Children "sets" of option descriptions
32+
/// </summary>
33+
public Dictionary<string, OptionSet> Sets = new();
2234

2335
// For serialization
2436
public OptionsDescription()
@@ -54,6 +66,29 @@ public OptionsDescription(object subject)
5466
}
5567
}
5668

69+
public OptionSet AddChildSet(string name)
70+
{
71+
var subject = $"{Subject}.{name}";
72+
var set = new OptionSet { Subject = subject };
73+
Sets[name] = set;
74+
return set;
75+
}
76+
77+
public OptionSet AddChildSet(string name, IEnumerable<object> children)
78+
{
79+
var set = AddChildSet(name);
80+
foreach (var child in children)
81+
{
82+
var description = child is IDescribeMyself describes
83+
? describes.ToDescription()
84+
: new OptionsDescription(child);
85+
86+
set.Rows.Add(description);
87+
}
88+
89+
return set;
90+
}
91+
5792
public OptionsValue AddValue(string name, object value)
5893
{
5994
var subject = $"{Subject}.{name}";
@@ -72,4 +107,8 @@ public OptionsValue AddValue(string name, object value)
72107
{
73108
return Properties.FirstOrDefault(x => x.Name.EqualsIgnoreCase(name));
74109
}
110+
111+
public Dictionary<string, string> Tags = new();
112+
113+
public List<MetricDescription> Metrics { get; set; } = new();
75114
}

src/JasperFx.Core/JasperFx.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Description>Common extension methods and reflection helpers used by JasperFx projects</Description>
5-
<Version>1.10.0</Version>
5+
<Version>1.11.0</Version>
66
<Authors>Jeremy D. Miller</Authors>
77
<AssemblyName>JasperFx.Core</AssemblyName>
88
<PackageId>JasperFx.Core</PackageId>

0 commit comments

Comments
 (0)