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..40ce953 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,10 @@ + + + AgileWebs + AgileWebs + git + http://192.168.68.156:3000/AgileWebs/operations-service + http://192.168.68.156:3000/AgileWebs/operations-service + false + + diff --git a/Operations.Service.slnx b/Operations.Service.slnx new file mode 100644 index 0000000..2387a1d --- /dev/null +++ b/Operations.Service.slnx @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/Operations.Service.Application/Operations.Service.Application.csproj b/src/Operations.Service.Application/Operations.Service.Application.csproj new file mode 100644 index 0000000..051edc0 --- /dev/null +++ b/src/Operations.Service.Application/Operations.Service.Application.csproj @@ -0,0 +1,12 @@ + + + + net10.0 + enable + enable + + + + + + diff --git a/src/Operations.Service.Application/Ports/DefaultOperationsConfigReadPort.cs b/src/Operations.Service.Application/Ports/DefaultOperationsConfigReadPort.cs new file mode 100644 index 0000000..4fd31b5 --- /dev/null +++ b/src/Operations.Service.Application/Ports/DefaultOperationsConfigReadPort.cs @@ -0,0 +1,18 @@ +using Operations.Service.Contracts.Contracts; +using Operations.Service.Contracts.Responses; + +namespace Operations.Service.Application.Ports; + +public sealed class DefaultOperationsConfigReadPort : IOperationsConfigReadPort +{ + public Task ReadConfigAsync(string locationId, CancellationToken cancellationToken) + { + var flags = new[] + { + new FeatureFlagStateContract("kitchen.dispatch.enabled", true), + new FeatureFlagStateContract("orders.priority.escalation", false) + }; + + return Task.FromResult(new GetOperationsConfigResponse("v1", flags)); + } +} diff --git a/src/Operations.Service.Application/Ports/IOperationsConfigReadPort.cs b/src/Operations.Service.Application/Ports/IOperationsConfigReadPort.cs new file mode 100644 index 0000000..f7d9d8b --- /dev/null +++ b/src/Operations.Service.Application/Ports/IOperationsConfigReadPort.cs @@ -0,0 +1,8 @@ +using Operations.Service.Contracts.Responses; + +namespace Operations.Service.Application.Ports; + +public interface IOperationsConfigReadPort +{ + Task ReadConfigAsync(string locationId, CancellationToken cancellationToken); +} diff --git a/src/Operations.Service.Application/UseCases/GetOperationsConfigUseCase.cs b/src/Operations.Service.Application/UseCases/GetOperationsConfigUseCase.cs new file mode 100644 index 0000000..558134c --- /dev/null +++ b/src/Operations.Service.Application/UseCases/GetOperationsConfigUseCase.cs @@ -0,0 +1,13 @@ +using Operations.Service.Application.Ports; +using Operations.Service.Contracts.Requests; +using Operations.Service.Contracts.Responses; + +namespace Operations.Service.Application.UseCases; + +public sealed class GetOperationsConfigUseCase(IOperationsConfigReadPort readPort) : IGetOperationsConfigUseCase +{ + public Task HandleAsync(GetOperationsConfigRequest request, CancellationToken cancellationToken) + { + return readPort.ReadConfigAsync(request.LocationId, cancellationToken); + } +} diff --git a/src/Operations.Service.Application/UseCases/IGetOperationsConfigUseCase.cs b/src/Operations.Service.Application/UseCases/IGetOperationsConfigUseCase.cs new file mode 100644 index 0000000..9ddcad6 --- /dev/null +++ b/src/Operations.Service.Application/UseCases/IGetOperationsConfigUseCase.cs @@ -0,0 +1,9 @@ +using Operations.Service.Contracts.Requests; +using Operations.Service.Contracts.Responses; + +namespace Operations.Service.Application.UseCases; + +public interface IGetOperationsConfigUseCase +{ + Task HandleAsync(GetOperationsConfigRequest request, CancellationToken cancellationToken); +} diff --git a/src/Operations.Service.Contracts/Contracts/FeatureFlagStateContract.cs b/src/Operations.Service.Contracts/Contracts/FeatureFlagStateContract.cs new file mode 100644 index 0000000..e068ab3 --- /dev/null +++ b/src/Operations.Service.Contracts/Contracts/FeatureFlagStateContract.cs @@ -0,0 +1,3 @@ +namespace Operations.Service.Contracts.Contracts; + +public sealed record FeatureFlagStateContract(string Key, bool Enabled); diff --git a/src/Operations.Service.Contracts/Operations.Service.Contracts.csproj b/src/Operations.Service.Contracts/Operations.Service.Contracts.csproj new file mode 100644 index 0000000..b760144 --- /dev/null +++ b/src/Operations.Service.Contracts/Operations.Service.Contracts.csproj @@ -0,0 +1,9 @@ + + + + net10.0 + enable + enable + + + diff --git a/src/Operations.Service.Contracts/Requests/GetOperationsConfigRequest.cs b/src/Operations.Service.Contracts/Requests/GetOperationsConfigRequest.cs new file mode 100644 index 0000000..78b19f9 --- /dev/null +++ b/src/Operations.Service.Contracts/Requests/GetOperationsConfigRequest.cs @@ -0,0 +1,3 @@ +namespace Operations.Service.Contracts.Requests; + +public sealed record GetOperationsConfigRequest(string LocationId); diff --git a/src/Operations.Service.Contracts/Responses/GetOperationsConfigResponse.cs b/src/Operations.Service.Contracts/Responses/GetOperationsConfigResponse.cs new file mode 100644 index 0000000..d913849 --- /dev/null +++ b/src/Operations.Service.Contracts/Responses/GetOperationsConfigResponse.cs @@ -0,0 +1,5 @@ +using Operations.Service.Contracts.Contracts; + +namespace Operations.Service.Contracts.Responses; + +public sealed record GetOperationsConfigResponse(string Version, IReadOnlyCollection FeatureFlags); diff --git a/src/Operations.Service.Grpc/Operations.Service.Grpc.csproj b/src/Operations.Service.Grpc/Operations.Service.Grpc.csproj new file mode 100644 index 0000000..da4663d --- /dev/null +++ b/src/Operations.Service.Grpc/Operations.Service.Grpc.csproj @@ -0,0 +1,13 @@ + + + + net10.0 + enable + enable + + + + + + + diff --git a/src/Operations.Service.Grpc/Program.cs b/src/Operations.Service.Grpc/Program.cs new file mode 100644 index 0000000..b1f66e9 --- /dev/null +++ b/src/Operations.Service.Grpc/Program.cs @@ -0,0 +1,17 @@ +using Operations.Service.Application.Ports; +using Operations.Service.Application.UseCases; +using Operations.Service.Contracts.Requests; + +var builder = WebApplication.CreateBuilder(args); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); + +var app = builder.Build(); + +app.MapGet("/internal/operations/config", async (string locationId, IGetOperationsConfigUseCase useCase, CancellationToken ct) => +{ + var request = new GetOperationsConfigRequest(locationId); + return Results.Ok(await useCase.HandleAsync(request, ct)); +}); + +app.Run(); diff --git a/src/Operations.Service.Grpc/Properties/launchSettings.json b/src/Operations.Service.Grpc/Properties/launchSettings.json new file mode 100644 index 0000000..c55f6a2 --- /dev/null +++ b/src/Operations.Service.Grpc/Properties/launchSettings.json @@ -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" + } + } + } +} diff --git a/src/Operations.Service.Grpc/appsettings.Development.json b/src/Operations.Service.Grpc/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/Operations.Service.Grpc/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/Operations.Service.Grpc/appsettings.json b/src/Operations.Service.Grpc/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/src/Operations.Service.Grpc/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}