Merge branch 'feature/kitchen-dal-adapters' into development
This commit is contained in:
commit
d1ce3bb123
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-dal</RepositoryUrl>
|
||||||
|
<PackageProjectUrl>http://192.168.68.156:3000/AgileWebs/kitchen-dal</PackageProjectUrl>
|
||||||
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
5
Kitchen.DAL.slnx
Normal file
5
Kitchen.DAL.slnx
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<Solution>
|
||||||
|
<Folder Name="/src/">
|
||||||
|
<Project Path="src/Kitchen.DAL/Kitchen.DAL.csproj" />
|
||||||
|
</Folder>
|
||||||
|
</Solution>
|
||||||
8
src/Kitchen.DAL/Contracts/KitchenWorkItemRecord.cs
Normal file
8
src/Kitchen.DAL/Contracts/KitchenWorkItemRecord.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace Kitchen.DAL.Contracts;
|
||||||
|
|
||||||
|
public sealed record KitchenWorkItemRecord(
|
||||||
|
string WorkItemId,
|
||||||
|
string WorkType,
|
||||||
|
int Priority,
|
||||||
|
DateTime RequestedAtUtc,
|
||||||
|
string State);
|
||||||
9
src/Kitchen.DAL/Kitchen.DAL.csproj
Normal file
9
src/Kitchen.DAL/Kitchen.DAL.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>
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using Kitchen.DAL.Contracts;
|
||||||
|
|
||||||
|
namespace Kitchen.DAL.Repositories;
|
||||||
|
|
||||||
|
public interface IKitchenWorkItemRepository
|
||||||
|
{
|
||||||
|
Task<IReadOnlyCollection<KitchenWorkItemRecord>> ListQueuedAsync(CancellationToken cancellationToken);
|
||||||
|
Task UpsertAsync(KitchenWorkItemRecord record, CancellationToken cancellationToken);
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using Kitchen.DAL.Contracts;
|
||||||
|
|
||||||
|
namespace Kitchen.DAL.Repositories;
|
||||||
|
|
||||||
|
public sealed class InMemoryKitchenWorkItemRepository : IKitchenWorkItemRepository
|
||||||
|
{
|
||||||
|
private readonly ConcurrentDictionary<string, KitchenWorkItemRecord> store = new();
|
||||||
|
|
||||||
|
public Task<IReadOnlyCollection<KitchenWorkItemRecord>> ListQueuedAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var result = store.Values.Where(x => x.State == "Queued").OrderByDescending(x => x.Priority).ToArray();
|
||||||
|
return Task.FromResult<IReadOnlyCollection<KitchenWorkItemRecord>>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task UpsertAsync(KitchenWorkItemRecord record, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
store[record.WorkItemId] = record;
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user