diff --git a/.gitignore b/.gitignore index 31c7257..b299ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .tasks/ .agile/ +**/bin/ +**/obj/ diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..560e8ec --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,10 @@ + + + AgileWebs + AgileWebs + git + http://192.168.68.156:3000/AgileWebs/kitchen-domain + http://192.168.68.156:3000/AgileWebs/kitchen-domain + false + + diff --git a/Kitchen.Domain.slnx b/Kitchen.Domain.slnx new file mode 100644 index 0000000..28cf337 --- /dev/null +++ b/Kitchen.Domain.slnx @@ -0,0 +1,5 @@ + + + + + diff --git a/src/Kitchen.Domain/Conventions/KitchenDomainPackageContract.cs b/src/Kitchen.Domain/Conventions/KitchenDomainPackageContract.cs new file mode 100644 index 0000000..7f08372 --- /dev/null +++ b/src/Kitchen.Domain/Conventions/KitchenDomainPackageContract.cs @@ -0,0 +1,3 @@ +namespace Kitchen.Domain.Conventions; + +public interface IKitchenDomainPackageContract; diff --git a/src/Kitchen.Domain/Decisions/DispatchDecision.cs b/src/Kitchen.Domain/Decisions/DispatchDecision.cs new file mode 100644 index 0000000..2bd1387 --- /dev/null +++ b/src/Kitchen.Domain/Decisions/DispatchDecision.cs @@ -0,0 +1,8 @@ +using Kitchen.Domain.Models; + +namespace Kitchen.Domain.Decisions; + +public sealed record DispatchDecision( + IReadOnlyCollection Selected, + IReadOnlyCollection Deferred, + string Reason); diff --git a/src/Kitchen.Domain/Decisions/IKitchenWorkflowDecisionService.cs b/src/Kitchen.Domain/Decisions/IKitchenWorkflowDecisionService.cs new file mode 100644 index 0000000..917e5e5 --- /dev/null +++ b/src/Kitchen.Domain/Decisions/IKitchenWorkflowDecisionService.cs @@ -0,0 +1,9 @@ +using Kitchen.Domain.Models; + +namespace Kitchen.Domain.Decisions; + +public interface IKitchenWorkflowDecisionService +{ + bool CanTransition(KitchenWorkflowState currentState, KitchenWorkflowState targetState); + DispatchDecision SelectForExecution(IReadOnlyCollection candidates, int availableCapacity); +} diff --git a/src/Kitchen.Domain/Decisions/KitchenWorkflowDecisionService.cs b/src/Kitchen.Domain/Decisions/KitchenWorkflowDecisionService.cs new file mode 100644 index 0000000..457c4cb --- /dev/null +++ b/src/Kitchen.Domain/Decisions/KitchenWorkflowDecisionService.cs @@ -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 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."); + } +} diff --git a/src/Kitchen.Domain/Kitchen.Domain.csproj b/src/Kitchen.Domain/Kitchen.Domain.csproj new file mode 100644 index 0000000..b760144 --- /dev/null +++ b/src/Kitchen.Domain/Kitchen.Domain.csproj @@ -0,0 +1,9 @@ + + + + net10.0 + enable + enable + + + diff --git a/src/Kitchen.Domain/Models/KitchenWorkflowState.cs b/src/Kitchen.Domain/Models/KitchenWorkflowState.cs new file mode 100644 index 0000000..398645b --- /dev/null +++ b/src/Kitchen.Domain/Models/KitchenWorkflowState.cs @@ -0,0 +1,10 @@ +namespace Kitchen.Domain.Models; + +public enum KitchenWorkflowState +{ + Queued = 0, + Preparing = 1, + ReadyForPickup = 2, + Delivered = 3, + Failed = 4 +} diff --git a/src/Kitchen.Domain/Models/WorkItemId.cs b/src/Kitchen.Domain/Models/WorkItemId.cs new file mode 100644 index 0000000..dd7cb4e --- /dev/null +++ b/src/Kitchen.Domain/Models/WorkItemId.cs @@ -0,0 +1,6 @@ +namespace Kitchen.Domain.Models; + +public readonly record struct WorkItemId(string Value) +{ + public override string ToString() => Value; +}