Compare commits
No commits in common. "ff28fe83c37b9400ecb0a4736de5e0d6921f01dd" and "20cbe1bb3b5f33011120cfff324711a8d9e6769f" have entirely different histories.
ff28fe83c3
...
20cbe1bb3b
@ -1,9 +0,0 @@
|
|||||||
**/bin/
|
|
||||||
**/obj/
|
|
||||||
.vs/
|
|
||||||
TestResults/
|
|
||||||
.git/
|
|
||||||
.repo-tasks/
|
|
||||||
.repo-context/
|
|
||||||
.tasks/
|
|
||||||
.agile/
|
|
||||||
60
.gitignore
vendored
60
.gitignore
vendored
@ -1,23 +1,53 @@
|
|||||||
# Repository orchestration folders (local only)
|
# AgileWebs local orchestration
|
||||||
.repo-tasks/
|
|
||||||
.repo-context/
|
|
||||||
.tasks/
|
.tasks/
|
||||||
.agile/
|
.agile/
|
||||||
|
|
||||||
# .NET build outputs
|
# Build artifacts
|
||||||
**/bin/
|
**/[Bb]in/
|
||||||
**/obj/
|
**/[Oo]bj/
|
||||||
|
/**/out/
|
||||||
|
/**/artifacts/
|
||||||
|
|
||||||
|
# IDE and editor files
|
||||||
.vs/
|
.vs/
|
||||||
TestResults/
|
|
||||||
**/TestResults/
|
|
||||||
*.user
|
|
||||||
*.suo
|
|
||||||
*.rsuser
|
|
||||||
|
|
||||||
# IDE
|
|
||||||
.idea/
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
*.rsuser
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
# Package artifacts
|
# NuGet
|
||||||
*.nupkg
|
*.nupkg
|
||||||
*.snupkg
|
*.snupkg
|
||||||
artifacts/
|
**/packages/*
|
||||||
|
!**/packages/build/
|
||||||
|
|
||||||
|
# Test output
|
||||||
|
**/TestResults/
|
||||||
|
*.trx
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
logs/
|
||||||
|
|
||||||
|
# Local environment files
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
.docker/
|
||||||
|
**/.docker/
|
||||||
|
*.pid
|
||||||
|
docker-compose.override.yml
|
||||||
|
docker-compose.*.override.yml
|
||||||
|
|
||||||
|
# OS files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|||||||
20
Dockerfile
20
Dockerfile
@ -1,20 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1.7
|
|
||||||
ARG SDK_IMAGE=mcr.microsoft.com/dotnet/sdk:10.0
|
|
||||||
ARG RUNTIME_IMAGE=mcr.microsoft.com/dotnet/aspnet:10.0
|
|
||||||
|
|
||||||
FROM ${SDK_IMAGE} AS build
|
|
||||||
ARG NUGET_FEED_URL=https://gitea.dream-views.com/api/packages/AgileWebs/nuget/index.json
|
|
||||||
ARG NUGET_FEED_USERNAME=
|
|
||||||
ARG NUGET_FEED_TOKEN=
|
|
||||||
WORKDIR /src
|
|
||||||
COPY . .
|
|
||||||
RUN if [ -n "$NUGET_FEED_USERNAME" ] && [ -n "$NUGET_FEED_TOKEN" ]; then dotnet nuget add source "$NUGET_FEED_URL" --name gitea-org --username "$NUGET_FEED_USERNAME" --password "$NUGET_FEED_TOKEN" --store-password-in-clear-text --allow-insecure-connections --configfile /root/.nuget/NuGet/NuGet.Config; fi
|
|
||||||
RUN dotnet restore "src/Furniture.DAL.Host/Furniture.DAL.Host.csproj" --configfile /root/.nuget/NuGet/NuGet.Config
|
|
||||||
RUN dotnet publish "src/Furniture.DAL.Host/Furniture.DAL.Host.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore
|
|
||||||
|
|
||||||
FROM ${RUNTIME_IMAGE} AS runtime
|
|
||||||
WORKDIR /app
|
|
||||||
ENV ASPNETCORE_URLS=http://+:8080 ASPNETCORE_ENVIRONMENT=Production
|
|
||||||
EXPOSE 8080
|
|
||||||
COPY --from=build /app/publish .
|
|
||||||
ENTRYPOINT ["dotnet", "Furniture.DAL.Host.dll"]
|
|
||||||
@ -1,6 +1,5 @@
|
|||||||
<Solution>
|
<Solution>
|
||||||
<Folder Name="/src/">
|
<Folder Name="/src/">
|
||||||
<Project Path="src/Furniture.DAL.Host/Furniture.DAL.Host.csproj" />
|
|
||||||
<Project Path="src/Furniture.DAL/Furniture.DAL.csproj" />
|
<Project Path="src/Furniture.DAL/Furniture.DAL.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder Name="/tests/">
|
<Folder Name="/tests/">
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
# Furniture DAL Domain Alignment
|
|
||||||
|
|
||||||
## Goal
|
|
||||||
Align DAL with furniture-domain abstractions while keeping DAL technical.
|
|
||||||
|
|
||||||
## DAL Responsibilities
|
|
||||||
- Persistence and retrieval
|
|
||||||
- Technical data translation
|
|
||||||
- Provider/repository boundaries
|
|
||||||
- Contract adaptation for service and domain boundaries without owning decisions
|
|
||||||
|
|
||||||
## Prohibited
|
|
||||||
- Domain decision ownership
|
|
||||||
- Service orchestration concerns
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
# Furniture DAL Package Consumption Baseline
|
|
||||||
|
|
||||||
## Objective
|
|
||||||
|
|
||||||
Remove cross-repo source coupling from `Furniture.DAL` and consume shared contracts through NuGet packages.
|
|
||||||
|
|
||||||
## Applied Baseline
|
|
||||||
|
|
||||||
`Furniture.DAL.csproj` now consumes:
|
|
||||||
|
|
||||||
- `BuildingBlock.Catalog.Contracts` `0.2.0`
|
|
||||||
- `Core.Blueprint.Common` `0.2.0`
|
|
||||||
|
|
||||||
## Feed Configuration
|
|
||||||
|
|
||||||
Repository-level `nuget.config` includes:
|
|
||||||
|
|
||||||
- `gitea-org`: `https://gitea.dream-views.com/api/packages/AgileWebs/nuget/index.json`
|
|
||||||
- `nuget.org`
|
|
||||||
|
|
||||||
Because feed is currently HTTP, `allowInsecureConnections="true"` is required for the Gitea source.
|
|
||||||
|
|
||||||
## Boundary Notes
|
|
||||||
|
|
||||||
- No cross-repo `ProjectReference` remains in `src/Furniture.DAL/Furniture.DAL.csproj`.
|
|
||||||
- DAL remains technical/provider-oriented and independent from BFF/Service source coupling.
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
# DAL Port Alignment Map
|
|
||||||
|
|
||||||
## Alignment Areas
|
|
||||||
- DAL read/write ports map to domain contracts.
|
|
||||||
- Technical DTO translation remains in DAL adapters.
|
|
||||||
- Domain invariants are not reimplemented in DAL.
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
# Technical Mapping Rules
|
|
||||||
|
|
||||||
## Rules
|
|
||||||
- Mapping logic must remain technical and deterministic.
|
|
||||||
- No business branching in DAL mapping layer.
|
|
||||||
- Correlation and metadata pass-through remains unchanged.
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
# Feature Epics
|
|
||||||
|
|
||||||
## Repository
|
|
||||||
furniture-dal
|
|
||||||
|
|
||||||
## Core Epics
|
|
||||||
- Epic 1: Expand domain-aligned capabilities for restaurant operations.
|
|
||||||
- Epic 2: Stabilize service contracts for containerized runtime integration.
|
|
||||||
- Epic 3: Improve observability and operational readiness for demo compose environments.
|
|
||||||
|
|
||||||
## Domain-Specific Candidate Features
|
|
||||||
- Order lifecycle consistency and state transitions.
|
|
||||||
- Kitchen queue and dispatch optimization hooks.
|
|
||||||
- Operations control-plane policies (flags, service windows, overrides).
|
|
||||||
- POS closeout and settlement summary alignment.
|
|
||||||
|
|
||||||
## Documentation Contract
|
|
||||||
Any code change in this repository must include docs updates in the same branch.
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
# Containerization Runbook
|
|
||||||
|
|
||||||
## Image Build
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker build --build-arg NUGET_FEED_USERNAME=<gitea-login> --build-arg NUGET_FEED_TOKEN=<gitea-token> -t agilewebs/furniture-dal:dev .
|
|
||||||
```
|
|
||||||
|
|
||||||
## Local Run
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run --rm -p 8080:8080 --name furniture-dal agilewebs/furniture-dal:dev
|
|
||||||
```
|
|
||||||
|
|
||||||
## Health Probe
|
|
||||||
|
|
||||||
- Path: `/health`
|
|
||||||
- Fallback path: `/healthz`
|
|
||||||
- Port: `8080`
|
|
||||||
|
|
||||||
## Runtime Notes
|
|
||||||
|
|
||||||
- Exposes internal DAL lookup endpoints for furniture availability and catalog projections.
|
|
||||||
- In-memory demo provider accepts canonical demo IDs (`FURN-001..003`) and aliases (`demo-context`, `FUR-*`, `PRD-*`, `PROD-FURN-*`).
|
|
||||||
|
|
||||||
## Health Endpoint Consistency
|
|
||||||
|
|
||||||
- Canonical probe: `/health`
|
|
||||||
- Compatibility probe: `/healthz`
|
|
||||||
- Container port: `8080`
|
|
||||||
|
|
||||||
## Demo Integration
|
|
||||||
|
|
||||||
- Participates in: **furniture** demo compose stack.
|
|
||||||
- Integration artifact path: `greenfield/demo/furniture/docker-compose.yml`
|
|
||||||
## Known Limitations
|
|
||||||
|
|
||||||
- Current runtime adapters are still predominantly in-memory for deterministic local/demo behavior.
|
|
||||||
- Demo PostgreSQL seeds validate integration contracts and smoke determinism, but do not yet imply full persistence implementation parity.
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<packageSources>
|
|
||||||
<clear />
|
|
||||||
<add key="gitea-org" value="https://gitea.dream-views.com/api/packages/AgileWebs/nuget/index.json" allowInsecureConnections="true" />
|
|
||||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
|
||||||
</packageSources>
|
|
||||||
</configuration>
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Furniture.DAL\Furniture.DAL.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
using Furniture.DAL.Contracts;
|
|
||||||
using Furniture.DAL.DependencyInjection;
|
|
||||||
using Furniture.DAL.Repositories;
|
|
||||||
using Microsoft.Extensions.Primitives;
|
|
||||||
|
|
||||||
const string CorrelationHeaderName = "x-correlation-id";
|
|
||||||
const string ContractVersion = "v1";
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
|
||||||
builder.Services.AddHealthChecks();
|
|
||||||
builder.Services.AddFurnitureDalRuntime();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
|
||||||
|
|
||||||
app.MapGet("/internal/furniture-dal/availability/{furnitureId}", async (
|
|
||||||
string furnitureId,
|
|
||||||
HttpContext context,
|
|
||||||
IFurnitureRepository repository,
|
|
||||||
CancellationToken ct) =>
|
|
||||||
{
|
|
||||||
var envelope = new FurnitureDalContractEnvelope(ContractVersion, ResolveCorrelationId(context));
|
|
||||||
var request = new FurnitureAvailabilityLookupRequest(envelope, furnitureId);
|
|
||||||
var record = await repository.ReadAvailabilityAsync(request, ct);
|
|
||||||
return record is null ? Results.NotFound() : Results.Ok(record);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.MapGet("/internal/furniture-dal/catalog/{productId}", async (
|
|
||||||
string productId,
|
|
||||||
HttpContext context,
|
|
||||||
ICatalogRepository repository,
|
|
||||||
CancellationToken ct) =>
|
|
||||||
{
|
|
||||||
var envelope = new FurnitureDalContractEnvelope(ContractVersion, ResolveCorrelationId(context));
|
|
||||||
var request = new CatalogProductLookupRequest(envelope, productId);
|
|
||||||
var record = await repository.ReadProductAsync(request, ct);
|
|
||||||
return record is null ? Results.NotFound() : Results.Ok(record);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.MapHealthChecks("/health");
|
|
||||||
app.MapHealthChecks("/healthz");
|
|
||||||
|
|
||||||
app.Run();
|
|
||||||
|
|
||||||
static string ResolveCorrelationId(HttpContext context)
|
|
||||||
{
|
|
||||||
if (context.Request.Headers.TryGetValue(CorrelationHeaderName, out var headerValue) &&
|
|
||||||
!StringValues.IsNullOrEmpty(headerValue))
|
|
||||||
{
|
|
||||||
return headerValue.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return context.TraceIdentifier;
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
|
||||||
"profiles": {
|
|
||||||
"http": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
|
||||||
"applicationUrl": "http://localhost:0",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"https": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
|
||||||
"applicationUrl": "https://localhost:0;http://localhost:0",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
using BuildingBlock.Catalog.Contracts.Conventions;
|
|
||||||
using BuildingBlock.Catalog.Contracts.Products;
|
|
||||||
using BuildingBlock.Catalog.Contracts.Responses;
|
|
||||||
using Furniture.DAL.Contracts;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.Adapters;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Default adapter implementation for catalog building block and furniture DAL contracts.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class CatalogProjectionContractAdapter : ICatalogProjectionContractAdapter
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public CatalogProductLookupRequest ToDalRequest(ProductContract contract)
|
|
||||||
{
|
|
||||||
var envelope = new FurnitureDalContractEnvelope(
|
|
||||||
contract.Envelope.ContractVersion,
|
|
||||||
contract.Envelope.CorrelationId);
|
|
||||||
|
|
||||||
return new CatalogProductLookupRequest(envelope, contract.ProductId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public ProductContractResponse ToCatalogResponse(CatalogProductProjectionRecord record)
|
|
||||||
{
|
|
||||||
var envelope = new CatalogContractEnvelope(
|
|
||||||
record.Envelope.ContractVersion,
|
|
||||||
record.Envelope.CorrelationId);
|
|
||||||
|
|
||||||
return new ProductContractResponse(
|
|
||||||
envelope,
|
|
||||||
record.ProductId,
|
|
||||||
record.DisplayName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
using Core.Blueprint.Common.Runtime;
|
|
||||||
using Furniture.DAL.Contracts;
|
|
||||||
using Furniture.DAL.Grpc;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.Adapters;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Default adapter implementation for furniture DAL gRPC contract translation.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class FurnitureDalGrpcContractAdapter(IBlueprintSystemClock clock) : IFurnitureDalGrpcContractAdapter
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public FurnitureAvailabilityDalGrpcContract ToGrpcAvailabilityRequest(FurnitureAvailabilityLookupRequest request)
|
|
||||||
{
|
|
||||||
return new FurnitureAvailabilityDalGrpcContract(request.FurnitureId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public FurnitureAvailabilityLookupRequest FromGrpcAvailabilityRequest(FurnitureAvailabilityDalGrpcContract contract)
|
|
||||||
{
|
|
||||||
return new FurnitureAvailabilityLookupRequest(CreateEnvelope(), contract.FurnitureId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public CatalogProductDalGrpcContract ToGrpcCatalogRequest(CatalogProductLookupRequest request)
|
|
||||||
{
|
|
||||||
return new CatalogProductDalGrpcContract(request.ProductId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public CatalogProductLookupRequest FromGrpcCatalogRequest(CatalogProductDalGrpcContract contract)
|
|
||||||
{
|
|
||||||
return new CatalogProductLookupRequest(CreateEnvelope(), contract.ProductId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private FurnitureDalContractEnvelope CreateEnvelope()
|
|
||||||
{
|
|
||||||
return new FurnitureDalContractEnvelope("1.0.0", $"corr-{clock.UtcNow:yyyyMMddHHmmssfff}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
using Furniture.DAL.Contracts;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.Caching;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Default cache invalidation policy for furniture DAL runtime.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class FurnitureCacheInvalidationPolicy : ICacheInvalidationPolicy
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public string BuildAvailabilityKey(FurnitureAvailabilityLookupRequest request)
|
|
||||||
{
|
|
||||||
return $"furniture:availability:{request.FurnitureId}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public IReadOnlyList<string> ResolveInvalidationKeys(FurnitureCacheInvalidationRequest request)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
[
|
|
||||||
$"furniture:availability:{request.FurnitureId}"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
namespace Furniture.DAL.Contracts;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Response contract for furniture DAL dependency health evaluation.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Envelope">Contract envelope metadata.</param>
|
|
||||||
/// <param name="IsHealthy">Indicates whether all runtime dependencies are healthy.</param>
|
|
||||||
/// <param name="DependencyNames">Dependency names included in health evaluation.</param>
|
|
||||||
public sealed record DalDependencyHealthStatus(
|
|
||||||
FurnitureDalContractEnvelope Envelope,
|
|
||||||
bool IsHealthy,
|
|
||||||
IReadOnlyList<string> DependencyNames);
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
using Core.Blueprint.Common.DependencyInjection;
|
|
||||||
using Furniture.DAL.Adapters;
|
|
||||||
using Furniture.DAL.Caching;
|
|
||||||
using Furniture.DAL.Health;
|
|
||||||
using Furniture.DAL.Providers;
|
|
||||||
using Furniture.DAL.Providers.InMemory;
|
|
||||||
using Furniture.DAL.Repositories;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.DependencyInjection;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Registers furniture DAL runtime provider, repository, and adapter implementations.
|
|
||||||
/// </summary>
|
|
||||||
public static class FurnitureDalServiceCollectionExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Adds furniture DAL runtime implementations aligned with blueprint runtime core.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="services">Service collection.</param>
|
|
||||||
/// <returns>Service collection for fluent chaining.</returns>
|
|
||||||
public static IServiceCollection AddFurnitureDalRuntime(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddBlueprintRuntimeCore();
|
|
||||||
|
|
||||||
services.TryAddSingleton<IFurnitureDataProvider, InMemoryFurnitureDataProvider>();
|
|
||||||
services.TryAddSingleton<ICatalogDataProvider, InMemoryCatalogDataProvider>();
|
|
||||||
|
|
||||||
services.TryAddSingleton<ICacheInvalidationPolicy, FurnitureCacheInvalidationPolicy>();
|
|
||||||
services.TryAddSingleton<IFurnitureRepository, FurnitureRepository>();
|
|
||||||
services.TryAddSingleton<ICatalogRepository, CatalogRepository>();
|
|
||||||
|
|
||||||
services.TryAddSingleton<ICatalogProjectionContractAdapter, CatalogProjectionContractAdapter>();
|
|
||||||
services.TryAddSingleton<IFurnitureDalGrpcContractAdapter, FurnitureDalGrpcContractAdapter>();
|
|
||||||
services.TryAddSingleton<IDalDependencyHealthCheck, DalDependencyHealthCheck>();
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -5,8 +5,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
|
<ProjectReference Include="..\..\..\blueprint-platform\src\Core.Blueprint.Common\Core.Blueprint.Common.csproj" />
|
||||||
<PackageReference Include="Core.Blueprint.Common" Version="0.2.0" />
|
<ProjectReference Include="..\..\..\building-block-catalog\src\BuildingBlock.Catalog.Contracts\BuildingBlock.Catalog.Contracts.csproj" />
|
||||||
<PackageReference Include="BuildingBlock.Catalog.Contracts" Version="0.2.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
using Core.Blueprint.Common.Runtime;
|
|
||||||
using Furniture.DAL.Contracts;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.Health;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Default DAL dependency health check implementation.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class DalDependencyHealthCheck(IBlueprintSystemClock clock) : IDalDependencyHealthCheck
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public Task<DalDependencyHealthStatus> CheckAsync(CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
var envelope = new FurnitureDalContractEnvelope("1.0.0", $"corr-{clock.UtcNow:yyyyMMddHHmmssfff}");
|
|
||||||
IReadOnlyList<string> dependencyNames =
|
|
||||||
[
|
|
||||||
"IFurnitureDataProvider",
|
|
||||||
"ICatalogDataProvider",
|
|
||||||
"IFurnitureRepository",
|
|
||||||
"ICatalogRepository",
|
|
||||||
"ICacheInvalidationPolicy"
|
|
||||||
];
|
|
||||||
|
|
||||||
var status = new DalDependencyHealthStatus(envelope, true, dependencyNames);
|
|
||||||
return Task.FromResult(status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
using Furniture.DAL.Contracts;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.Health;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Defines furniture DAL dependency health check boundary.
|
|
||||||
/// </summary>
|
|
||||||
public interface IDalDependencyHealthCheck
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Evaluates runtime dependency health for DAL providers and repositories.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cancellationToken">Cancellation token.</param>
|
|
||||||
/// <returns>Dependency health status contract.</returns>
|
|
||||||
Task<DalDependencyHealthStatus> CheckAsync(CancellationToken cancellationToken = default);
|
|
||||||
}
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
using Furniture.DAL.Contracts;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.Providers.InMemory;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// In-memory provider implementation for catalog persistence reads.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class InMemoryCatalogDataProvider : ICatalogDataProvider
|
|
||||||
{
|
|
||||||
private static readonly IReadOnlyDictionary<string, string> DisplayNameByProductId =
|
|
||||||
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
["FURN-001"] = "Nordic Chair",
|
|
||||||
["FURN-002"] = "Oak Dining Table",
|
|
||||||
["FURN-003"] = "Bar Stool"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static readonly IReadOnlyDictionary<string, string> CanonicalProductIdAliases =
|
|
||||||
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
["demo-context"] = "FURN-001",
|
|
||||||
["FUR-001"] = "FURN-001",
|
|
||||||
["FUR-002"] = "FURN-002",
|
|
||||||
["FUR-003"] = "FURN-003",
|
|
||||||
["PRD-001"] = "FURN-001",
|
|
||||||
["PRD-002"] = "FURN-002",
|
|
||||||
["PRD-003"] = "FURN-003",
|
|
||||||
["PROD-FURN-001"] = "FURN-001",
|
|
||||||
["PROD-FURN-002"] = "FURN-002",
|
|
||||||
["PROD-FURN-003"] = "FURN-003"
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public Task<CatalogProductProjectionRecord?> ReadProductAsync(
|
|
||||||
CatalogProductLookupRequest request,
|
|
||||||
CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
var canonicalProductId = ResolveCanonicalProductId(request.ProductId);
|
|
||||||
if (!DisplayNameByProductId.TryGetValue(canonicalProductId, out var displayName))
|
|
||||||
{
|
|
||||||
return Task.FromResult<CatalogProductProjectionRecord?>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
var record = new CatalogProductProjectionRecord(
|
|
||||||
request.Envelope,
|
|
||||||
request.ProductId,
|
|
||||||
displayName);
|
|
||||||
|
|
||||||
return Task.FromResult<CatalogProductProjectionRecord?>(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string ResolveCanonicalProductId(string productId)
|
|
||||||
{
|
|
||||||
if (CanonicalProductIdAliases.TryGetValue(productId, out var mappedId))
|
|
||||||
{
|
|
||||||
return mappedId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return productId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
using Furniture.DAL.Contracts;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.Providers.InMemory;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// In-memory provider implementation for furniture persistence reads.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class InMemoryFurnitureDataProvider : IFurnitureDataProvider
|
|
||||||
{
|
|
||||||
private static readonly IReadOnlyDictionary<string, int> AvailabilityByFurnitureId =
|
|
||||||
new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
["FURN-001"] = 22,
|
|
||||||
["FURN-002"] = 11,
|
|
||||||
["FURN-003"] = 18
|
|
||||||
};
|
|
||||||
|
|
||||||
private static readonly IReadOnlyDictionary<string, string> CanonicalFurnitureIdAliases =
|
|
||||||
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
["demo-context"] = "FURN-001",
|
|
||||||
["FUR-001"] = "FURN-001",
|
|
||||||
["FUR-002"] = "FURN-002",
|
|
||||||
["FUR-003"] = "FURN-003",
|
|
||||||
["PRD-001"] = "FURN-001",
|
|
||||||
["PRD-002"] = "FURN-002",
|
|
||||||
["PRD-003"] = "FURN-003",
|
|
||||||
["PROD-FURN-001"] = "FURN-001",
|
|
||||||
["PROD-FURN-002"] = "FURN-002",
|
|
||||||
["PROD-FURN-003"] = "FURN-003"
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public Task<FurnitureAvailabilityRecord?> ReadAvailabilityAsync(
|
|
||||||
FurnitureAvailabilityLookupRequest request,
|
|
||||||
CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
var canonicalId = ResolveCanonicalFurnitureId(request.FurnitureId);
|
|
||||||
if (!AvailabilityByFurnitureId.TryGetValue(canonicalId, out var quantityAvailable))
|
|
||||||
{
|
|
||||||
return Task.FromResult<FurnitureAvailabilityRecord?>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
var record = new FurnitureAvailabilityRecord(
|
|
||||||
request.Envelope,
|
|
||||||
request.FurnitureId,
|
|
||||||
quantityAvailable);
|
|
||||||
|
|
||||||
return Task.FromResult<FurnitureAvailabilityRecord?>(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string ResolveCanonicalFurnitureId(string furnitureId)
|
|
||||||
{
|
|
||||||
if (CanonicalFurnitureIdAliases.TryGetValue(furnitureId, out var mappedId))
|
|
||||||
{
|
|
||||||
return mappedId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return furnitureId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
using Furniture.DAL.Contracts;
|
|
||||||
using Furniture.DAL.Providers;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.Repositories;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Default catalog repository implementation composed from DAL providers.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class CatalogRepository(ICatalogDataProvider catalogDataProvider) : ICatalogRepository
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public Task<CatalogProductProjectionRecord?> ReadProductAsync(
|
|
||||||
CatalogProductLookupRequest request,
|
|
||||||
CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
return catalogDataProvider.ReadProductAsync(request, cancellationToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
using System.Collections.Concurrent;
|
|
||||||
using Furniture.DAL.Caching;
|
|
||||||
using Furniture.DAL.Contracts;
|
|
||||||
using Furniture.DAL.Providers;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.Repositories;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Default furniture repository implementation composed from DAL providers.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class FurnitureRepository(
|
|
||||||
IFurnitureDataProvider furnitureDataProvider,
|
|
||||||
ICacheInvalidationPolicy cacheInvalidationPolicy) : IFurnitureRepository
|
|
||||||
{
|
|
||||||
private readonly ConcurrentDictionary<string, FurnitureAvailabilityRecord> availabilityCache = new(
|
|
||||||
StringComparer.OrdinalIgnoreCase);
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public async Task<FurnitureAvailabilityRecord?> ReadAvailabilityAsync(
|
|
||||||
FurnitureAvailabilityLookupRequest request,
|
|
||||||
CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
var cacheKey = cacheInvalidationPolicy.BuildAvailabilityKey(request);
|
|
||||||
if (availabilityCache.TryGetValue(cacheKey, out var cachedRecord))
|
|
||||||
{
|
|
||||||
return cachedRecord with { Envelope = request.Envelope };
|
|
||||||
}
|
|
||||||
|
|
||||||
var providerRecord = await furnitureDataProvider.ReadAvailabilityAsync(request, cancellationToken);
|
|
||||||
if (providerRecord is null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
availabilityCache[cacheKey] = providerRecord;
|
|
||||||
return providerRecord;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,7 +7,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="coverlet.collector" Version="6.0.4" />
|
<PackageReference Include="coverlet.collector" Version="6.0.4" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||||
<PackageReference Include="xunit" Version="2.9.3" />
|
<PackageReference Include="xunit" Version="2.9.3" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
|
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
|
||||||
|
|||||||
@ -1,76 +0,0 @@
|
|||||||
using Furniture.DAL.Adapters;
|
|
||||||
using Furniture.DAL.Contracts;
|
|
||||||
using Furniture.DAL.DependencyInjection;
|
|
||||||
using Furniture.DAL.Health;
|
|
||||||
using Furniture.DAL.Repositories;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace Furniture.DAL.UnitTests;
|
|
||||||
|
|
||||||
public class RuntimeWiringTests
|
|
||||||
{
|
|
||||||
[Fact]
|
|
||||||
public async Task AddFurnitureDalRuntime_WhenResolved_WiresRepositoriesAndProviders()
|
|
||||||
{
|
|
||||||
var services = new ServiceCollection();
|
|
||||||
services.AddFurnitureDalRuntime();
|
|
||||||
|
|
||||||
using var provider = services.BuildServiceProvider();
|
|
||||||
var furnitureRepository = provider.GetRequiredService<IFurnitureRepository>();
|
|
||||||
var catalogRepository = provider.GetRequiredService<ICatalogRepository>();
|
|
||||||
var envelope = new FurnitureDalContractEnvelope("1.0.0", "corr-123");
|
|
||||||
|
|
||||||
var availability = await furnitureRepository.ReadAvailabilityAsync(
|
|
||||||
new FurnitureAvailabilityLookupRequest(envelope, "FURN-001"));
|
|
||||||
var product = await catalogRepository.ReadProductAsync(
|
|
||||||
new CatalogProductLookupRequest(envelope, "PROD-FURN-001"));
|
|
||||||
|
|
||||||
Assert.NotNull(availability);
|
|
||||||
Assert.Equal("FURN-001", availability.FurnitureId);
|
|
||||||
Assert.Equal(22, availability.QuantityAvailable);
|
|
||||||
|
|
||||||
Assert.NotNull(product);
|
|
||||||
Assert.Equal("PROD-FURN-001", product.ProductId);
|
|
||||||
Assert.Equal("Nordic Chair", product.DisplayName);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddFurnitureDalRuntime_WhenResolved_WiresGrpcAndCatalogAdapters()
|
|
||||||
{
|
|
||||||
var services = new ServiceCollection();
|
|
||||||
services.AddFurnitureDalRuntime();
|
|
||||||
|
|
||||||
using var provider = services.BuildServiceProvider();
|
|
||||||
var grpcAdapter = provider.GetRequiredService<IFurnitureDalGrpcContractAdapter>();
|
|
||||||
var projectionAdapter = provider.GetRequiredService<ICatalogProjectionContractAdapter>();
|
|
||||||
|
|
||||||
var availabilityRequest = grpcAdapter.FromGrpcAvailabilityRequest(
|
|
||||||
new Furniture.DAL.Grpc.FurnitureAvailabilityDalGrpcContract("FURN-002"));
|
|
||||||
var catalogRequest = projectionAdapter.ToDalRequest(
|
|
||||||
new BuildingBlock.Catalog.Contracts.Products.ProductContract(
|
|
||||||
new BuildingBlock.Catalog.Contracts.Conventions.CatalogContractEnvelope("1.0.0", "corr-456"),
|
|
||||||
"PROD-FURN-002",
|
|
||||||
"Oak Dining Table"));
|
|
||||||
|
|
||||||
Assert.Equal("FURN-002", availabilityRequest.FurnitureId);
|
|
||||||
Assert.NotEmpty(availabilityRequest.Envelope.CorrelationId);
|
|
||||||
Assert.Equal("PROD-FURN-002", catalogRequest.ProductId);
|
|
||||||
Assert.Equal("corr-456", catalogRequest.Envelope.CorrelationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task AddFurnitureDalRuntime_WhenResolved_WiresDependencyHealthCheck()
|
|
||||||
{
|
|
||||||
var services = new ServiceCollection();
|
|
||||||
services.AddFurnitureDalRuntime();
|
|
||||||
|
|
||||||
using var provider = services.BuildServiceProvider();
|
|
||||||
var healthCheck = provider.GetRequiredService<IDalDependencyHealthCheck>();
|
|
||||||
|
|
||||||
var status = await healthCheck.CheckAsync();
|
|
||||||
|
|
||||||
Assert.True(status.IsHealthy);
|
|
||||||
Assert.Contains("IFurnitureDataProvider", status.DependencyNames);
|
|
||||||
Assert.Contains("ICatalogRepository", status.DependencyNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user