Skip to content

Commit

Permalink
rename plebeian
Browse files Browse the repository at this point in the history
  • Loading branch information
volllly committed Oct 24, 2023
1 parent bc51028 commit cfd28da
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 51 deletions.
22 changes: 11 additions & 11 deletions src/fiskaltrust.Launcher/Commands/DoctorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public async Task<int> InvokeAsync(InvocationContext context)

await CheckAwait("Start monarch WebApplication", async () => await WithTimeout(async () => await monarchApp.StartAsync(_lifetime.ApplicationLifetime.ApplicationStopping), TimeSpan.FromSeconds(5)), throws: true);

var plebianConfiguration = new PlebianConfiguration
var plebeianConfiguration = new PlebeianConfiguration
{
PackageId = doctorId,
PackageType = Constants.PackageType.Queue
Expand All @@ -167,24 +167,24 @@ public async Task<int> InvokeAsync(InvocationContext context)
var packageConfiguration = new PackageConfiguration
{
Configuration = new(),
Id = plebianConfiguration.PackageId,
Id = plebeianConfiguration.PackageId,
Package = "none",
Url = Array.Empty<string>(),
Version = "1.0.0"
};

IProcessHostService? processHostService = Check("Start plebian processhostservice client", () => GrpcChannel.ForAddress($"http://localhost:{launcherConfiguration.LauncherPort}").CreateGrpcService<IProcessHostService>());
IProcessHostService? processHostService = Check("Start plebeian processhostservice client", () => GrpcChannel.ForAddress($"http://localhost:{launcherConfiguration.LauncherPort}").CreateGrpcService<IProcessHostService>());

var plebianBuilder = Host.CreateDefaultBuilder()
var plebeianBuilder = Host.CreateDefaultBuilder()
.UseSerilog(new LoggerConfiguration().CreateLogger())
.ConfigureServices(services =>
{
Check("Setup plebian services", () =>
Check("Setup plebeian services", () =>
{
services.Configure<HostOptions>(opts => opts.ShutdownTimeout = TimeSpan.FromSeconds(30));
services.AddSingleton(_ => launcherConfiguration);
services.AddSingleton(_ => packageConfiguration);
services.AddSingleton(_ => plebianConfiguration);
services.AddSingleton(_ => plebeianConfiguration);

var pluginLoader = new PluginLoader();
services.AddSingleton(_ => pluginLoader);
Expand All @@ -195,7 +195,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
}

services.AddSingleton<HostingService>();
services.AddHostedService<ProcessHostPlebian>();
services.AddHostedService<ProcessHostPlebeian>();

services.AddSingleton<IClientFactory<IDESSCD>, DESSCDClientFactory>();
services.AddSingleton<IClientFactory<IPOS>, POSClientFactory>();
Expand All @@ -212,9 +212,9 @@ public async Task<int> InvokeAsync(InvocationContext context)
}, throws: true);
});

var plebianApp = Check("Build plebian Host", plebianBuilder.Build, throws: true)!;
var plebeianApp = Check("Build plebeian Host", plebeianBuilder.Build, throws: true)!;

await CheckAwait("Start plebian Host", async () => await WithTimeout(async () => await plebianApp.StartAsync(_lifetime.ApplicationLifetime.ApplicationStopping), TimeSpan.FromSeconds(5)));
await CheckAwait("Start plebeian Host", async () => await WithTimeout(async () => await plebeianApp.StartAsync(_lifetime.ApplicationLifetime.ApplicationStopping), TimeSpan.FromSeconds(5)));

await doctorProcessHostMonarch.IsStarted.Task;

Expand All @@ -225,8 +225,8 @@ await CheckAwait("Shutdown launcher gracefully", async () => await WithTimeout(a
await monarchApp.StopAsync();
await monarchApp.WaitForShutdownAsync();

await plebianApp.StopAsync();
await plebianApp.WaitForShutdownAsync();
await plebeianApp.StopAsync();
await plebeianApp.WaitForShutdownAsync();
}, TimeSpan.FromSeconds(5))
);
}
Expand Down
14 changes: 7 additions & 7 deletions src/fiskaltrust.Launcher/Commands/HostCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class HostCommand : Command
{
public HostCommand() : base("host")
{
AddOption(new Option<string>("--plebian-configuration"));
AddOption(new Option<string>("--plebeian-configuration"));
AddOption(new Option<string>("--debugging"));
AddOption(new Option<string>("--launcher-configuration"));
AddOption(new Option<bool>("--no-process-host-service", getDefaultValue: () => false));
Expand All @@ -38,7 +38,7 @@ public HostCommand() : base("host")
public class HostCommandHandler : ICommandHandler
{
public string LauncherConfiguration { get; set; } = null!;
public string PlebianConfiguration { get; set; } = null!;
public string PlebeianConfiguration { get; set; } = null!;
public bool NoProcessHostService { get; set; }
public bool Debugging { get; set; }

Expand All @@ -63,19 +63,19 @@ public async Task<int> InvokeAsync(InvocationContext context)

var launcherConfiguration = Common.Configuration.LauncherConfiguration.Deserialize(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(LauncherConfiguration)));

var plebianConfiguration = Configuration.PlebianConfiguration.Deserialize(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(PlebianConfiguration)));
var plebeianConfiguration = Configuration.PlebeianConfiguration.Deserialize(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(PlebeianConfiguration)));

