Merge branch 'feature/kitchen-domain-invariants' into development
This commit is contained in:
commit
2a1d056823
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
.tasks/
|
.tasks/
|
||||||
.agile/
|
.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-domain</RepositoryUrl>
|
||||||
|
<PackageProjectUrl>http://192.168.68.156:3000/AgileWebs/kitchen-domain</PackageProjectUrl>
|
||||||
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
5
Kitchen.Domain.slnx
Normal file
5
Kitchen.Domain.slnx
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<Solution>
|
||||||
|
<Folder Name="/src/">
|
||||||
|
<Project Path="src/Kitchen.Domain/Kitchen.Domain.csproj" />
|
||||||
|
</Folder>
|
||||||
|
</Solution>
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
namespace Kitchen.Domain.Conventions;
|
||||||
|
|
||||||
|
public interface IKitchenDomainPackageContract;
|
||||||
8
src/Kitchen.Domain/Decisions/DispatchDecision.cs
Normal file
8
src/Kitchen.Domain/Decisions/DispatchDecision.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
using Kitchen.Domain.Models;
|
||||||
|
|
||||||
|
namespace Kitchen.Domain.Decisions;
|
||||||
|
|
||||||
|
public sealed record DispatchDecision(
|
||||||
|
IReadOnlyCollection<WorkItemId> Selected,
|
||||||
|
IReadOnlyCollection<WorkItemId> Deferred,
|
||||||
|
string Reason);
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using Kitchen.Domain.Models;
|
||||||
|
|
||||||
|
namespace Kitchen.Domain.Decisions;
|
||||||
|
|
||||||
|
public interface IKitchenWorkflowDecisionService
|
||||||
|
{
|
||||||
|
bool CanTransition(KitchenWorkflowState currentState, KitchenWorkflowState targetState);
|
||||||
|
DispatchDecision SelectForExecution(IReadOnlyCollection<WorkItemId> candidates, int availableCapacity);
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
using Kitchen.Domain.Models;
|
||||||
|
|
||||||
|
namespace Kitchen.Domain.Decisions;
|
||||||
|
|
||||||
|
public sealed class KitchenWorkflowDecisionService : IKitchenWorkflowDecisionService
|
||||||
|
{
|
||||||
|
public bool CanTransition(KitchenWorkflowState currentState, KitchenWorkflowState targetState)
|
||||||
|
{
|
||||||
|
return currentState switch
|
||||||
|
{
|
||||||
|
KitchenWorkflowState.Queued => targetState is KitchenWorkflowState.Preparing or KitchenWorkflowState.Failed,
|
||||||
|
KitchenWorkflowState.Preparing => targetState is KitchenWorkflowState.ReadyForPickup or KitchenWorkflowState.Failed,
|
||||||
|
KitchenWorkflowState.ReadyForPickup => targetState is KitchenWorkflowState.Delivered,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public DispatchDecision SelectForExecution(IReadOnlyCollection<WorkItemId> candidates, int availableCapacity)
|
||||||
|
{
|
||||||
|
var selected = candidates.Take(Math.Max(availableCapacity, 0)).ToArray();
|
||||||
|
var deferred = candidates.Skip(selected.Length).ToArray();
|
||||||
|
return new DispatchDecision(selected, deferred, "Selected by available capacity.");
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/Kitchen.Domain/Kitchen.Domain.csproj
Normal file
9
src/Kitchen.Domain/Kitchen.Domain.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
10
src/Kitchen.Domain/Models/KitchenWorkflowState.cs
Normal file
10
src/Kitchen.Domain/Models/KitchenWorkflowState.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace Kitchen.Domain.Models;
|
||||||
|
|
||||||
|
public enum KitchenWorkflowState
|
||||||
|
{
|
||||||
|
Queued = 0,
|
||||||
|
Preparing = 1,
|
||||||
|
ReadyForPickup = 2,
|
||||||
|
Delivered = 3,
|
||||||
|
Failed = 4
|
||||||
|
}
|
||||||
6
src/Kitchen.Domain/Models/WorkItemId.cs
Normal file
6
src/Kitchen.Domain/Models/WorkItemId.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace Kitchen.Domain.Models;
|
||||||
|
|
||||||
|
public readonly record struct WorkItemId(string Value)
|
||||||
|
{
|
||||||
|
public override string ToString() => Value;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user