feat(domain): BIG Domain Service skeleton with the Registration aggregate (closes #6) #61
@@ -11,6 +11,7 @@
|
|||||||
<Project Path="services/domain/Big.Domain/Big.Domain.csproj" />
|
<Project Path="services/domain/Big.Domain/Big.Domain.csproj" />
|
||||||
<Project Path="services/domain/Big.Application/Big.Application.csproj" />
|
<Project Path="services/domain/Big.Application/Big.Application.csproj" />
|
||||||
<Project Path="services/domain/Big.Infrastructure/Big.Infrastructure.csproj" />
|
<Project Path="services/domain/Big.Infrastructure/Big.Infrastructure.csproj" />
|
||||||
|
<Project Path="services/domain/Big.Api/Big.Api.csproj" />
|
||||||
<Project Path="services/domain/Big.Tests/Big.Tests.csproj" />
|
<Project Path="services/domain/Big.Tests/Big.Tests.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder Name="/services/bff/">
|
<Folder Name="/services/bff/">
|
||||||
|
|||||||
14
services/domain/Big.Api/Big.Api.csproj
Normal file
14
services/domain/Big.Api/Big.Api.csproj
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Big.Application\Big.Application.csproj" />
|
||||||
|
<ProjectReference Include="..\Big.Infrastructure\Big.Infrastructure.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
64
services/domain/Big.Api/Program.cs
Normal file
64
services/domain/Big.Api/Program.cs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
using Big.Application;
|
||||||
|
using Big.Domain;
|
||||||
|
using Big.Infrastructure;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Options bound from configuration (compose sets Flowable__* and Acl__* env vars).
|
||||||
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
||||||
|
.GetSection("Flowable").Get<FlowableOptions>()
|
||||||
|
?? throw new InvalidOperationException("Missing configuration section 'Flowable'"));
|
||||||
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
||||||
|
.GetSection("Acl").Get<AclOptions>()
|
||||||
|
?? throw new InvalidOperationException("Missing configuration section 'Acl'"));
|
||||||
|
|
||||||
|
// The in-memory registration store is shared between the submit endpoint and the worker (ADR-0009).
|
||||||
|
builder.Services.AddSingleton<IRegistrationStore, InMemoryRegistrationStore>();
|
||||||
|
|
||||||
|
// The Workflow Client is one type behind two ports (start side + worker side); both resolve to the
|
||||||
|
// same HttpClient-backed implementation — the only code that talks to Flowable (§8.2).
|
||||||
|
builder.Services.AddHttpClient<FlowableWorkflowClient>();
|
||||||
|
builder.Services.AddTransient<IWorkflowClient>(sp => sp.GetRequiredService<FlowableWorkflowClient>());
|
||||||
|
builder.Services.AddTransient<IExternalWorkerClient>(sp => sp.GetRequiredService<FlowableWorkflowClient>());
|
||||||
|
builder.Services.AddHttpClient<IAclClient, AclHttpClient>();
|
||||||
|
|
||||||
|
builder.Services.AddScoped<SubmitRegistration>();
|
||||||
|
builder.Services.AddScoped<OpenZaakWorker>();
|
||||||
|
builder.Services.AddScoped<OpenZaakJobProcessor>();
|
||||||
|
|
||||||
|
// The hosted external-task job worker polls Flowable and drives OpenZaakAanmaken to completion.
|
||||||
|
builder.Services.AddHostedService<OpenZaakJobPump>();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
app.MapGet("/health", () => "Healthy");
|
||||||
|
|
||||||
|
// Submit a registration. The aggregate is created (INGEDIEND) and the registratie process started;
|
||||||
|
// the zaak is opened later, off the request path, by the worker — so this returns 202 Accepted with
|
||||||
|
// a location to read the registration's progress (ADR-0009, eventual consistency).
|
||||||
|
app.MapPost("/registrations", async (SubmitRegistrationRequest body, SubmitRegistration submit, CancellationToken ct) =>
|
||||||
|
{
|
||||||
|
var id = await submit.HandleAsync(new SubmitRegistrationCommand(body.Bsn), ct);
|
||||||
|
return Results.Accepted($"/registrations/{id}", new RegistrationResponse(id.ToString(), RegistrationStatus.Ingediend.ToString(), null));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Read a registration. Its zaak URL appears once the worker has opened the zaak (eventually).
|
||||||
|
app.MapGet("/registrations/{id}", async (string id, IRegistrationStore store, CancellationToken ct) =>
|
||||||
|
{
|
||||||
|
if (!Guid.TryParse(id, out var guid))
|
||||||
|
return Results.NotFound();
|
||||||
|
|
||||||
|
var registration = await store.GetAsync(new RegistrationId(guid), ct);
|
||||||
|
return registration is null
|
||||||
|
? Results.NotFound()
|
||||||
|
: Results.Ok(new RegistrationResponse(
|
||||||
|
registration.Id.ToString(), registration.Status.ToString(), registration.ZaakUrl?.ToString()));
|
||||||
|
});
|
||||||
|
|
||||||
|
await app.RunAsync();
|
||||||
|
|
||||||
|
public sealed record SubmitRegistrationRequest(string Bsn);
|
||||||
|
|
||||||
|
public sealed record RegistrationResponse(string RegistrationId, string Status, string? ZaakUrl);
|
||||||
|
|
||||||
|
public partial class Program;
|
||||||
9
services/domain/Big.Api/appsettings.json
Normal file
9
services/domain/Big.Api/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
@@ -2,5 +2,6 @@
|
|||||||
<Project Path="Big.Domain/Big.Domain.csproj" />
|
<Project Path="Big.Domain/Big.Domain.csproj" />
|
||||||
<Project Path="Big.Application/Big.Application.csproj" />
|
<Project Path="Big.Application/Big.Application.csproj" />
|
||||||
<Project Path="Big.Infrastructure/Big.Infrastructure.csproj" />
|
<Project Path="Big.Infrastructure/Big.Infrastructure.csproj" />
|
||||||
|
<Project Path="Big.Api/Big.Api.csproj" />
|
||||||
<Project Path="Big.Tests/Big.Tests.csproj" />
|
<Project Path="Big.Tests/Big.Tests.csproj" />
|
||||||
</Solution>
|
</Solution>
|
||||||
|
|||||||
Reference in New Issue
Block a user