Add DataStreamPublisher service modules designed for Dependency Injection

* Change DataStreamPublisher json fields to match cs class property names verbatim
* Rename Publishers -> PublisherNodes in DataStreamPublisherConfig
This commit is contained in:
John Colvin committed 2024-09-18 14:02:35 +00:00
1 parent 24e5683ad2
commit 3f6f5ab0e0
12 files changed
+387 -283

No files matched your search

@@ -1,7 +1,5 @@
namespace Bts.DataStreamPublisher;
using Bts.PubSub;
using CommandLine;
using System;
@@ -11,35 +9,12 @@ using System.Text.Json;
using System.Text.Json.Serialization;
public class DataStreamPublisherConfig {
/// <summary>
/// The login user for sparkd
/// </summary>
[JsonPropertyName("user")]
[Option("user", HelpText = "The sparkd login user")]
public string? User { get; set; }
/// <summary>
/// The login password for sparkd
/// </summary>
[JsonPropertyName("password")]
[Option("pass", HelpText = "The sparkd login password")]
public string? Password { get; set; }
/// <summary>
/// The config server url for sparkd
/// </summary>
[JsonPropertyName("sparkd")]
[Option("sparkd", HelpText = "The sparkd config server")]
public string? Sparkd { get; set; }
/// <summary>
/// The tables to publish on startup. Each key/value represents a table name/query to publish.
/// </summary>
[JsonPropertyName("publishers")]
public List<PublisherNode>? Publishers { get; set; }
public List<PublisherNode>? PublisherNodes { get; set; }
[JsonPropertyName("pubsub")]
public PubSubConfig? PubSub { get; set; }
public List<string>? CsvDirs { get; set; }
[Option(
"config",
@@ -49,16 +24,10 @@ public class DataStreamPublisherConfig {
public string? ConfigFile { get; set; }
public static DataStreamPublisherConfig Default() =>
new() {
PubSub = PubSubConfig.Default(),
};
new() { };
public void MergeWith(DataStreamPublisherConfig other) {
User ??= other.User;
Password ??= other.Password;
Sparkd ??= other.Sparkd;
Publishers ??= other.Publishers;
PubSub ??= other.PubSub;
PublisherNodes ??= other.PublisherNodes;
ConfigFile ??= other.ConfigFile;
}