Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host IPOS for Helpers if its available #168

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Loading