Change line endings to crlf in a few cs files
This commit is contained in:
1 parent
cfc60766d8
commit
d2e9fe8237
2 files changed
+116
-116
No files matched your search
@@ -1,49 +1,49 @@
|
||||
using BCG;
|
||||
|
||||
using bts;
|
||||
using bts.api.core;
|
||||
|
||||
using Bts.DataStreamQueryAnalyzer;
|
||||
using Bts.PubSub;
|
||||
|
||||
using CommandLine;
|
||||
|
||||
using mbts.config;
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
static class Program {
|
||||
[STAThread]
|
||||
static async Task Main(string[] args) {
|
||||
await Parser.Default.ParseArguments<DataStreamQueryAnalyzerConfig>(args)
|
||||
.MapResult(RunAsync, errs => Task.FromResult(1));
|
||||
|
||||
async Task<int> RunAsync(DataStreamQueryAnalyzerConfig cfg) {
|
||||
try {
|
||||
cfg.MergeWithConfigFile();
|
||||
cfg.MergeWith(DataStreamQueryAnalyzerConfig.Default());
|
||||
PubSubConfig.SetGlobalConfig(Log.notnull(cfg.PubSub));
|
||||
Configuration.initialize(cfg.Sparkd);
|
||||
Log.Gen.info("Starting DataStreamQueryAnalyzer");
|
||||
var service_ctx = ServiceContext.create(cfg.Sparkd);
|
||||
await service_ctx.login(cfg.User ?? "bts", cfg.Password ?? string.Empty);
|
||||
Log.Gen.info("Launching Main Window");
|
||||
var mainForm = new MainForm();
|
||||
if (cfg.StreamFile is not null) {
|
||||
mainForm.loadFile(cfg.StreamFile);
|
||||
}
|
||||
Application.Run(mainForm);
|
||||
} catch (Exception ex) {
|
||||
// Write the error to console first, in case the logging system is compromised.
|
||||
var error_msg = $"DataStreamPublisher threw exception:\n{ex}";
|
||||
Console.Error.WriteLine(error_msg);
|
||||
Console.Error.Flush();
|
||||
bts.Log.Gen.error(error_msg);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
using BCG;
|
||||
|
||||
using bts;
|
||||
using bts.api.core;
|
||||
|
||||
using Bts.DataStreamQueryAnalyzer;
|
||||
using Bts.PubSub;
|
||||
|
||||
using CommandLine;
|
||||
|
||||
using mbts.config;
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
static class Program {
|
||||
[STAThread]
|
||||
static async Task Main(string[] args) {
|
||||
await Parser.Default.ParseArguments<DataStreamQueryAnalyzerConfig>(args)
|
||||
.MapResult(RunAsync, errs => Task.FromResult(1));
|
||||
|
||||
async Task<int> RunAsync(DataStreamQueryAnalyzerConfig cfg) {
|
||||
try {
|
||||
cfg.MergeWithConfigFile();
|
||||
cfg.MergeWith(DataStreamQueryAnalyzerConfig.Default());
|
||||
PubSubConfig.SetGlobalConfig(Log.notnull(cfg.PubSub));
|
||||
Configuration.initialize(cfg.Sparkd);
|
||||
Log.Gen.info("Starting DataStreamQueryAnalyzer");
|
||||
var service_ctx = ServiceContext.create(cfg.Sparkd);
|
||||
await service_ctx.login(cfg.User ?? "bts", cfg.Password ?? string.Empty);
|
||||
Log.Gen.info("Launching Main Window");
|
||||
var mainForm = new MainForm();
|
||||
if (cfg.StreamFile is not null) {
|
||||
mainForm.loadFile(cfg.StreamFile);
|
||||
}
|
||||
Application.Run(mainForm);
|
||||
} catch (Exception ex) {
|
||||
// Write the error to console first, in case the logging system is compromised.
|
||||
var error_msg = $"DataStreamPublisher threw exception:\n{ex}";
|
||||
Console.Error.WriteLine(error_msg);
|
||||
Console.Error.Flush();
|
||||
bts.Log.Gen.error(error_msg);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,67 @@
|
||||
namespace Bts.PubSubServer;
|
||||
|
||||
using Bts.PubSub;
|
||||
|
||||
using CommandLine;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
public class PubSubServerConfig {
|
||||
/// <summary>
|
||||
/// The config server url for sparkd
|
||||
/// </summary>
|
||||
[JsonPropertyName("sparkd")]
|
||||
[Option("sparkd", HelpText = "The sparkd config server")]
|
||||
public string? Sparkd { get; set; }
|
||||
|
||||
[JsonPropertyName("simple_echo_server")]
|
||||
[Option("simple-echo-server", HelpText = "Run a simple echo server (won't connect to sparkd)")]
|
||||
public bool? SimpleEchoServer { get; set; }
|
||||
|
||||
[JsonPropertyName("pubsub")]
|
||||
public PubSubConfig? PubSub { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[Option(
|
||||
"config",
|
||||
MetaValue = "PATH",
|
||||
HelpText = "Path to json file representing these options (PubSubServerConfig)")]
|
||||
public string? ConfigFile { get; set; }
|
||||
|
||||
public static PubSubServerConfig Default() =>
|
||||
new() {
|
||||
Sparkd = "http://localhost:8000/config",
|
||||
SimpleEchoServer = false,
|
||||
PubSub = PubSubConfig.Default(),
|
||||
ConfigFile = null,
|
||||
};
|
||||
|
||||
public void MergeWith(PubSubServerConfig other) {
|
||||
Sparkd ??= other.Sparkd;
|
||||
SimpleEchoServer ??= other.SimpleEchoServer;
|
||||
PubSub ??= other.PubSub;
|
||||
ConfigFile ??= other.ConfigFile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges options with those defined in `ConfigFile` (does not overwrite
|
||||
/// non-null existing values).
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// JsonSerializer.Deserialize returns null
|
||||
/// </exception>
|
||||
public void MergeWithConfigFile() {
|
||||
if (ConfigFile is null) {
|
||||
return;
|
||||
}
|
||||
var cfgString = File.ReadAllText(ConfigFile);
|
||||
var parsedCfg = JsonSerializer.Deserialize<PubSubServerConfig>(cfgString) ??
|
||||
throw new InvalidOperationException($"Failed to parse json from {ConfigFile}");
|
||||
MergeWith(parsedCfg);
|
||||
ConfigFile = null;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Bts.PubSubServer;
|
||||
|
||||
using Bts.PubSub;
|
||||
|
||||
using CommandLine;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
public class PubSubServerConfig {
|
||||
/// <summary>
|
||||
/// The config server url for sparkd
|
||||
/// </summary>
|
||||
[JsonPropertyName("sparkd")]
|
||||
[Option("sparkd", HelpText = "The sparkd config server")]
|
||||
public string? Sparkd { get; set; }
|
||||
|
||||
[JsonPropertyName("simple_echo_server")]
|
||||
[Option("simple-echo-server", HelpText = "Run a simple echo server (won't connect to sparkd)")]
|
||||
public bool? SimpleEchoServer { get; set; }
|
||||
|
||||
[JsonPropertyName("pubsub")]
|
||||
public PubSubConfig? PubSub { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[Option(
|
||||
"config",
|
||||
MetaValue = "PATH",
|
||||
HelpText = "Path to json file representing these options (PubSubServerConfig)")]
|
||||
public string? ConfigFile { get; set; }
|
||||
|
||||
public static PubSubServerConfig Default() =>
|
||||
new() {
|
||||
Sparkd = "http://localhost:8000/config",
|
||||
SimpleEchoServer = false,
|
||||
PubSub = PubSubConfig.Default(),
|
||||
ConfigFile = null,
|
||||
};
|
||||
|
||||
public void MergeWith(PubSubServerConfig other) {
|
||||
Sparkd ??= other.Sparkd;
|
||||
SimpleEchoServer ??= other.SimpleEchoServer;
|
||||
PubSub ??= other.PubSub;
|
||||
ConfigFile ??= other.ConfigFile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges options with those defined in `ConfigFile` (does not overwrite
|
||||
/// non-null existing values).
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// JsonSerializer.Deserialize returns null
|
||||
/// </exception>
|
||||
public void MergeWithConfigFile() {
|
||||
if (ConfigFile is null) {
|
||||
return;
|
||||
}
|
||||
var cfgString = File.ReadAllText(ConfigFile);
|
||||
var parsedCfg = JsonSerializer.Deserialize<PubSubServerConfig>(cfgString) ??
|
||||
throw new InvalidOperationException($"Failed to parse json from {ConfigFile}");
|
||||
MergeWith(parsedCfg);
|
||||
ConfigFile = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user