Skip to content

Commit 8a92f73

Browse files
committed
Added architecture to support the import orchestrator and steps pipeline. Wired up initial Sam import WIP.
1 parent 0fdeddf commit 8a92f73

20 files changed

Lines changed: 268 additions & 2 deletions

src/KeeperData.Application/KeeperData.Application.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<PackageReference Include="MediatR" Version="13.0.0" />
1313
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0" />
1414
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
15+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
1516
</ItemGroup>
1617

1718
<ItemGroup>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace KeeperData.Application.Orchestration.Cts;
2+
3+
public class CtsCphHoldingImportedOrchestrator
4+
{
5+
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace KeeperData.Application.Orchestration.Cts;
2+
3+
public class CtsHoldingImportContext
4+
{
5+
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace KeeperData.Application.Orchestration.Cts.Steps;
2+
3+
public class CtsPersistenceStep
4+
{
5+
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace KeeperData.Application.Orchestration.Cts.Steps;
2+
3+
public class CtsRawAggregationStep
4+
{
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace KeeperData.Application.Orchestration.Cts.Steps;
2+
3+
public class CtsSilverMappingStep
4+
{
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace KeeperData.Application.Orchestration;
2+
3+
public interface IImportStep<TContext>
4+
{
5+
Task ExecuteAsync(TContext context, CancellationToken cancellationToken);
6+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace KeeperData.Application.Orchestration;
2+
3+
public abstract class ImportOrchestrator<TContext>(IEnumerable<IImportStep<TContext>> steps)
4+
{
5+
private readonly IEnumerable<IImportStep<TContext>> _steps = steps;
6+
7+
public async Task ExecuteAsync(TContext context, CancellationToken cancellationToken)
8+
{
9+
foreach (var step in _steps)
10+
{
11+
await step.ExecuteAsync(context, cancellationToken);
12+
}
13+
}
14+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Microsoft.Extensions.Logging;
2+
using System.Diagnostics;
3+
4+
namespace KeeperData.Application.Orchestration;
5+
6+
public abstract class ImportStepBase<TContext>(ILogger logger) : IImportStep<TContext>
7+
{
8+
private readonly ILogger _logger = logger;
9+
10+
public async Task ExecuteAsync(TContext context, CancellationToken cancellationToken)
11+
{
12+
var stepName = GetType().Name;
13+
var stopwatch = Stopwatch.StartNew();
14+
15+
try
16+
{
17+
_logger.LogInformation("Starting step: {StepName}", stepName);
18+
await ExecuteCoreAsync(context, cancellationToken);
19+
_logger.LogInformation("Completed step: {StepName} in {ElapsedMs}ms", stepName, stopwatch.ElapsedMilliseconds);
20+
}
21+
catch (Exception ex)
22+
{
23+
_logger.LogError(ex, "Error in step: {StepName}", stepName);
24+
throw;
25+
}
26+
}
27+
28+
protected abstract Task ExecuteCoreAsync(TContext context, CancellationToken cancellationToken);
29+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using KeeperData.Core.ApiClients.DataBridgeApi.Contracts;
2+
using KeeperData.Core.Documents.Source;
3+
4+
namespace KeeperData.Application.Orchestration.Sam.Mappings;
5+
6+
public static class SamHolderMapper
7+
{
8+
public static SamPartyDocument ToSilver(SamCphHolder raw)
9+
{
10+
return new SamPartyDocument
11+
{
12+
PartyId = raw.PARTY_ID
13+
};
14+
}
15+
}

0 commit comments

Comments
 (0)