var cashboxConfiguration = CashBoxConfigurationExt.Deserialize(await File.ReadAllTextAsync(launcherConfiguration.CashboxConfigurationFile!));

cashboxConfiguration.Decrypt(launcherConfiguration, await CommonCommandHandler.LoadCurve(launcherConfiguration.AccessToken!, launcherConfiguration.UseLegacyDataProtection!.Value));

var packageConfiguration = (plebianConfiguration.PackageType switch
var packageConfiguration = (plebeianConfiguration.PackageType switch
{
PackageType.Queue => cashboxConfiguration.ftQueues,
PackageType.SCU => cashboxConfiguration.ftSignaturCreationDevices,
PackageType.Helper => cashboxConfiguration.helpers,
var unknown => throw new Exception($"Unknown PackageType {unknown}")
}).First(p => p.Id == plebianConfiguration.PackageId);
}).First(p => p.Id == plebeianConfiguration.PackageId);

packageConfiguration.Configuration = ProcessPackageConfiguration(packageConfiguration.Configuration, launcherConfiguration, cashboxConfiguration);

Expand Down Expand Up @@ -103,7 +103,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
});
services.AddSingleton(_ => launcherConfiguration);
services.AddSingleton(_ => packageConfiguration);
services.AddSingleton(_ => plebianConfiguration);
services.AddSingleton(_ => plebeianConfiguration);

var pluginLoader = new PluginLoader();
services.AddSingleton(_ => pluginLoader);
Expand All @@ -114,7 +114,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
}

services.AddSingleton<HostingService>();
services.AddHostedService<ProcessHostPlebian>();
services.AddHostedService<ProcessHostPlebeian>();

services.AddSingleton<IClientFactory<IDESSCD>, DESSCDClientFactory>();
services.AddSingleton<IClientFactory<IITSSCD>, ITSSCDClientFactory>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

namespace fiskaltrust.Launcher.Configuration
{
public record PlebianConfiguration
public record PlebeianConfiguration
{
public PackageType PackageType { get; set; }
public Guid PackageId { get; set; }

public static PlebianConfiguration Deserialize(string text) => JsonSerializer.Deserialize(text, typeof(PlebianConfiguration), Helpers.Serialization.SerializerContext.Default) as PlebianConfiguration ?? throw new Exception($"Could not deserialize {nameof(PlebianConfiguration)}");
public static PlebeianConfiguration Deserialize(string text) => JsonSerializer.Deserialize(text, typeof(PlebeianConfiguration), Helpers.Serialization.SerializerContext.Default) as PlebeianConfiguration ?? throw new Exception($"Could not deserialize {nameof(PlebeianConfiguration)}");

public string Serialize() => JsonSerializer.Serialize(this, typeof(PlebianConfiguration), Helpers.Serialization.SerializerContext.Default);
public string Serialize() => JsonSerializer.Serialize(this, typeof(PlebeianConfiguration), Helpers.Serialization.SerializerContext.Default);
}
}
2 changes: 1 addition & 1 deletion src/fiskaltrust.Launcher/Helpers/SerializerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

namespace fiskaltrust.Launcher.Helpers.Serialization
{
[JsonSerializable(typeof(PlebianConfiguration))]
[JsonSerializable(typeof(PlebeianConfiguration))]
public partial class SerializerContext : JsonSerializerContext { }
}
14 changes: 7 additions & 7 deletions src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ProcessHostMonarch : IProcessHostMonarch

private readonly PackageConfiguration _packageConfiguration;
private readonly ILogger<ProcessHostMonarch> _logger;
private readonly List<string> _plebianLogBuffer = new List<string>();
private readonly List<string> _plebeianLogBuffer = new List<string>();
private LauncherConfiguration _launcherConfiguration;
private PackageType _packageType;
private LauncherExecutablePath _launcherExecutablePath;
Expand Down Expand Up @@ -63,7 +63,7 @@ private void Setup()
CreateNoWindow = false,
Arguments = string.Join(" ", new string[] {
"host",
"--plebian-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(new PlebianConfiguration { PackageType = _packageType, PackageId = _packageConfiguration.Id }.Serialize()))}\"",
"--plebeian-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(new PlebeianConfiguration { PackageType = _packageType, PackageId = _packageConfiguration.Id }.Serialize()))}\"",
"--launcher-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(_launcherConfiguration.Serialize()))}\"",
}),
RedirectStandardInput = true,
Expand All @@ -81,7 +81,7 @@ private void ReceiveStdOut(object sender, DataReceivedEventArgs e)
{
if (e.Data != null)
{
_plebianLogBuffer.Add(e.Data);
_plebeianLogBuffer.Add(e.Data);
}
}

