Коммит
132f09a377
|
@ -17,6 +17,8 @@ file sealed class RunPublisherHandler(ProcessNamedValuesToPut processNamedValues
|
|||
ProcessDeletedNamedValues processDeletedNamedValues,
|
||||
ProcessBackendsToPut processBackendsToPut,
|
||||
ProcessDeletedBackends processDeletedBackends,
|
||||
ProcessPolicyFragmentsToPut processPolicyFragmentsToPut,
|
||||
ProcessDeletedPolicyFragments processDeletedPolicyFragments,
|
||||
GetPublisherFiles getPublisherFiles,
|
||||
PublishFile publishFile,
|
||||
ILoggerFactory loggerFactory)
|
||||
|
@ -27,11 +29,13 @@ file sealed class RunPublisherHandler(ProcessNamedValuesToPut processNamedValues
|
|||
{
|
||||
await processNamedValuesToPut(cancellationToken);
|
||||
await processBackendsToPut(cancellationToken);
|
||||
await processPolicyFragmentsToPut(cancellationToken);
|
||||
|
||||
await ProcessPublisherFiles(cancellationToken);
|
||||
|
||||
await processDeletedNamedValues(cancellationToken);
|
||||
await processDeletedPolicyFragments(cancellationToken);
|
||||
await processDeletedBackends(cancellationToken);
|
||||
await processDeletedNamedValues(cancellationToken);
|
||||
|
||||
logger.LogInformation("Publisher completed.");
|
||||
}
|
||||
|
@ -80,7 +84,6 @@ file sealed class PublishFileHandler(FindTagAction findTagAction,
|
|||
| findVersionSetAction(file)
|
||||
| findLoggerAction(file)
|
||||
| findDiagnosticAction(file)
|
||||
| findPolicyFragmentAction(file)
|
||||
| findServicePolicyAction(file)
|
||||
| findProductAction(file)
|
||||
| findProductPolicyAction(file)
|
||||
|
@ -104,6 +107,8 @@ internal static class AppServices
|
|||
NamedValueServices.ConfigureProcessDeletedNamedValues(services);
|
||||
BackendServices.ConfigureProcessBackendsToPut(services);
|
||||
BackendServices.ConfigureProcessDeletedBackends(services);
|
||||
PolicyFragmentServices.ConfigureProcessPolicyFragmentsToPut(services);
|
||||
PolicyFragmentServices.ConfigureProcessDeletedPolicyFragments(services);
|
||||
ConfigurePublishFile(services);
|
||||
|
||||
services.TryAddSingleton<RunPublisherHandler>();
|
||||
|
|
|
@ -6,7 +6,6 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
|
@ -9,11 +9,15 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace publisher;
|
||||
|
||||
internal delegate ValueTask ProcessPolicyFragmentsToPut(CancellationToken cancellationToken);
|
||||
internal delegate ValueTask ProcessDeletedPolicyFragments(CancellationToken cancellationToken);
|
||||
|
||||
internal delegate Option<PublisherAction> FindPolicyFragmentAction(FileInfo file);
|
||||
|
||||
file delegate Option<PolicyFragmentName> TryParsePolicyFragmentName(FileInfo file);
|
||||
|
@ -34,6 +38,30 @@ file delegate ValueTask DeletePolicyFragmentFromApim(PolicyFragmentName name, Ca
|
|||
|
||||
internal delegate ValueTask OnDeletingPolicyFragment(PolicyFragmentName name, CancellationToken cancellationToken);
|
||||
|
||||
file sealed class ProcessPolicyFragmentsToPutHandler(GetPublisherFiles getPublisherFiles,
|
||||
TryParsePolicyFragmentName tryParsePolicyFragmentName,
|
||||
IsPolicyFragmentNameInSourceControl isNameInSourceControl,
|
||||
PutPolicyFragment putPolicyFragment)
|
||||
{
|
||||
public async ValueTask Handle(CancellationToken cancellationToken) =>
|
||||
await getPublisherFiles()
|
||||
.Choose(tryParsePolicyFragmentName.Invoke)
|
||||
.Where(isNameInSourceControl.Invoke)
|
||||
.IterParallel(putPolicyFragment.Invoke, cancellationToken);
|
||||
}
|
||||
|
||||
file sealed class ProcessDeletedPolicyFragmentsHandler(GetPublisherFiles getPublisherFiles,
|
||||
TryParsePolicyFragmentName tryParsePolicyFragmentName,
|
||||
IsPolicyFragmentNameInSourceControl isNameInSourceControl,
|
||||
DeletePolicyFragment deletePolicyFragment)
|
||||
{
|
||||
public async ValueTask Handle(CancellationToken cancellationToken) =>
|
||||
await getPublisherFiles()
|
||||
.Choose(tryParsePolicyFragmentName.Invoke)
|
||||
.Where(name => isNameInSourceControl.Invoke(name) is false)
|
||||
.IterParallel(deletePolicyFragment.Invoke, cancellationToken);
|
||||
}
|
||||
|
||||
file sealed class FindPolicyFragmentActionHandler(TryParsePolicyFragmentName tryParseName, ProcessPolicyFragment processPolicyFragment)
|
||||
{
|
||||
public Option<PublisherAction> Handle(FileInfo file) =>
|
||||
|
@ -239,6 +267,26 @@ file sealed class DeletePolicyFragmentFromApimHandler(ILoggerFactory loggerFacto
|
|||
|
||||
internal static class PolicyFragmentServices
|
||||
{
|
||||
public static void ConfigureProcessPolicyFragmentsToPut(IServiceCollection services)
|
||||
{
|
||||
ConfigureTryParsePolicyFragmentName(services);
|
||||
ConfigureIsPolicyFragmentNameInSourceControl(services);
|
||||
ConfigurePutPolicyFragment(services);
|
||||
|
||||
services.TryAddSingleton<ProcessPolicyFragmentsToPutHandler>();
|
||||
services.TryAddSingleton<ProcessPolicyFragmentsToPut>(provider => provider.GetRequiredService<ProcessPolicyFragmentsToPutHandler>().Handle);
|
||||
}
|
||||
|
||||
public static void ConfigureProcessDeletedPolicyFragments(IServiceCollection services)
|
||||
{
|
||||
ConfigureTryParsePolicyFragmentName(services);
|
||||
ConfigureIsPolicyFragmentNameInSourceControl(services);
|
||||
ConfigureDeletePolicyFragment(services);
|
||||
|
||||
services.TryAddSingleton<ProcessDeletedPolicyFragmentsHandler>();
|
||||
services.TryAddSingleton<ProcessDeletedPolicyFragments>(provider => provider.GetRequiredService<ProcessDeletedPolicyFragmentsHandler>().Handle);
|
||||
}
|
||||
|
||||
public static void ConfigureFindPolicyFragmentAction(IServiceCollection services)
|
||||
{
|
||||
ConfigureTryParsePolicyFragmentName(services);
|
||||
|
|
Загрузка…
Ссылка в новой задаче