Remove unused PubSubConfig props

This commit is contained in:
John Colvin committed 2024-09-18 14:02:35 +00:00
1 parent 08319cfd38
commit cb5fcee2ce
2 files changed
-133

No files matched your search

@@ -26,80 +26,27 @@ public class PubSubConfig {
public bool? SimpleEchoServer { get; set; }
// unused
public int? MillisecondsBetweenSubInfoUpdates { get; set; } = 1000;
// unused
public int? MillisecondsBetweenTimeSliceUpdates { get; set; } = 5000;
// unused
public int? MillisecondsBetweenNoBufferRetries { get; set; } = 100;
// unused
public int? RetriesOnNoBufferSpace { get; set; } = 1;
// unused
public int? DoItAllSecondsBetweenLog { get; set; } = 0;
// Used by the PubSubMessageReactor to pass to the ManagedTCPMessageHb (but unsed within it)
public int? HeartbeatInterval { get; set; } = 15000;
public int? MissingHeartbeatsBeforeGc { get; set; } = 50;
// unused
// Milliseconds
public int? StateUpdatePeriod { get; set; } = 5000;
// unused
// Milliseconds
public int? StatisticsUpdatePeriod { get; set; } = 5000;
// Milliseconds
public int? DisposedConnectionCheckPeriod { get; set; } = 1000;
public TagTypeToAssembly? TagTypeToAssemblyMap { get; set; }
public PubSubTagHandlerFactoryConfig? TagHandlerFactory { get; set; }
// unused
public int? LatencyReportThresholdMs { get; set; }
// unused
public bool? InternallyPublishSubInfo { get; set; }
public string? CompressedTags { get; set; }
public int? GcActivationThreshold { get; set; }
// Milliseconds
public int? WaitPeriodAfterGc { get; set; }
public PubSubRouterConfig? Routing { get; set; }
public List<PubSubRoute>? PublisherRoutes => Routing?.PublisherRoutes;
public List<PubSubRoute>? SubscriberRoutes => Routing?.SubscriberRoutes;
public static PubSubConfig Default() {
const string NOTAGS = "^NOTAGS$";
var rv = new PubSubConfig() {
MillisecondsBetweenSubInfoUpdates = 1000,
MillisecondsBetweenTimeSliceUpdates = 5000,
MillisecondsBetweenNoBufferRetries = 100,
RetriesOnNoBufferSpace = 1,
DoItAllSecondsBetweenLog = 0,
HeartbeatInterval = 15000,
MissingHeartbeatsBeforeGc = 50,
StateUpdatePeriod = 5000,
StatisticsUpdatePeriod = 5000,
DisposedConnectionCheckPeriod = 1000,
ServerPort = 12345,
TagTypeToAssemblyMap = new(),
TagHandlerFactory = PubSubTagHandlerFactoryConfig.Default(),
LatencyReportThresholdMs = 1500,
InternallyPublishSubInfo = true,
CompressedTags = NOTAGS,
GcActivationThreshold = 0,
WaitPeriodAfterGc = 1000,
SimpleEchoServer = false,
Routing = new() {
PublisherRoutes = new() {
@@ -114,24 +61,11 @@ public class PubSubConfig {
}
public void MergeWith(PubSubConfig other) {
MillisecondsBetweenSubInfoUpdates ??= other.MillisecondsBetweenSubInfoUpdates;
MillisecondsBetweenTimeSliceUpdates ??= other.MillisecondsBetweenTimeSliceUpdates;
MillisecondsBetweenNoBufferRetries ??= other.MillisecondsBetweenNoBufferRetries;
RetriesOnNoBufferSpace ??= other.RetriesOnNoBufferSpace;
DoItAllSecondsBetweenLog ??= other.DoItAllSecondsBetweenLog;
HeartbeatInterval ??= other.HeartbeatInterval;
MissingHeartbeatsBeforeGc ??= other.MissingHeartbeatsBeforeGc;
StateUpdatePeriod ??= other.StateUpdatePeriod;
StatisticsUpdatePeriod ??= other.StatisticsUpdatePeriod;
DisposedConnectionCheckPeriod ??= other.DisposedConnectionCheckPeriod;
ServerPort ??= other.ServerPort;
TagTypeToAssemblyMap ??= other.TagTypeToAssemblyMap;
TagHandlerFactory ??= other.TagHandlerFactory;
LatencyReportThresholdMs ??= other.LatencyReportThresholdMs;
InternallyPublishSubInfo ??= other.InternallyPublishSubInfo;
CompressedTags ??= other.CompressedTags;
GcActivationThreshold ??= other.GcActivationThreshold;
WaitPeriodAfterGc ??= other.WaitPeriodAfterGc;
SimpleEchoServer ??= other.SimpleEchoServer;
if (other.Routing is not null) {
if (Routing is null) {
@@ -1,67 +0,0 @@
using System;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
namespace BCG
{
/*
* PubSubPortRange.cs
*
* This class represents a range of ports that could be used by a server.
* Servers that wish to provide services ask the blue pages for a port they can use,
* and blue pages replies with a port.
*
* */
[JsonConverter(typeof(PubSubPortRangeJsonConverter))]
public class PubSubPortRange
{
public PubSubPortRange()
{
}
public PubSubPortRange(int min, int max)
{
minPort = min;
maxPort = max;
}
public int minPort;
public int maxPort;
}
public class PubSubPortRangeJsonConverter : JsonConverter<PubSubPortRange> {
public override PubSubPortRange? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {
var rv = new PubSubPortRange();
var jsonObj = JsonSerializer.Deserialize<JsonObject>(ref reader, options);
if (jsonObj is null) {
return null;
}
ReadPrimitive("min_port", ref rv.minPort);
ReadPrimitive("max_port", ref rv.maxPort);
return rv;
void ReadPrimitive<T>(string key, ref T valueOut) where T : struct {
if (jsonObj.TryGetPropertyValue(key, out var valueJson)) {
var valueInt = valueJson?.GetValue<T>();
// Only (over)write valueOut if non-null
if (valueInt.HasValue) {
valueOut = valueInt.Value;
}
}
}
}
public override void Write(Utf8JsonWriter writer, PubSubPortRange value, JsonSerializerOptions options) {
var jsonObj = new JsonObject {
["min_port"] = value.minPort,
["max_port"] = value.maxPort,
};
JsonSerializer.Serialize(writer, jsonObj, options);
}
}
}