Expand Down Expand Up @@ -122,11 +122,11 @@ private async Task HandleExit(CancellationToken cancellationToken)
if (!_started.Task.IsCompleted)
{
// If the process hat not signaled startup, we print the log buffer.
_logger.LogError($"Error while starting {{package}} {{id}}.{Environment.NewLine}{{error}}", _packageConfiguration.Package, _packageConfiguration.Id, string.Join(Environment.NewLine, _plebianLogBuffer));
_plebianLogBuffer.Clear();
_logger.LogError($"Error while starting {{package}} {{id}}.{Environment.NewLine}{{error}}", _packageConfiguration.Package, _packageConfiguration.Id, string.Join(Environment.NewLine, _plebeianLogBuffer));
_plebeianLogBuffer.Clear();
}

// Plebian crash happened during the startup phase so we don't went to keep restarting.
// Plebeian crash happened during the startup phase so we don't went to keep restarting.
if (!_monarchStartupCompleted)
{
_started.TrySetCanceled();
Expand Down Expand Up @@ -212,7 +212,7 @@ public void SetPlebeanStarted()
_process.OutputDataReceived -= ReceiveStdOut;
_process.ErrorDataReceived -= ReceiveStdOut;
}
_plebianLogBuffer.Clear();
_plebeianLogBuffer.Clear();
}

public void SetStartupCompleted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
namespace fiskaltrust.Launcher.ProcessHost
{

public class ProcessHostPlebian : BackgroundService
public class ProcessHostPlebeian : BackgroundService
{
private readonly PackageConfiguration _packageConfiguration;
private readonly IProcessHostService? _processHostService;
private readonly HostingService _hosting;
private readonly PlebianConfiguration _plebianConfiguration;
private readonly PlebeianConfiguration _plebeianConfiguration;
private readonly LauncherConfiguration _launcherConfiguration;
private readonly ILogger<ProcessHostPlebian> _logger;
private readonly ILogger<ProcessHostPlebeian> _logger;
private readonly IServiceProvider _services;
private readonly IHostApplicationLifetime _lifetime;

public ProcessHostPlebian(ILogger<ProcessHostPlebian> logger, HostingService hosting, LauncherConfiguration launcherConfiguration, PackageConfiguration packageConfiguration, PlebianConfiguration plebianConfiguration, IServiceProvider services, IHostApplicationLifetime lifetime, IProcessHostService? processHostService = null)
public ProcessHostPlebeian(ILogger<ProcessHostPlebeian> logger, HostingService hosting, LauncherConfiguration launcherConfiguration, PackageConfiguration packageConfiguration, PlebeianConfiguration plebeianConfiguration, IServiceProvider services, IHostApplicationLifetime lifetime, IProcessHostService? processHostService = null)
{
_logger = logger;
_hosting = hosting;
_launcherConfiguration = launcherConfiguration;
_packageConfiguration = packageConfiguration;
_plebianConfiguration = plebianConfiguration;
_plebeianConfiguration = plebeianConfiguration;
_services = services;
_processHostService = processHostService;
_lifetime = lifetime;
Expand All @@ -45,7 +45,7 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{
await StartHosting(_packageConfiguration.Url);

if (_plebianConfiguration.PackageType == PackageType.Helper)
if (_plebeianConfiguration.PackageType == PackageType.Helper)
{
_logger.LogDebug("Helper StartBegin() and StartEnd()");
var helper = _services.GetRequiredService<IHelper>();
Expand All @@ -69,7 +69,7 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken)
try
{

if (_plebianConfiguration.PackageType == PackageType.Helper)
if (_plebeianConfiguration.PackageType == PackageType.Helper)
{
IHelper helper;
try
Expand Down Expand Up @@ -118,7 +118,7 @@ private async Task StartHosting(string[] uris)
{
var hostingFailedCompletely = uris.Length > 0;

(object instance, Action<WebApplication> addEndpoints, Type instanceInterface) = _plebianConfiguration.PackageType switch
(object instance, Action<WebApplication> addEndpoints, Type instanceInterface) = _plebeianConfiguration.PackageType switch
{
PackageType.Queue => GetQueue(_services),
PackageType.SCU => GetScu(_services),
Expand All @@ -140,7 +140,7 @@ private async Task StartHosting(string[] uris)

try
{
switch (_plebianConfiguration.PackageType)
switch (_plebeianConfiguration.PackageType)
{
case PackageType.SCU:
if (instanceInterface == typeof(IDESSCD))
Expand Down
2 changes: 1 addition & 1 deletion src/fiskaltrust.Launcher/Services/EncodingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class LauncherEncodingProvider : EncodingProvider
{
public override Encoding? GetEncoding(int codepage) => null;

// This EncodingProvider needs to be registered in the plebian processes
// This EncodingProvider needs to be registered in the plebeian processes
// because ASP.NET Core uses the Encoding.GetEncoding(string) method to parse the charset of the Content-Type header.
// According to the http standard (https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.1) the charset may be wrapped in quotes.
// Until this is fixed in ASP.NET we'll need the workaround below.
Expand Down
Loading

0 comments on commit cfd28da

Please sign in to comment.