Skip to content

Commit

Permalink
Host ipos of helper if available
Browse files Browse the repository at this point in the history
  • Loading branch information
volllly committed Feb 16, 2024
1 parent 93c096a commit 834a753
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ private async Task StartHosting(string[] uris)
_ => throw new NotImplementedException()
};

var helperIPOS = GetHelper(_services);

foreach (var uri in uris)
{
Expand All @@ -136,12 +137,6 @@ private async Task StartHosting(string[] uris)
continue;
}

Action<WebApplication>? addEndpointsInner = hostingType switch
{
HostingType.REST => addEndpoints,
_ => null
};

try
{
switch (_plebeianConfiguration.PackageType)
Expand All @@ -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();
Expand All @@ -180,6 +178,18 @@ private async Task StartHosting(string[] uris)
}
}

private static (IPOS instance, Action<WebApplication> addEndpoints)? GetHelper(IServiceProvider services)
{
var queue = services.GetService<IPOS>();

if (queue is not null)
{
return (queue, (WebApplication app) => app.AddQueueEndpoints(queue));
}

return null;
}

private static (object, Action<WebApplication>, Type) GetQueue(IServiceProvider services)
{
var queue = services.GetRequiredService<IPOS>();
Expand Down

0 comments on commit 834a753

Please sign in to comment.