From 834a753f2a0923e25314a3cad263fcfb7ea3bd24 Mon Sep 17 00:00:00 2001 From: Paul Volavsek Date: Fri, 16 Feb 2024 09:52:15 +0100 Subject: [PATCH] Host ipos of helper if available --- .../ProcessHost/ProcessHostPlebeian.cs | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs index 23191ac2..15742ead 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs @@ -126,6 +126,7 @@ private async Task StartHosting(string[] uris) _ => throw new NotImplementedException() }; + var helperIPOS = GetHelper(_services); foreach (var uri in uris) { @@ -136,12 +137,6 @@ private async Task StartHosting(string[] uris) continue; } - Action? addEndpointsInner = hostingType switch - { - HostingType.REST => addEndpoints, - _ => null - }; - try { switch (_plebeianConfiguration.PackageType) @@ -160,7 +155,10 @@ private async Task StartHosting(string[] uris) await _hosting.HostService(url, hostingType.Value, (IPOS)instance, addEndpoints); break; case PackageType.Helper: - await _hosting.HostService(url, hostingType.Value, (IHelper)instance, addEndpoints); + if (helperIPOS is not null) + { + await _hosting.HostService(url, hostingType.Value, helperIPOS.Value.instance, helperIPOS.Value.addEndpoints); + } break; default: throw new NotImplementedException(); @@ -180,6 +178,18 @@ private async Task StartHosting(string[] uris) } } + private static (IPOS instance, Action addEndpoints)? GetHelper(IServiceProvider services) + { + var queue = services.GetService(); + + if (queue is not null) + { + return (queue, (WebApplication app) => app.AddQueueEndpoints(queue)); + } + + return null; + } + private static (object, Action, Type) GetQueue(IServiceProvider services) { var queue = services.GetRequiredService();