Merge branch 'feature/kitchen-service-orchestration' into development
This commit is contained in:
commit
cb0f238e4b
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
.tasks/
|
||||
.agile/
|
||||
**/bin/
|
||||
**/obj/
|
||||
|
||||
10
Directory.Build.props
Normal file
10
Directory.Build.props
Normal file
@ -0,0 +1,10 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Authors>AgileWebs</Authors>
|
||||
<Company>AgileWebs</Company>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>http://192.168.68.156:3000/AgileWebs/kitchen-service</RepositoryUrl>
|
||||
<PackageProjectUrl>http://192.168.68.156:3000/AgileWebs/kitchen-service</PackageProjectUrl>
|
||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
7
Kitchen.Service.slnx
Normal file
7
Kitchen.Service.slnx
Normal file
@ -0,0 +1,7 @@
|
||||
<Solution>
|
||||
<Folder Name="/src/">
|
||||
<Project Path="src/Kitchen.Service.Application/Kitchen.Service.Application.csproj" />
|
||||
<Project Path="src/Kitchen.Service.Contracts/Kitchen.Service.Contracts.csproj" />
|
||||
<Project Path="src/Kitchen.Service.Grpc/Kitchen.Service.Grpc.csproj" />
|
||||
</Folder>
|
||||
</Solution>
|
||||
@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Kitchen.Service.Contracts\Kitchen.Service.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,18 @@
|
||||
using Kitchen.Service.Contracts.Contracts;
|
||||
using Kitchen.Service.Contracts.Responses;
|
||||
|
||||
namespace Kitchen.Service.Application.Ports;
|
||||
|
||||
public sealed class DefaultKitchenQueueReadPort : IKitchenQueueReadPort
|
||||
{
|
||||
public Task<GetKitchenQueueResponse> ReadQueueAsync(string queueName, int limit, CancellationToken cancellationToken)
|
||||
{
|
||||
var items = new[]
|
||||
{
|
||||
new KitchenQueueItemContract("WK-1001", "PrepareOrder", 3, "Queued"),
|
||||
new KitchenQueueItemContract("WK-1002", "AssembleTray", 2, "Queued")
|
||||
}.Take(Math.Max(limit, 0)).ToArray();
|
||||
|
||||
return Task.FromResult(new GetKitchenQueueResponse(items));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
using Kitchen.Service.Contracts.Responses;
|
||||
|
||||
namespace Kitchen.Service.Application.Ports;
|
||||
|
||||
public interface IKitchenQueueReadPort
|
||||
{
|
||||
Task<GetKitchenQueueResponse> ReadQueueAsync(string queueName, int limit, CancellationToken cancellationToken);
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
using Kitchen.Service.Application.Ports;
|
||||
using Kitchen.Service.Contracts.Requests;
|
||||
using Kitchen.Service.Contracts.Responses;
|
||||
|
||||
namespace Kitchen.Service.Application.UseCases;
|
||||
|
||||
public sealed class GetKitchenQueueUseCase(IKitchenQueueReadPort readPort) : IGetKitchenQueueUseCase
|
||||
{
|
||||
public Task<GetKitchenQueueResponse> HandleAsync(GetKitchenQueueRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return readPort.ReadQueueAsync(request.QueueName, request.Limit, cancellationToken);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
using Kitchen.Service.Contracts.Requests;
|
||||
using Kitchen.Service.Contracts.Responses;
|
||||
|
||||
namespace Kitchen.Service.Application.UseCases;
|
||||
|
||||
public interface IGetKitchenQueueUseCase
|
||||
{
|
||||
Task<GetKitchenQueueResponse> HandleAsync(GetKitchenQueueRequest request, CancellationToken cancellationToken);
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
namespace Kitchen.Service.Contracts.Contracts;
|
||||
|
||||
public sealed record KitchenQueueItemContract(string WorkItemId, string WorkType, int Priority, string State);
|
||||
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,3 @@
|
||||
namespace Kitchen.Service.Contracts.Requests;
|
||||
|
||||
public sealed record GetKitchenQueueRequest(string QueueName, int Limit);
|
||||
@ -0,0 +1,5 @@
|
||||
using Kitchen.Service.Contracts.Contracts;
|
||||
|
||||
namespace Kitchen.Service.Contracts.Responses;
|
||||
|
||||
public sealed record GetKitchenQueueResponse(IReadOnlyCollection<KitchenQueueItemContract> Items);
|
||||
13
src/Kitchen.Service.Grpc/Kitchen.Service.Grpc.csproj
Normal file
13
src/Kitchen.Service.Grpc/Kitchen.Service.Grpc.csproj
Normal file
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Kitchen.Service.Application\Kitchen.Service.Application.csproj" />
|
||||
<ProjectReference Include="..\Kitchen.Service.Contracts\Kitchen.Service.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
17
src/Kitchen.Service.Grpc/Program.cs
Normal file
17
src/Kitchen.Service.Grpc/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Kitchen.Service.Application.Ports;
|
||||
using Kitchen.Service.Application.UseCases;
|
||||
using Kitchen.Service.Contracts.Requests;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddSingleton<IKitchenQueueReadPort, DefaultKitchenQueueReadPort>();
|
||||
builder.Services.AddSingleton<IGetKitchenQueueUseCase, GetKitchenQueueUseCase>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapGet("/internal/kitchen/queue", async (string queueName, int? limit, IGetKitchenQueueUseCase useCase, CancellationToken ct) =>
|
||||
{
|
||||
var request = new GetKitchenQueueRequest(queueName, limit ?? 20);
|
||||
return Results.Ok(await useCase.HandleAsync(request, ct));
|
||||
});
|
||||
|
||||
app.Run();
|
||||
23
src/Kitchen.Service.Grpc/Properties/launchSettings.json
Normal file
23
src/Kitchen.Service.Grpc/Properties/launchSettings.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"$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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
src/Kitchen.Service.Grpc/appsettings.Development.json
Normal file
8
src/Kitchen.Service.Grpc/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
src/Kitchen.Service.Grpc/appsettings.json
Normal file
9
src/Kitchen.Service.Grpc/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user