From ba4fa313e803ca3af3e401326ddae1987edf16a9 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Mon, 26 Aug 2024 15:03:01 +0200 Subject: [PATCH 01/47] Add messagebus to docker compose file --- src/docker-compose.yml | 53 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/docker-compose.yml b/src/docker-compose.yml index 9821f9d..83a46d7 100644 --- a/src/docker-compose.yml +++ b/src/docker-compose.yml @@ -7,9 +7,13 @@ services: build: context: . dockerfile: Clients.Admin.Bff/Dockerfile + environment: + - OpenTelemetry__LoggerEndpoint=http://seq:5341 ports: - "8080:8080" - "8081:8081" + networks: + - seq admin-web: image: ghcr.io/madworldnl/mantarayplan-admin-web:latest container_name: admin-web @@ -28,11 +32,20 @@ services: context: . dockerfile: Server.Controllers.Api.Grpc/Dockerfile depends_on: + messagebus: + condition: service_healthy postgres: condition: service_healthy + environment: + - Database__Host=postgres + - OpenTelemetry__LoggerEndpoint=http://seq:5341 ports: - "8084:8080" - "8085:8081" + networks: + - messagebus + - postgres + - seq api-message-bus: image: ghcr.io/madworldnl/mantarayplan-api-message-bus:latest container_name: api-message-bus @@ -41,11 +54,20 @@ services: context: . dockerfile: Server.Controllers.Api.MessageBus/Dockerfile depends_on: + messagebus: + condition: service_healthy postgres: condition: service_healthy + environment: + - Database__Host=postgres + - OpenTelemetry__LoggerEndpoint=http://seq:5341 ports: - "8086:8080" - "8087:8081" + networks: + - messagebus + - postgres + - seq viewer-bff: image: ghcr.io/madworldnl/mantarayplan-viewer-bff:latest container_name: viewer-bff @@ -53,9 +75,13 @@ services: build: context: . dockerfile: Clients.Viewer.Bff/Dockerfile + environment: + - OpenTelemetry__LoggerEndpoint=http://seq:5341 ports: - "8088:8080" - "8089:8081" + networks: + - seq viewer-web: image: ghcr.io/madworldnl/mantarayplan-viewer-web:latest container_name: viewer-web @@ -76,6 +102,8 @@ services: - SEQ_FIRSTRUN_ADMINPASSWORDHASH=QFCKH3NTSBQ5zmsH9DpXTB2YefIavEGJKa4SshKb11AXX8b4o4KPjuo9bd6WBfqDkpxKqzNjaOrCsE49ph369Wx84mIrksnJx5OtRcxAOjff ports: - "5341:80" + networks: + - seq volumes: - seq-data:/data postgres: @@ -111,9 +139,32 @@ services: - postgres volumes: - pgadmin-data:/var/lib/pgadmin + messagebus: + image: rabbitmq:3-management + container_name: messagebus + hostname: my-rabbit + environment: + - "RABBITMQ_DEFAULT_USER=development" + - "RABBITMQ_DEFAULT_PASS=Secret1234" + ports: + - "5672:5672" + - "15672:15672" + networks: + - messagebus + volumes: + - "rabbitmq-data:/var/lib/rabbitmq" + healthcheck: + test: rabbitmq-diagnostics -q ping + interval: 30s + timeout: 10s + retries: 5 + start_period: 10s volumes: postgres-data: pgadmin-data: + rabbitmq-data: seq-data: networks: - postgres: \ No newline at end of file + messagebus: + postgres: + seq: \ No newline at end of file From 4a4ed80510550953f5027d4e46ca5f885d7696d0 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Tue, 27 Aug 2024 20:12:53 +0200 Subject: [PATCH 02/47] Add basic message bus to the projects --- src/Directory.Packages.props | 2 ++ .../Api.Grpc.csproj | 2 ++ src/Server.Controllers.Api.Grpc/Program.cs | 20 +++++++++++++++++++ .../appsettings.Development.json | 6 ++++++ .../appsettings.json | 6 ++++++ .../Api.MessageBus.csproj | 2 ++ .../Program.cs | 20 +++++++++++++++++++ .../appsettings.Development.json | 6 ++++++ .../appsettings.json | 6 ++++++ .../MessageBuses/MessageBusSettings.cs | 11 ++++++++++ 10 files changed, 81 insertions(+) create mode 100644 src/Server.Logic.Domain/MessageBuses/MessageBusSettings.cs diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 2c6f02e..58a1b74 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -1,6 +1,8 @@ + + diff --git a/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj b/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj index 046bf93..e1385aa 100644 --- a/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj +++ b/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj @@ -13,6 +13,8 @@ + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Server.Controllers.Api.Grpc/Program.cs b/src/Server.Controllers.Api.Grpc/Program.cs index 5ba4c3e..548a21d 100644 --- a/src/Server.Controllers.Api.Grpc/Program.cs +++ b/src/Server.Controllers.Api.Grpc/Program.cs @@ -1,6 +1,8 @@ using MadWorldNL.MantaRayPlan.Extensions; +using MadWorldNL.MantaRayPlan.MessageBuses; using MadWorldNL.MantaRayPlan.OpenTelemetry; using MadWorldNL.MantaRayPlan.Services; +using MassTransit; var builder = WebApplication.CreateBuilder(args); @@ -16,6 +18,24 @@ builder.Services.AddHealthChecks(); +builder.Services.AddMassTransit(x => +{ + x.SetKebabCaseEndpointNameFormatter(); + + x.UsingRabbitMq((context,cfg) => + { + var messageBusSettings = builder.Configuration.GetSection(MessageBusSettings.Key) + .Get()!; + + cfg.Host(messageBusSettings.Host, messageBusSettings.Port, "/", h => { + h.Username(messageBusSettings.Username); + h.Password(messageBusSettings.Password); + }); + + cfg.ConfigureEndpoints(context); + }); +}); + var app = builder.Build(); app.MapGrpcService(); diff --git a/src/Server.Controllers.Api.Grpc/appsettings.Development.json b/src/Server.Controllers.Api.Grpc/appsettings.Development.json index 26cce75..2659f1b 100644 --- a/src/Server.Controllers.Api.Grpc/appsettings.Development.json +++ b/src/Server.Controllers.Api.Grpc/appsettings.Development.json @@ -16,5 +16,11 @@ "Application": "Api.Grpc", "LoggerEndpoint": "http://localhost:5341", "LoggerApiKey": "" + }, + "MessageBus": { + "Host": "localhost", + "Port": 5672, + "Username": "development", + "Password": "Secret1234" } } diff --git a/src/Server.Controllers.Api.Grpc/appsettings.json b/src/Server.Controllers.Api.Grpc/appsettings.json index f8f53df..a2e398b 100644 --- a/src/Server.Controllers.Api.Grpc/appsettings.json +++ b/src/Server.Controllers.Api.Grpc/appsettings.json @@ -22,5 +22,11 @@ "EndpointDefaults": { "Protocols": "Http2" } + }, + "MessageBus": { + "Host": "localhost", + "Port": 5672, + "Username": "development", + "Password": "Secret1234" } } diff --git a/src/Server.Controllers.Api.MessageBus/Api.MessageBus.csproj b/src/Server.Controllers.Api.MessageBus/Api.MessageBus.csproj index 767f695..efe9221 100644 --- a/src/Server.Controllers.Api.MessageBus/Api.MessageBus.csproj +++ b/src/Server.Controllers.Api.MessageBus/Api.MessageBus.csproj @@ -22,6 +22,8 @@ + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Server.Controllers.Api.MessageBus/Program.cs b/src/Server.Controllers.Api.MessageBus/Program.cs index 52c3e5f..ebe4460 100644 --- a/src/Server.Controllers.Api.MessageBus/Program.cs +++ b/src/Server.Controllers.Api.MessageBus/Program.cs @@ -2,7 +2,9 @@ using MadWorldNL.MantaRayPlan; using MadWorldNL.MantaRayPlan.Extensions; +using MadWorldNL.MantaRayPlan.MessageBuses; using MadWorldNL.MantaRayPlan.OpenTelemetry; +using MassTransit; var builder = WebApplication.CreateBuilder(); @@ -15,6 +17,24 @@ builder.Services.AddHealthChecks(); +builder.Services.AddMassTransit(x => +{ + x.SetKebabCaseEndpointNameFormatter(); + + x.UsingRabbitMq((context,cfg) => + { + var messageBusSettings = builder.Configuration.GetSection(MessageBusSettings.Key) + .Get()!; + + cfg.Host(messageBusSettings.Host, messageBusSettings.Port, "/", h => { + h.Username(messageBusSettings.Username); + h.Password(messageBusSettings.Password); + }); + + cfg.ConfigureEndpoints(context); + }); +}); + var app = builder.Build(); app.MapHealthChecks("/healthz"); diff --git a/src/Server.Controllers.Api.MessageBus/appsettings.Development.json b/src/Server.Controllers.Api.MessageBus/appsettings.Development.json index 25629a4..dc7be52 100644 --- a/src/Server.Controllers.Api.MessageBus/appsettings.Development.json +++ b/src/Server.Controllers.Api.MessageBus/appsettings.Development.json @@ -16,5 +16,11 @@ "Application": "Api.MessageBus", "LoggerEndpoint": "http://localhost:5341", "LoggerApiKey": "" + }, + "MessageBus": { + "Host": "localhost", + "Port": 5672, + "Username": "development", + "Password": "Secret1234" } } diff --git a/src/Server.Controllers.Api.MessageBus/appsettings.json b/src/Server.Controllers.Api.MessageBus/appsettings.json index aa2163c..534a16d 100644 --- a/src/Server.Controllers.Api.MessageBus/appsettings.json +++ b/src/Server.Controllers.Api.MessageBus/appsettings.json @@ -22,5 +22,11 @@ "EndpointDefaults": { "Protocols": "Http1" } + }, + "MessageBus": { + "Host": "localhost", + "Port": 5672, + "Username": "development", + "Password": "Secret1234" } } diff --git a/src/Server.Logic.Domain/MessageBuses/MessageBusSettings.cs b/src/Server.Logic.Domain/MessageBuses/MessageBusSettings.cs new file mode 100644 index 0000000..53171d2 --- /dev/null +++ b/src/Server.Logic.Domain/MessageBuses/MessageBusSettings.cs @@ -0,0 +1,11 @@ +namespace MadWorldNL.MantaRayPlan.MessageBuses; + +public class MessageBusSettings +{ + public const string Key = "MessageBus"; + + public string Host { get; init; } = string.Empty; + public ushort Port { get; init; } + public string Username { get; init; } = string.Empty; + public string Password { get; init; } = string.Empty; +} \ No newline at end of file From 2c572240aab7a5a94f702128383cd489c1e9b718 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Tue, 27 Aug 2024 21:17:17 +0200 Subject: [PATCH 03/47] Start with query consumer --- src/Directory.Packages.props | 1 + src/MadWorldNL.MantaRayPlan.sln | 7 ++++ .../Api.Grpc.csproj | 1 + src/Server.Controllers.Api.Grpc/Program.cs | 5 +++ .../Services/MessageBusServiceProxy.cs | 35 +++++++++++++------ .../MessageBuses/GetMessageBusStatus.cs | 3 ++ src/Server.Logic.Functions/Functions.csproj | 3 +- .../GetMessageBusStatusConsumer.cs | 20 +++++++++++ src/Server.Logic.Queries/Queries.csproj | 16 +++++++++ 9 files changed, 78 insertions(+), 13 deletions(-) create mode 100644 src/Server.Logic.Domain/MessageBuses/GetMessageBusStatus.cs create mode 100644 src/Server.Logic.Queries/MessageBuses/GetMessageBusStatusConsumer.cs create mode 100644 src/Server.Logic.Queries/Queries.csproj diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 58a1b74..ccd0baa 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -2,6 +2,7 @@ + diff --git a/src/MadWorldNL.MantaRayPlan.sln b/src/MadWorldNL.MantaRayPlan.sln index 4be719d..365bbad 100644 --- a/src/MadWorldNL.MantaRayPlan.sln +++ b/src/MadWorldNL.MantaRayPlan.sln @@ -113,6 +113,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Functions", "Server.Logic.F EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api.MessageBus.IntegrationTests", "Server.Controllers.Api.MessageBus.IntegrationTests\Api.MessageBus.IntegrationTests.csproj", "{78883E90-1F9F-4FA4-A1BC-573AF4AF432B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Queries", "Server.Logic.Queries\Queries.csproj", "{4ED4374B-83B4-43C5-8E48-F9C9179AF077}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -154,6 +156,7 @@ Global {1803C1EF-6193-4CE5-A37A-16F920F2388D} = {A7B2EEF8-045E-4473-9DE2-6452F5E14CE3} {3952C3C4-FB97-4441-9608-A5B7C3BC4E53} = {A7B2EEF8-045E-4473-9DE2-6452F5E14CE3} {78883E90-1F9F-4FA4-A1BC-573AF4AF432B} = {FCC26FAC-D27A-4E9C-97AB-225E3131FA52} + {4ED4374B-83B4-43C5-8E48-F9C9179AF077} = {A7B2EEF8-045E-4473-9DE2-6452F5E14CE3} EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C3AFAE1F-DDC9-4DB1-931D-1B934F9C9DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -224,5 +227,9 @@ Global {78883E90-1F9F-4FA4-A1BC-573AF4AF432B}.Debug|Any CPU.Build.0 = Debug|Any CPU {78883E90-1F9F-4FA4-A1BC-573AF4AF432B}.Release|Any CPU.ActiveCfg = Release|Any CPU {78883E90-1F9F-4FA4-A1BC-573AF4AF432B}.Release|Any CPU.Build.0 = Release|Any CPU + {4ED4374B-83B4-43C5-8E48-F9C9179AF077}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4ED4374B-83B4-43C5-8E48-F9C9179AF077}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4ED4374B-83B4-43C5-8E48-F9C9179AF077}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4ED4374B-83B4-43C5-8E48-F9C9179AF077}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj b/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj index e1385aa..6cf7e42 100644 --- a/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj +++ b/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj @@ -38,6 +38,7 @@ + diff --git a/src/Server.Controllers.Api.Grpc/Program.cs b/src/Server.Controllers.Api.Grpc/Program.cs index 548a21d..7439f6c 100644 --- a/src/Server.Controllers.Api.Grpc/Program.cs +++ b/src/Server.Controllers.Api.Grpc/Program.cs @@ -22,6 +22,11 @@ { x.SetKebabCaseEndpointNameFormatter(); + x.AddConsumer() + .Endpoint(e => e.Name = nameof(GetMessageBusStatus)); + + x.AddRequestClient(new Uri($"exchange:{nameof(GetMessageBusStatus)}")); + x.UsingRabbitMq((context,cfg) => { var messageBusSettings = builder.Configuration.GetSection(MessageBusSettings.Key) diff --git a/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs b/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs index 61f1d90..ec54649 100644 --- a/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs +++ b/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs @@ -2,32 +2,45 @@ using Grpc.Core; using MadWorldNL.MantaRayPlan.MessageBuses; using MantaRayPlan; +using MassTransit; namespace MadWorldNL.MantaRayPlan.Services; -public class MessageBusServiceProxy(IMessageBusRepository messageBusRepository, ILogger logger) - : MessageBusService.MessageBusServiceBase +public class MessageBusServiceProxy( + IRequestClient getMessageBusStatusClient, + ILogger logger) + : MessageBusService.MessageBusServiceBase { public override async Task GetStatus(Empty request, ServerCallContext context) { try { - var status = await messageBusRepository.FindStatusAsync() ?? new MessageBusStatus(); - + var status = + await getMessageBusStatusClient.GetResponse(new GetMessageBusStatus()); + + return new MessageBusStatusReply() + { + Counter = status.Message.Count, + }; + } + catch (RequestFaultException exception) when (exception.Fault?.Exceptions.Any(ex => + ex.InnerException?.ExceptionType == + "Npgsql.NpgsqlException") ?? false) + { + logger.LogError(exception, "Unable to connect with database"); + return new MessageBusStatusReply() { - Counter = status.Count + Message = "Unable to connect with database" }; } - catch (Exception ex) + catch (Exception exception) { - const string message = "Database error"; - - logger.LogError(ex, message); - + logger.LogError(exception, "Unknown error"); + return new MessageBusStatusReply() { - Message = message + Message = "Unknown error" }; } } diff --git a/src/Server.Logic.Domain/MessageBuses/GetMessageBusStatus.cs b/src/Server.Logic.Domain/MessageBuses/GetMessageBusStatus.cs new file mode 100644 index 0000000..f094c31 --- /dev/null +++ b/src/Server.Logic.Domain/MessageBuses/GetMessageBusStatus.cs @@ -0,0 +1,3 @@ +namespace MadWorldNL.MantaRayPlan.MessageBuses; + +public record GetMessageBusStatus(); \ No newline at end of file diff --git a/src/Server.Logic.Functions/Functions.csproj b/src/Server.Logic.Functions/Functions.csproj index 3a63532..606f215 100644 --- a/src/Server.Logic.Functions/Functions.csproj +++ b/src/Server.Logic.Functions/Functions.csproj @@ -2,8 +2,7 @@ net8.0 - enable - enable + MadWorldNL.MantaRayPlan.Logic.Functions diff --git a/src/Server.Logic.Queries/MessageBuses/GetMessageBusStatusConsumer.cs b/src/Server.Logic.Queries/MessageBuses/GetMessageBusStatusConsumer.cs new file mode 100644 index 0000000..e046fc2 --- /dev/null +++ b/src/Server.Logic.Queries/MessageBuses/GetMessageBusStatusConsumer.cs @@ -0,0 +1,20 @@ +using MassTransit; + +namespace MadWorldNL.MantaRayPlan.MessageBuses; + +public class GetMessageBusStatusConsumer : IConsumer +{ + private readonly IMessageBusRepository _messageBusRepository; + + public GetMessageBusStatusConsumer(IMessageBusRepository messageBusRepository) + { + _messageBusRepository = messageBusRepository; + } + + + public async Task Consume(ConsumeContext context) + { + var messageBusStatus = await _messageBusRepository.FindStatusAsync() ?? new MessageBusStatus(); + await context.RespondAsync(messageBusStatus); + } +} \ No newline at end of file diff --git a/src/Server.Logic.Queries/Queries.csproj b/src/Server.Logic.Queries/Queries.csproj new file mode 100644 index 0000000..f6d3b42 --- /dev/null +++ b/src/Server.Logic.Queries/Queries.csproj @@ -0,0 +1,16 @@ + + + + net8.0 + MadWorldNL.MantaRayPlan.Logic.Queries + + + + + + + + + + + From 0238223ae43cc4652a18be294a42dd81f57a8d1e Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Wed, 28 Aug 2024 21:13:31 +0200 Subject: [PATCH 04/47] Add command to the messagebus --- src/Server.Controllers.Api.Grpc/Program.cs | 14 ++++++--- .../Protos/messagebus.proto | 9 ++++-- .../Services/MessageBusServiceProxy.cs | 20 ++++++++---- .../Api.MessageBus.csproj | 1 + .../Program.cs | 2 ++ .../MessageBuses/MessageBusStatus.cs | 4 +-- .../MessageBuses/MessageBusStatusCommand.cs | 3 ++ .../MessageBuses/MessageBusStatusEvent.cs | 3 ++ ...eBusStatus.cs => MessageBusStatusQuery.cs} | 2 +- src/Server.Logic.Functions/Functions.csproj | 8 +++++ .../MessageBusStatusCommandConsumer.cs | 31 +++++++++++++++++++ ...er.cs => MessageBusStatusQueryConsumer.cs} | 6 ++-- 12 files changed, 85 insertions(+), 18 deletions(-) create mode 100644 src/Server.Logic.Domain/MessageBuses/MessageBusStatusCommand.cs create mode 100644 src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs rename src/Server.Logic.Domain/MessageBuses/{GetMessageBusStatus.cs => MessageBusStatusQuery.cs} (56%) create mode 100644 src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs rename src/Server.Logic.Queries/MessageBuses/{GetMessageBusStatusConsumer.cs => MessageBusStatusQueryConsumer.cs} (61%) diff --git a/src/Server.Controllers.Api.Grpc/Program.cs b/src/Server.Controllers.Api.Grpc/Program.cs index 7439f6c..3e2019e 100644 --- a/src/Server.Controllers.Api.Grpc/Program.cs +++ b/src/Server.Controllers.Api.Grpc/Program.cs @@ -22,10 +22,10 @@ { x.SetKebabCaseEndpointNameFormatter(); - x.AddConsumer() - .Endpoint(e => e.Name = nameof(GetMessageBusStatus)); + x.AddConsumer() + .Endpoint(e => e.Name = GetName()); - x.AddRequestClient(new Uri($"exchange:{nameof(GetMessageBusStatus)}")); + x.AddRequestClient(new Uri(GetExchangeName())); x.UsingRabbitMq((context,cfg) => { @@ -38,6 +38,8 @@ }); cfg.ConfigureEndpoints(context); + + EndpointConvention.Map(new Uri(GetExchangeName())); }); }); @@ -58,4 +60,8 @@ await app.RunAsync(); -public abstract partial class Program { } \ No newline at end of file +public abstract partial class Program +{ + private static string GetExchangeName() => $"exchange:{GetName()}"; + private static string GetName() => $"{typeof(T).Namespace}:{typeof(T).Name}"; +} \ No newline at end of file diff --git a/src/Server.Controllers.Api.Grpc/Protos/messagebus.proto b/src/Server.Controllers.Api.Grpc/Protos/messagebus.proto index 4b72ca3..650eb99 100644 --- a/src/Server.Controllers.Api.Grpc/Protos/messagebus.proto +++ b/src/Server.Controllers.Api.Grpc/Protos/messagebus.proto @@ -7,10 +7,15 @@ package messagebus; import "google/protobuf/empty.proto"; service MessageBusService { - rpc GetStatus (google.protobuf.Empty) returns (MessageBusStatusReply); + rpc GetStatus (google.protobuf.Empty) returns (GetMessageBusStatusReply); + rpc PostStatus (google.protobuf.Empty) returns (PostMessageBusStatusReply); } -message MessageBusStatusReply { +message GetMessageBusStatusReply { string message = 1; int32 counter = 2; +} + +message PostMessageBusStatusReply { + string message = 1; } \ No newline at end of file diff --git a/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs b/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs index ec54649..d61716c 100644 --- a/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs +++ b/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs @@ -7,18 +7,19 @@ namespace MadWorldNL.MantaRayPlan.Services; public class MessageBusServiceProxy( - IRequestClient getMessageBusStatusClient, + IRequestClient getMessageBusStatusClient, + ISendEndpointProvider sendEndpointProvider, ILogger logger) : MessageBusService.MessageBusServiceBase { - public override async Task GetStatus(Empty request, ServerCallContext context) + public override async Task GetStatus(Empty request, ServerCallContext context) { try { var status = - await getMessageBusStatusClient.GetResponse(new GetMessageBusStatus()); + await getMessageBusStatusClient.GetResponse(new MessageBusStatusQuery(), context.CancellationToken); - return new MessageBusStatusReply() + return new GetMessageBusStatusReply() { Counter = status.Message.Count, }; @@ -29,7 +30,7 @@ public override async Task GetStatus(Empty request, Serve { logger.LogError(exception, "Unable to connect with database"); - return new MessageBusStatusReply() + return new GetMessageBusStatusReply() { Message = "Unable to connect with database" }; @@ -38,10 +39,17 @@ public override async Task GetStatus(Empty request, Serve { logger.LogError(exception, "Unknown error"); - return new MessageBusStatusReply() + return new GetMessageBusStatusReply() { Message = "Unknown error" }; } } + + public override async Task PostStatus(Empty request, ServerCallContext context) + { + await sendEndpointProvider.Send(new MessageBusStatusCommand("Test"), context.CancellationToken); + + return new PostMessageBusStatusReply(); + } } \ No newline at end of file diff --git a/src/Server.Controllers.Api.MessageBus/Api.MessageBus.csproj b/src/Server.Controllers.Api.MessageBus/Api.MessageBus.csproj index efe9221..294bc1e 100644 --- a/src/Server.Controllers.Api.MessageBus/Api.MessageBus.csproj +++ b/src/Server.Controllers.Api.MessageBus/Api.MessageBus.csproj @@ -19,6 +19,7 @@ + diff --git a/src/Server.Controllers.Api.MessageBus/Program.cs b/src/Server.Controllers.Api.MessageBus/Program.cs index ebe4460..9142845 100644 --- a/src/Server.Controllers.Api.MessageBus/Program.cs +++ b/src/Server.Controllers.Api.MessageBus/Program.cs @@ -21,6 +21,8 @@ { x.SetKebabCaseEndpointNameFormatter(); + x.AddConsumer(); + x.UsingRabbitMq((context,cfg) => { var messageBusSettings = builder.Configuration.GetSection(MessageBusSettings.Key) diff --git a/src/Server.Logic.Domain/MessageBuses/MessageBusStatus.cs b/src/Server.Logic.Domain/MessageBuses/MessageBusStatus.cs index c599f1c..62a4751 100644 --- a/src/Server.Logic.Domain/MessageBuses/MessageBusStatus.cs +++ b/src/Server.Logic.Domain/MessageBuses/MessageBusStatus.cs @@ -2,8 +2,8 @@ namespace MadWorldNL.MantaRayPlan.MessageBuses; public class MessageBusStatus { - public int Id { get; private set; } - public int Count { get; private set; } + public int Id { get; set; } + public int Count { get; set; } public void IncrementCount() { diff --git a/src/Server.Logic.Domain/MessageBuses/MessageBusStatusCommand.cs b/src/Server.Logic.Domain/MessageBuses/MessageBusStatusCommand.cs new file mode 100644 index 0000000..55b0e51 --- /dev/null +++ b/src/Server.Logic.Domain/MessageBuses/MessageBusStatusCommand.cs @@ -0,0 +1,3 @@ +namespace MadWorldNL.MantaRayPlan.MessageBuses; + +public record MessageBusStatusCommand(string RandomData); \ No newline at end of file diff --git a/src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs b/src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs new file mode 100644 index 0000000..7e8f9bc --- /dev/null +++ b/src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs @@ -0,0 +1,3 @@ +namespace MadWorldNL.MantaRayPlan.MessageBuses; + +public record MessageBusStatusEvent(int Count); \ No newline at end of file diff --git a/src/Server.Logic.Domain/MessageBuses/GetMessageBusStatus.cs b/src/Server.Logic.Domain/MessageBuses/MessageBusStatusQuery.cs similarity index 56% rename from src/Server.Logic.Domain/MessageBuses/GetMessageBusStatus.cs rename to src/Server.Logic.Domain/MessageBuses/MessageBusStatusQuery.cs index f094c31..7822c7a 100644 --- a/src/Server.Logic.Domain/MessageBuses/GetMessageBusStatus.cs +++ b/src/Server.Logic.Domain/MessageBuses/MessageBusStatusQuery.cs @@ -1,3 +1,3 @@ namespace MadWorldNL.MantaRayPlan.MessageBuses; -public record GetMessageBusStatus(); \ No newline at end of file +public record MessageBusStatusQuery(); \ No newline at end of file diff --git a/src/Server.Logic.Functions/Functions.csproj b/src/Server.Logic.Functions/Functions.csproj index 606f215..3139d29 100644 --- a/src/Server.Logic.Functions/Functions.csproj +++ b/src/Server.Logic.Functions/Functions.csproj @@ -5,4 +5,12 @@ MadWorldNL.MantaRayPlan.Logic.Functions + + + + + + + + diff --git a/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs b/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs new file mode 100644 index 0000000..e987880 --- /dev/null +++ b/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs @@ -0,0 +1,31 @@ +using MassTransit; + +namespace MadWorldNL.MantaRayPlan.MessageBuses; + +public class MessageBusStatusCommandConsumer : IConsumer +{ + private readonly IMessageBusRepository _messageBusRepository; + + public MessageBusStatusCommandConsumer(IMessageBusRepository messageBusRepository) + { + _messageBusRepository = messageBusRepository; + } + + public async Task Consume(ConsumeContext context) + { + var status = await _messageBusRepository.FindStatusAsync(); + + if (status is null) + { + status = new MessageBusStatus(); + + await _messageBusRepository.CreateAsync(status); + } + + status.IncrementCount(); + + await _messageBusRepository.UpdateAsync(status); + + await context.Publish(new MessageBusStatusEvent(status.Count)); + } +} \ No newline at end of file diff --git a/src/Server.Logic.Queries/MessageBuses/GetMessageBusStatusConsumer.cs b/src/Server.Logic.Queries/MessageBuses/MessageBusStatusQueryConsumer.cs similarity index 61% rename from src/Server.Logic.Queries/MessageBuses/GetMessageBusStatusConsumer.cs rename to src/Server.Logic.Queries/MessageBuses/MessageBusStatusQueryConsumer.cs index e046fc2..a7fb378 100644 --- a/src/Server.Logic.Queries/MessageBuses/GetMessageBusStatusConsumer.cs +++ b/src/Server.Logic.Queries/MessageBuses/MessageBusStatusQueryConsumer.cs @@ -2,17 +2,17 @@ namespace MadWorldNL.MantaRayPlan.MessageBuses; -public class GetMessageBusStatusConsumer : IConsumer +public class MessageBusStatusQueryConsumer : IConsumer { private readonly IMessageBusRepository _messageBusRepository; - public GetMessageBusStatusConsumer(IMessageBusRepository messageBusRepository) + public MessageBusStatusQueryConsumer(IMessageBusRepository messageBusRepository) { _messageBusRepository = messageBusRepository; } - public async Task Consume(ConsumeContext context) + public async Task Consume(ConsumeContext context) { var messageBusStatus = await _messageBusRepository.FindStatusAsync() ?? new MessageBusStatus(); await context.RespondAsync(messageBusStatus); From 4f689a6ed399afb384815fa83774e5b41a7921bd Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Thu, 29 Aug 2024 21:00:16 +0200 Subject: [PATCH 05/47] Push events to grpc --- .../Api.Grpc.csproj | 2 ++ src/Server.Controllers.Api.Grpc/Program.cs | 3 ++ .../Protos/events.proto | 16 +++++++++ .../Services/EventServiceProxy.cs | 35 +++++++++++++++++++ .../MessageBuses/MessageBusStatusEvent.cs | 7 +++- .../Process/EventPublisher.cs | 6 ++++ src/Server.Logic.Domain/Process/IEvent.cs | 6 ++++ .../MessageBuses/GrpcEventPusherConsumer.cs | 14 ++++++++ .../MessageBusStatusCommandConsumer.cs | 5 ++- 9 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 src/Server.Controllers.Api.Grpc/Protos/events.proto create mode 100644 src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs create mode 100644 src/Server.Logic.Domain/Process/EventPublisher.cs create mode 100644 src/Server.Logic.Domain/Process/IEvent.cs create mode 100644 src/Server.Logic.Functions/MessageBuses/GrpcEventPusherConsumer.cs diff --git a/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj b/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj index 6cf7e42..263a2d6 100644 --- a/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj +++ b/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj @@ -7,6 +7,7 @@ + @@ -38,6 +39,7 @@ + diff --git a/src/Server.Controllers.Api.Grpc/Program.cs b/src/Server.Controllers.Api.Grpc/Program.cs index 3e2019e..f9b84cd 100644 --- a/src/Server.Controllers.Api.Grpc/Program.cs +++ b/src/Server.Controllers.Api.Grpc/Program.cs @@ -21,6 +21,8 @@ builder.Services.AddMassTransit(x => { x.SetKebabCaseEndpointNameFormatter(); + + x.AddConsumer>(); x.AddConsumer() .Endpoint(e => e.Name = GetName()); @@ -45,6 +47,7 @@ var app = builder.Build(); +app.MapGrpcService(); app.MapGrpcService(); if (app.Environment.IsDevelopment()) diff --git a/src/Server.Controllers.Api.Grpc/Protos/events.proto b/src/Server.Controllers.Api.Grpc/Protos/events.proto new file mode 100644 index 0000000..eb08361 --- /dev/null +++ b/src/Server.Controllers.Api.Grpc/Protos/events.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +option csharp_namespace = "MantaRayPlan"; + +package events; + +import "google/protobuf/empty.proto"; + +service EventService { + rpc Subscribe (google.protobuf.Empty) returns (stream newEvent); +} + +message newEvent { + string type = 1; + string json = 2; +} \ No newline at end of file diff --git a/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs b/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs new file mode 100644 index 0000000..a790557 --- /dev/null +++ b/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs @@ -0,0 +1,35 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Google.Protobuf.WellKnownTypes; +using Grpc.Core; +using MadWorldNL.MantaRayPlan.Process; +using MantaRayPlan; + +namespace MadWorldNL.MantaRayPlan.Services; + +public class EventServiceProxy : EventService.EventServiceBase +{ + public override Task Subscribe(Empty request, IServerStreamWriter responseStream, ServerCallContext context) + { + EventPublisher.OnMessageReceived += SendEventToClient; + + while (!context.CancellationToken.IsCancellationRequested) + { + Thread.Sleep(1000); + } + + EventPublisher.OnMessageReceived -= SendEventToClient; + return Task.CompletedTask; + + void SendEventToClient(IEvent newEvent) + { + var newEventResponse = new newEvent() + { + Type = newEvent.GetType().Name, + Json = JsonSerializer.Serialize(newEvent, newEvent.GetType()) + }; + + responseStream.WriteAsync(newEventResponse); + } + } +} \ No newline at end of file diff --git a/src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs b/src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs index 7e8f9bc..536714e 100644 --- a/src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs +++ b/src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs @@ -1,3 +1,8 @@ +using MadWorldNL.MantaRayPlan.Process; + namespace MadWorldNL.MantaRayPlan.MessageBuses; -public record MessageBusStatusEvent(int Count); \ No newline at end of file +public class MessageBusStatusEvent() : IEvent +{ + public int Count { get; set; } +} \ No newline at end of file diff --git a/src/Server.Logic.Domain/Process/EventPublisher.cs b/src/Server.Logic.Domain/Process/EventPublisher.cs new file mode 100644 index 0000000..1d71db8 --- /dev/null +++ b/src/Server.Logic.Domain/Process/EventPublisher.cs @@ -0,0 +1,6 @@ +namespace MadWorldNL.MantaRayPlan.Process; + +public static class EventPublisher +{ + public static Action OnMessageReceived { get; set; } = _ => { }; +} \ No newline at end of file diff --git a/src/Server.Logic.Domain/Process/IEvent.cs b/src/Server.Logic.Domain/Process/IEvent.cs new file mode 100644 index 0000000..8745cf8 --- /dev/null +++ b/src/Server.Logic.Domain/Process/IEvent.cs @@ -0,0 +1,6 @@ +namespace MadWorldNL.MantaRayPlan.Process; + +public interface IEvent +{ + +} \ No newline at end of file diff --git a/src/Server.Logic.Functions/MessageBuses/GrpcEventPusherConsumer.cs b/src/Server.Logic.Functions/MessageBuses/GrpcEventPusherConsumer.cs new file mode 100644 index 0000000..0bddc92 --- /dev/null +++ b/src/Server.Logic.Functions/MessageBuses/GrpcEventPusherConsumer.cs @@ -0,0 +1,14 @@ +using MadWorldNL.MantaRayPlan.Process; +using MassTransit; + +namespace MadWorldNL.MantaRayPlan.MessageBuses; + +public class GrpcEventPusherConsumer : IConsumer where TMessage : class, IEvent +{ + public Task Consume(ConsumeContext context) + { + EventPublisher.OnMessageReceived(context.Message); + + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs b/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs index e987880..e5278b7 100644 --- a/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs +++ b/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs @@ -26,6 +26,9 @@ public async Task Consume(ConsumeContext context) await _messageBusRepository.UpdateAsync(status); - await context.Publish(new MessageBusStatusEvent(status.Count)); + await context.Publish(new MessageBusStatusEvent + { + Count = status.Count + }); } } \ No newline at end of file From 06dc3ab02f010217e75202e2be88afbca4b6f3b5 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Mon, 23 Sep 2024 18:24:20 +0200 Subject: [PATCH 06/47] Update new version --- src/Directory.Packages.props | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index ccd0baa..6a38f5b 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -1,6 +1,6 @@ - + @@ -19,11 +19,11 @@ - - - - - + + + + + @@ -33,7 +33,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive From bd5e7c1e656dbf95cfe0a6f2082329cbee5bc537 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Wed, 25 Sep 2024 19:47:39 +0200 Subject: [PATCH 07/47] Get Message Bus Status in Admin bff --- .../ClientSdk.Admin.Bff.csproj | 9 ++++ .../MessageBuses/GetStatusResponse.cs | 3 ++ .../ClientSdk.Api.Grpc.csproj | 20 +++++++++ .../Protos/events.proto | 2 +- .../Protos/messagebus.proto | 2 +- src/Clients.Admin.Bff/Admin.Bff.csproj | 3 ++ src/Clients.Admin.Bff/Clients.Admin.Bff.http | 6 --- .../Configurations/ApiSettings.cs | 11 +++++ .../Endpoints/MessageBusEndpoints.cs | 20 +++++++++ src/Clients.Admin.Bff/Program.cs | 41 ++++++++----------- src/Clients.Admin.Bff/WeatherForecast.cs | 6 --- .../appsettings.Development.json | 3 ++ src/Clients.Admin.Bff/appsettings.json | 3 ++ src/Directory.Packages.props | 3 ++ src/MadWorldNL.MantaRayPlan.sln | 14 +++++++ .../Api.Grpc.csproj | 6 +-- .../Services/EventServiceProxy.cs | 3 +- .../Services/MessageBusServiceProxy.cs | 2 +- 18 files changed, 111 insertions(+), 46 deletions(-) create mode 100644 src/ClientSdk.Admin.Bff/ClientSdk.Admin.Bff.csproj create mode 100644 src/ClientSdk.Admin.Bff/MessageBuses/GetStatusResponse.cs create mode 100644 src/ClientSdk.Api.Grpc/ClientSdk.Api.Grpc.csproj rename src/{Server.Controllers.Api.Grpc => ClientSdk.Api.Grpc}/Protos/events.proto (80%) rename src/{Server.Controllers.Api.Grpc => ClientSdk.Api.Grpc}/Protos/messagebus.proto (87%) delete mode 100644 src/Clients.Admin.Bff/Clients.Admin.Bff.http create mode 100644 src/Clients.Admin.Bff/Configurations/ApiSettings.cs create mode 100644 src/Clients.Admin.Bff/Endpoints/MessageBusEndpoints.cs delete mode 100644 src/Clients.Admin.Bff/WeatherForecast.cs diff --git a/src/ClientSdk.Admin.Bff/ClientSdk.Admin.Bff.csproj b/src/ClientSdk.Admin.Bff/ClientSdk.Admin.Bff.csproj new file mode 100644 index 0000000..3a63532 --- /dev/null +++ b/src/ClientSdk.Admin.Bff/ClientSdk.Admin.Bff.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/src/ClientSdk.Admin.Bff/MessageBuses/GetStatusResponse.cs b/src/ClientSdk.Admin.Bff/MessageBuses/GetStatusResponse.cs new file mode 100644 index 0000000..16f3f4d --- /dev/null +++ b/src/ClientSdk.Admin.Bff/MessageBuses/GetStatusResponse.cs @@ -0,0 +1,3 @@ +namespace MadWorldNL.MantaRayPlan.MessageBuses; + +public record GetStatusResponse(string message, int counter); \ No newline at end of file diff --git a/src/ClientSdk.Api.Grpc/ClientSdk.Api.Grpc.csproj b/src/ClientSdk.Api.Grpc/ClientSdk.Api.Grpc.csproj new file mode 100644 index 0000000..77a2068 --- /dev/null +++ b/src/ClientSdk.Api.Grpc/ClientSdk.Api.Grpc.csproj @@ -0,0 +1,20 @@ + + + + net8.0 + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/src/Server.Controllers.Api.Grpc/Protos/events.proto b/src/ClientSdk.Api.Grpc/Protos/events.proto similarity index 80% rename from src/Server.Controllers.Api.Grpc/Protos/events.proto rename to src/ClientSdk.Api.Grpc/Protos/events.proto index eb08361..bdd9d2c 100644 --- a/src/Server.Controllers.Api.Grpc/Protos/events.proto +++ b/src/ClientSdk.Api.Grpc/Protos/events.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option csharp_namespace = "MantaRayPlan"; +option csharp_namespace = "MadWorldNL.MantaRayPlan.Api"; package events; diff --git a/src/Server.Controllers.Api.Grpc/Protos/messagebus.proto b/src/ClientSdk.Api.Grpc/Protos/messagebus.proto similarity index 87% rename from src/Server.Controllers.Api.Grpc/Protos/messagebus.proto rename to src/ClientSdk.Api.Grpc/Protos/messagebus.proto index 650eb99..630a9d8 100644 --- a/src/Server.Controllers.Api.Grpc/Protos/messagebus.proto +++ b/src/ClientSdk.Api.Grpc/Protos/messagebus.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option csharp_namespace = "MantaRayPlan"; +option csharp_namespace = "MadWorldNL.MantaRayPlan.Api"; package messagebus; diff --git a/src/Clients.Admin.Bff/Admin.Bff.csproj b/src/Clients.Admin.Bff/Admin.Bff.csproj index 45f7915..867b2b5 100644 --- a/src/Clients.Admin.Bff/Admin.Bff.csproj +++ b/src/Clients.Admin.Bff/Admin.Bff.csproj @@ -7,6 +7,7 @@ + @@ -27,6 +28,8 @@ + + diff --git a/src/Clients.Admin.Bff/Clients.Admin.Bff.http b/src/Clients.Admin.Bff/Clients.Admin.Bff.http deleted file mode 100644 index 1f9e60f..0000000 --- a/src/Clients.Admin.Bff/Clients.Admin.Bff.http +++ /dev/null @@ -1,6 +0,0 @@ -@Clients.Admin.Bff_HostAddress = http://localhost:5173 - -GET {{Clients.Admin.Bff_HostAddress}}/weatherforecast/ -Accept: application/json - -### diff --git a/src/Clients.Admin.Bff/Configurations/ApiSettings.cs b/src/Clients.Admin.Bff/Configurations/ApiSettings.cs new file mode 100644 index 0000000..c5044e2 --- /dev/null +++ b/src/Clients.Admin.Bff/Configurations/ApiSettings.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace MadWorldNL.MantaRayPlan.Configurations; + +public class ApiSettings +{ + public const string Key = "Api"; + + [Required] + public string Address { get; init; } = string.Empty; +} \ No newline at end of file diff --git a/src/Clients.Admin.Bff/Endpoints/MessageBusEndpoints.cs b/src/Clients.Admin.Bff/Endpoints/MessageBusEndpoints.cs new file mode 100644 index 0000000..c167af2 --- /dev/null +++ b/src/Clients.Admin.Bff/Endpoints/MessageBusEndpoints.cs @@ -0,0 +1,20 @@ +using Google.Protobuf.WellKnownTypes; +using MadWorldNL.MantaRayPlan.Api; +using MadWorldNL.MantaRayPlan.MessageBuses; +using Microsoft.AspNetCore.Mvc; + +namespace MadWorldNL.MantaRayPlan.Endpoints; + +public static class MessageBusEndpoints +{ + public static void AddMessageBusEndpoints(this RouteGroupBuilder endpoints) + { + var messageBusEndpoints = endpoints.MapGroup("/MessageBus"); + + messageBusEndpoints.MapGet("/Status", ([FromServices] MessageBusService.MessageBusServiceClient client) => + { + var status = client.GetStatus(new Empty()); + return new GetStatusResponse(status.Message, status.Counter); + }); + } +} \ No newline at end of file diff --git a/src/Clients.Admin.Bff/Program.cs b/src/Clients.Admin.Bff/Program.cs index 3c3d8ad..2eeac8e 100644 --- a/src/Clients.Admin.Bff/Program.cs +++ b/src/Clients.Admin.Bff/Program.cs @@ -1,11 +1,9 @@ using System.Threading.RateLimiting; -using MadWorldNL.MantaRayPlan; +using MadWorldNL.MantaRayPlan.Api; using MadWorldNL.MantaRayPlan.Configurations; +using MadWorldNL.MantaRayPlan.Endpoints; using MadWorldNL.MantaRayPlan.OpenTelemetry; using Microsoft.AspNetCore.RateLimiting; -using OpenTelemetry; -using OpenTelemetry.Exporter; -using OpenTelemetry.Logs; var builder = WebApplication.CreateBuilder(args); @@ -19,6 +17,18 @@ builder.Services.AddHealthChecks(); +var apiSettingsSection = builder.Configuration.GetSection(ApiSettings.Key); +builder.Services.AddOptions() + .Bind(apiSettingsSection) + .ValidateDataAnnotations() + .ValidateOnStart(); +var apiSettings = apiSettingsSection.Get(); + +builder.Services.AddGrpcClient(options => +{ + options.Address = new Uri(apiSettings!.Address); +}); + builder.Services.AddRateLimiter(rl => rl .AddFixedWindowLimiter(policyName: RateLimiterConfig.DefaultName, options => { @@ -50,29 +60,12 @@ app.MapHealthChecks("/healthz"); -var summaries = new[] -{ - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" -}; - -app.MapGet("/weatherforecast", (ILogger logger) => - { - logger.LogInformation("Retrieve weather forecast"); - - var forecast = Enumerable.Range(1, 5).Select(index => - new WeatherForecast - ( - DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - Random.Shared.Next(-20, 55), - summaries[Random.Shared.Next(summaries.Length)] - )) - .ToArray(); - return forecast; - }) - .WithName("GetWeatherForecast") +var defaultEndpoints = app.MapGroup("/") .WithOpenApi() .RequireRateLimiting(RateLimiterConfig.DefaultName); +defaultEndpoints.AddMessageBusEndpoints(); + await app.RunAsync(); public abstract partial class Program { } \ No newline at end of file diff --git a/src/Clients.Admin.Bff/WeatherForecast.cs b/src/Clients.Admin.Bff/WeatherForecast.cs deleted file mode 100644 index ef88bad..0000000 --- a/src/Clients.Admin.Bff/WeatherForecast.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace MadWorldNL.MantaRayPlan; - -public record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) -{ - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); -} \ No newline at end of file diff --git a/src/Clients.Admin.Bff/appsettings.Development.json b/src/Clients.Admin.Bff/appsettings.Development.json index 8cccbee..7e33399 100644 --- a/src/Clients.Admin.Bff/appsettings.Development.json +++ b/src/Clients.Admin.Bff/appsettings.Development.json @@ -1,4 +1,7 @@ { + "Api": { + "Address": "https://localhost:7132" + }, "Logging": { "LogLevel": { "Default": "Information", diff --git a/src/Clients.Admin.Bff/appsettings.json b/src/Clients.Admin.Bff/appsettings.json index 8873a5f..cc1ddc7 100644 --- a/src/Clients.Admin.Bff/appsettings.json +++ b/src/Clients.Admin.Bff/appsettings.json @@ -1,5 +1,8 @@ { "AllowedHosts": "*", + "Api": { + "Address": "https://localhost:7132" + }, "Logging": { "LogLevel": { "Default": "Information", diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 6a38f5b..a0a38d1 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -1,6 +1,9 @@ + + + diff --git a/src/MadWorldNL.MantaRayPlan.sln b/src/MadWorldNL.MantaRayPlan.sln index 365bbad..7d02b40 100644 --- a/src/MadWorldNL.MantaRayPlan.sln +++ b/src/MadWorldNL.MantaRayPlan.sln @@ -115,6 +115,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api.MessageBus.IntegrationT EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Queries", "Server.Logic.Queries\Queries.csproj", "{4ED4374B-83B4-43C5-8E48-F9C9179AF077}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientSdk.Api.Grpc", "ClientSdk.Api.Grpc\ClientSdk.Api.Grpc.csproj", "{6F2083BE-51EF-48D2-AA85-8C6A099C3E85}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientSdk.Admin.Bff", "ClientSdk.Admin.Bff\ClientSdk.Admin.Bff.csproj", "{B5FA9C6D-5F8A-4334-985F-4909833996AE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -157,6 +161,8 @@ Global {3952C3C4-FB97-4441-9608-A5B7C3BC4E53} = {A7B2EEF8-045E-4473-9DE2-6452F5E14CE3} {78883E90-1F9F-4FA4-A1BC-573AF4AF432B} = {FCC26FAC-D27A-4E9C-97AB-225E3131FA52} {4ED4374B-83B4-43C5-8E48-F9C9179AF077} = {A7B2EEF8-045E-4473-9DE2-6452F5E14CE3} + {6F2083BE-51EF-48D2-AA85-8C6A099C3E85} = {00C31373-91B2-410A-A8B7-F66F7CD51708} + {B5FA9C6D-5F8A-4334-985F-4909833996AE} = {AD870EB2-89A9-471C-A5CB-C95FA4D917BC} EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C3AFAE1F-DDC9-4DB1-931D-1B934F9C9DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -231,5 +237,13 @@ Global {4ED4374B-83B4-43C5-8E48-F9C9179AF077}.Debug|Any CPU.Build.0 = Debug|Any CPU {4ED4374B-83B4-43C5-8E48-F9C9179AF077}.Release|Any CPU.ActiveCfg = Release|Any CPU {4ED4374B-83B4-43C5-8E48-F9C9179AF077}.Release|Any CPU.Build.0 = Release|Any CPU + {6F2083BE-51EF-48D2-AA85-8C6A099C3E85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F2083BE-51EF-48D2-AA85-8C6A099C3E85}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F2083BE-51EF-48D2-AA85-8C6A099C3E85}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F2083BE-51EF-48D2-AA85-8C6A099C3E85}.Release|Any CPU.Build.0 = Release|Any CPU + {B5FA9C6D-5F8A-4334-985F-4909833996AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5FA9C6D-5F8A-4334-985F-4909833996AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5FA9C6D-5F8A-4334-985F-4909833996AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5FA9C6D-5F8A-4334-985F-4909833996AE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj b/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj index 263a2d6..6727934 100644 --- a/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj +++ b/src/Server.Controllers.Api.Grpc/Api.Grpc.csproj @@ -6,11 +6,6 @@ Linux - - - - - @@ -37,6 +32,7 @@ + diff --git a/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs b/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs index a790557..f5df860 100644 --- a/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs +++ b/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs @@ -1,9 +1,8 @@ using System.Text.Json; -using System.Text.Json.Serialization; using Google.Protobuf.WellKnownTypes; using Grpc.Core; +using MadWorldNL.MantaRayPlan.Api; using MadWorldNL.MantaRayPlan.Process; -using MantaRayPlan; namespace MadWorldNL.MantaRayPlan.Services; diff --git a/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs b/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs index d61716c..89647bb 100644 --- a/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs +++ b/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs @@ -1,7 +1,7 @@ using Google.Protobuf.WellKnownTypes; using Grpc.Core; +using MadWorldNL.MantaRayPlan.Api; using MadWorldNL.MantaRayPlan.MessageBuses; -using MantaRayPlan; using MassTransit; namespace MadWorldNL.MantaRayPlan.Services; From 905a9ac2e8fbd1849f12af749030c88a11dc7dfe Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Wed, 25 Sep 2024 19:54:05 +0200 Subject: [PATCH 08/47] Add Post message bus in admin bff --- src/ClientSdk.Admin.Bff/MessageBuses/PostStatusResponse.cs | 3 +++ src/Clients.Admin.Bff/Endpoints/MessageBusEndpoints.cs | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 src/ClientSdk.Admin.Bff/MessageBuses/PostStatusResponse.cs diff --git a/src/ClientSdk.Admin.Bff/MessageBuses/PostStatusResponse.cs b/src/ClientSdk.Admin.Bff/MessageBuses/PostStatusResponse.cs new file mode 100644 index 0000000..6c56936 --- /dev/null +++ b/src/ClientSdk.Admin.Bff/MessageBuses/PostStatusResponse.cs @@ -0,0 +1,3 @@ +namespace MadWorldNL.MantaRayPlan.MessageBuses; + +public record PostStatusResponse(string message); \ No newline at end of file diff --git a/src/Clients.Admin.Bff/Endpoints/MessageBusEndpoints.cs b/src/Clients.Admin.Bff/Endpoints/MessageBusEndpoints.cs index c167af2..555db35 100644 --- a/src/Clients.Admin.Bff/Endpoints/MessageBusEndpoints.cs +++ b/src/Clients.Admin.Bff/Endpoints/MessageBusEndpoints.cs @@ -16,5 +16,11 @@ public static void AddMessageBusEndpoints(this RouteGroupBuilder endpoints) var status = client.GetStatus(new Empty()); return new GetStatusResponse(status.Message, status.Counter); }); + + messageBusEndpoints.MapPost("/Status", ([FromServices] MessageBusService.MessageBusServiceClient client) => + { + var response = client.PostStatus(new Empty()); + return new PostStatusResponse(response.Message); + }); } } \ No newline at end of file From ae5c84710e601868403a2248dab0a8f37489351e Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Wed, 25 Sep 2024 20:43:49 +0200 Subject: [PATCH 09/47] Start with SignalR --- .../ClientSdk.Api.MessageBus.csproj | 9 +++++++ src/ClientSdk.Api.MessageBus/Events/IEvent.cs | 6 +++++ .../Events/MessageBusStatusEvent.cs | 6 +++++ src/Clients.Admin.Bff/Admin.Bff.csproj | 1 + src/Clients.Admin.Bff/Hubs/EventsHub.cs | 25 +++++++++++++++++++ src/Clients.Admin.Bff/Program.cs | 10 +++++++- src/Directory.Packages.props | 1 + .../MadWorldNL.AspNetCore.csproj | 5 ++++ .../MassTransit}/EventPublisher.cs | 4 ++- .../MassTransit/EventPusherConsumer.cs} | 6 ++--- src/MadWorldNL.MantaRayPlan.sln | 7 ++++++ src/Server.Controllers.Api.Grpc/Program.cs | 4 ++- .../Services/EventServiceProxy.cs | 3 ++- .../MessageBuses/MessageBusStatusEvent.cs | 8 ------ src/Server.Logic.Domain/Process/IEvent.cs | 6 ----- src/Server.Logic.Functions/Functions.csproj | 1 + .../MessageBusStatusCommandConsumer.cs | 1 + 17 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 src/ClientSdk.Api.MessageBus/ClientSdk.Api.MessageBus.csproj create mode 100644 src/ClientSdk.Api.MessageBus/Events/IEvent.cs create mode 100644 src/ClientSdk.Api.MessageBus/Events/MessageBusStatusEvent.cs create mode 100644 src/Clients.Admin.Bff/Hubs/EventsHub.cs rename src/{Server.Logic.Domain/Process => MadWorldNL.AspNetCore/MassTransit}/EventPublisher.cs (57%) rename src/{Server.Logic.Functions/MessageBuses/GrpcEventPusherConsumer.cs => MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs} (50%) delete mode 100644 src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs delete mode 100644 src/Server.Logic.Domain/Process/IEvent.cs diff --git a/src/ClientSdk.Api.MessageBus/ClientSdk.Api.MessageBus.csproj b/src/ClientSdk.Api.MessageBus/ClientSdk.Api.MessageBus.csproj new file mode 100644 index 0000000..3a63532 --- /dev/null +++ b/src/ClientSdk.Api.MessageBus/ClientSdk.Api.MessageBus.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/src/ClientSdk.Api.MessageBus/Events/IEvent.cs b/src/ClientSdk.Api.MessageBus/Events/IEvent.cs new file mode 100644 index 0000000..d093abc --- /dev/null +++ b/src/ClientSdk.Api.MessageBus/Events/IEvent.cs @@ -0,0 +1,6 @@ +namespace MadWorldNL.MantaRayPlan.Events; + +public interface IEvent +{ + +} \ No newline at end of file diff --git a/src/ClientSdk.Api.MessageBus/Events/MessageBusStatusEvent.cs b/src/ClientSdk.Api.MessageBus/Events/MessageBusStatusEvent.cs new file mode 100644 index 0000000..5fb72bb --- /dev/null +++ b/src/ClientSdk.Api.MessageBus/Events/MessageBusStatusEvent.cs @@ -0,0 +1,6 @@ +namespace MadWorldNL.MantaRayPlan.Events; + +public class MessageBusStatusEvent() : IEvent +{ + public int Count { get; set; } +} \ No newline at end of file diff --git a/src/Clients.Admin.Bff/Admin.Bff.csproj b/src/Clients.Admin.Bff/Admin.Bff.csproj index 867b2b5..196e6df 100644 --- a/src/Clients.Admin.Bff/Admin.Bff.csproj +++ b/src/Clients.Admin.Bff/Admin.Bff.csproj @@ -14,6 +14,7 @@ + diff --git a/src/Clients.Admin.Bff/Hubs/EventsHub.cs b/src/Clients.Admin.Bff/Hubs/EventsHub.cs new file mode 100644 index 0000000..4b216c4 --- /dev/null +++ b/src/Clients.Admin.Bff/Hubs/EventsHub.cs @@ -0,0 +1,25 @@ +using MadWorldNL.MantaRayPlan.Events; +using MadWorldNL.MantaRayPlan.MassTransit; +using Microsoft.AspNetCore.SignalR; + +namespace MadWorldNL.MantaRayPlan.Hubs; + +public class EventsHub : Hub +{ + public EventsHub() + { + EventPublisher.OnMessageReceived += SendEventToClient; + } + + void SendEventToClient(IEvent newEvent) + { + + } + + public new void Dispose() + { + EventPublisher.OnMessageReceived -= SendEventToClient; + + base.Dispose(); + } +} \ No newline at end of file diff --git a/src/Clients.Admin.Bff/Program.cs b/src/Clients.Admin.Bff/Program.cs index 2eeac8e..938b1f4 100644 --- a/src/Clients.Admin.Bff/Program.cs +++ b/src/Clients.Admin.Bff/Program.cs @@ -2,6 +2,7 @@ using MadWorldNL.MantaRayPlan.Api; using MadWorldNL.MantaRayPlan.Configurations; using MadWorldNL.MantaRayPlan.Endpoints; +using MadWorldNL.MantaRayPlan.Hubs; using MadWorldNL.MantaRayPlan.OpenTelemetry; using Microsoft.AspNetCore.RateLimiting; @@ -12,8 +13,13 @@ builder.AddDefaultOpenTelemetry(openTelemetryConfig); +builder.Services.AddSignalR(); + builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); +builder.Services.AddSwaggerGen(options => +{ + options.AddSignalRSwaggerGen(); +}); builder.Services.AddHealthChecks(); @@ -58,6 +64,8 @@ app.UseSwagger(); app.UseSwaggerUI(); +app.MapHub("/Events"); + app.MapHealthChecks("/healthz"); var defaultEndpoints = app.MapGroup("/") diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index a0a38d1..728ebe8 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -22,6 +22,7 @@ + diff --git a/src/MadWorldNL.AspNetCore/MadWorldNL.AspNetCore.csproj b/src/MadWorldNL.AspNetCore/MadWorldNL.AspNetCore.csproj index eda91ff..2ac3383 100644 --- a/src/MadWorldNL.AspNetCore/MadWorldNL.AspNetCore.csproj +++ b/src/MadWorldNL.AspNetCore/MadWorldNL.AspNetCore.csproj @@ -7,6 +7,7 @@ + @@ -15,4 +16,8 @@ + + + + diff --git a/src/Server.Logic.Domain/Process/EventPublisher.cs b/src/MadWorldNL.AspNetCore/MassTransit/EventPublisher.cs similarity index 57% rename from src/Server.Logic.Domain/Process/EventPublisher.cs rename to src/MadWorldNL.AspNetCore/MassTransit/EventPublisher.cs index 1d71db8..e9e0016 100644 --- a/src/Server.Logic.Domain/Process/EventPublisher.cs +++ b/src/MadWorldNL.AspNetCore/MassTransit/EventPublisher.cs @@ -1,4 +1,6 @@ -namespace MadWorldNL.MantaRayPlan.Process; +using MadWorldNL.MantaRayPlan.Events; + +namespace MadWorldNL.MantaRayPlan.MassTransit; public static class EventPublisher { diff --git a/src/Server.Logic.Functions/MessageBuses/GrpcEventPusherConsumer.cs b/src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs similarity index 50% rename from src/Server.Logic.Functions/MessageBuses/GrpcEventPusherConsumer.cs rename to src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs index 0bddc92..389eb85 100644 --- a/src/Server.Logic.Functions/MessageBuses/GrpcEventPusherConsumer.cs +++ b/src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs @@ -1,9 +1,9 @@ -using MadWorldNL.MantaRayPlan.Process; +using MadWorldNL.MantaRayPlan.Events; using MassTransit; -namespace MadWorldNL.MantaRayPlan.MessageBuses; +namespace MadWorldNL.MantaRayPlan.MassTransit; -public class GrpcEventPusherConsumer : IConsumer where TMessage : class, IEvent +public class EventPusherConsumer : IConsumer where TMessage : class, IEvent { public Task Consume(ConsumeContext context) { diff --git a/src/MadWorldNL.MantaRayPlan.sln b/src/MadWorldNL.MantaRayPlan.sln index 7d02b40..2768202 100644 --- a/src/MadWorldNL.MantaRayPlan.sln +++ b/src/MadWorldNL.MantaRayPlan.sln @@ -119,6 +119,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientSdk.Api.Grpc", "Clien EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientSdk.Admin.Bff", "ClientSdk.Admin.Bff\ClientSdk.Admin.Bff.csproj", "{B5FA9C6D-5F8A-4334-985F-4909833996AE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientSdk.Api.MessageBus", "ClientSdk.Api.MessageBus\ClientSdk.Api.MessageBus.csproj", "{F76D206C-3F80-4099-B4ED-3DAE193303FC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -163,6 +165,7 @@ Global {4ED4374B-83B4-43C5-8E48-F9C9179AF077} = {A7B2EEF8-045E-4473-9DE2-6452F5E14CE3} {6F2083BE-51EF-48D2-AA85-8C6A099C3E85} = {00C31373-91B2-410A-A8B7-F66F7CD51708} {B5FA9C6D-5F8A-4334-985F-4909833996AE} = {AD870EB2-89A9-471C-A5CB-C95FA4D917BC} + {F76D206C-3F80-4099-B4ED-3DAE193303FC} = {00C31373-91B2-410A-A8B7-F66F7CD51708} EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C3AFAE1F-DDC9-4DB1-931D-1B934F9C9DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -245,5 +248,9 @@ Global {B5FA9C6D-5F8A-4334-985F-4909833996AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {B5FA9C6D-5F8A-4334-985F-4909833996AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {B5FA9C6D-5F8A-4334-985F-4909833996AE}.Release|Any CPU.Build.0 = Release|Any CPU + {F76D206C-3F80-4099-B4ED-3DAE193303FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F76D206C-3F80-4099-B4ED-3DAE193303FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F76D206C-3F80-4099-B4ED-3DAE193303FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F76D206C-3F80-4099-B4ED-3DAE193303FC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/Server.Controllers.Api.Grpc/Program.cs b/src/Server.Controllers.Api.Grpc/Program.cs index f9b84cd..bfddf9f 100644 --- a/src/Server.Controllers.Api.Grpc/Program.cs +++ b/src/Server.Controllers.Api.Grpc/Program.cs @@ -1,4 +1,6 @@ +using MadWorldNL.MantaRayPlan.Events; using MadWorldNL.MantaRayPlan.Extensions; +using MadWorldNL.MantaRayPlan.MassTransit; using MadWorldNL.MantaRayPlan.MessageBuses; using MadWorldNL.MantaRayPlan.OpenTelemetry; using MadWorldNL.MantaRayPlan.Services; @@ -22,7 +24,7 @@ { x.SetKebabCaseEndpointNameFormatter(); - x.AddConsumer>(); + x.AddConsumer>(); x.AddConsumer() .Endpoint(e => e.Name = GetName()); diff --git a/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs b/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs index f5df860..674d23a 100644 --- a/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs +++ b/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs @@ -2,7 +2,8 @@ using Google.Protobuf.WellKnownTypes; using Grpc.Core; using MadWorldNL.MantaRayPlan.Api; -using MadWorldNL.MantaRayPlan.Process; +using MadWorldNL.MantaRayPlan.Events; +using MadWorldNL.MantaRayPlan.MassTransit; namespace MadWorldNL.MantaRayPlan.Services; diff --git a/src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs b/src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs deleted file mode 100644 index 536714e..0000000 --- a/src/Server.Logic.Domain/MessageBuses/MessageBusStatusEvent.cs +++ /dev/null @@ -1,8 +0,0 @@ -using MadWorldNL.MantaRayPlan.Process; - -namespace MadWorldNL.MantaRayPlan.MessageBuses; - -public class MessageBusStatusEvent() : IEvent -{ - public int Count { get; set; } -} \ No newline at end of file diff --git a/src/Server.Logic.Domain/Process/IEvent.cs b/src/Server.Logic.Domain/Process/IEvent.cs deleted file mode 100644 index 8745cf8..0000000 --- a/src/Server.Logic.Domain/Process/IEvent.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace MadWorldNL.MantaRayPlan.Process; - -public interface IEvent -{ - -} \ No newline at end of file diff --git a/src/Server.Logic.Functions/Functions.csproj b/src/Server.Logic.Functions/Functions.csproj index 3139d29..71fc592 100644 --- a/src/Server.Logic.Functions/Functions.csproj +++ b/src/Server.Logic.Functions/Functions.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs b/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs index e5278b7..f6cb2bf 100644 --- a/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs +++ b/src/Server.Logic.Functions/MessageBuses/MessageBusStatusCommandConsumer.cs @@ -1,3 +1,4 @@ +using MadWorldNL.MantaRayPlan.Events; using MassTransit; namespace MadWorldNL.MantaRayPlan.MessageBuses; From 9cb8952282cde0564308b94e1b3df03dc7e834b0 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Fri, 27 Sep 2024 08:50:03 +0200 Subject: [PATCH 10/47] Send event to signalR --- src/Clients.Admin.Bff/Admin.Bff.csproj | 2 ++ .../Hubs/EventHandlerService.cs | 22 ++++++++++++++++++ src/Clients.Admin.Bff/Hubs/EventsHub.cs | 22 +++--------------- src/Clients.Admin.Bff/Program.cs | 23 +++++++++++++++++++ .../appsettings.Development.json | 6 +++++ src/Clients.Admin.Bff/appsettings.json | 6 +++++ src/Directory.Packages.props | 6 ++--- .../MassTransit}/MessageBusSettings.cs | 2 +- .../Program.cs | 1 + 9 files changed, 67 insertions(+), 23 deletions(-) create mode 100644 src/Clients.Admin.Bff/Hubs/EventHandlerService.cs rename src/{Server.Logic.Domain/MessageBuses => MadWorldNL.AspNetCore/MassTransit}/MessageBusSettings.cs (85%) diff --git a/src/Clients.Admin.Bff/Admin.Bff.csproj b/src/Clients.Admin.Bff/Admin.Bff.csproj index 196e6df..e79e633 100644 --- a/src/Clients.Admin.Bff/Admin.Bff.csproj +++ b/src/Clients.Admin.Bff/Admin.Bff.csproj @@ -8,6 +8,8 @@ + + diff --git a/src/Clients.Admin.Bff/Hubs/EventHandlerService.cs b/src/Clients.Admin.Bff/Hubs/EventHandlerService.cs new file mode 100644 index 0000000..4389d04 --- /dev/null +++ b/src/Clients.Admin.Bff/Hubs/EventHandlerService.cs @@ -0,0 +1,22 @@ +using MadWorldNL.MantaRayPlan.Events; +using MadWorldNL.MantaRayPlan.MassTransit; +using Microsoft.AspNetCore.SignalR; + +namespace MadWorldNL.MantaRayPlan.Hubs; + +public class EventHandlerService +{ + private readonly IHubContext _context; + + public EventHandlerService(IHubContext context) + { + _context = context; + + EventPublisher.OnMessageReceived += SendEventToClient; + } + + private void SendEventToClient(IEvent newEvent) + { + _context.Clients.All.SendAsync("NewEvent", newEvent); + } +} \ No newline at end of file diff --git a/src/Clients.Admin.Bff/Hubs/EventsHub.cs b/src/Clients.Admin.Bff/Hubs/EventsHub.cs index 4b216c4..f243fc4 100644 --- a/src/Clients.Admin.Bff/Hubs/EventsHub.cs +++ b/src/Clients.Admin.Bff/Hubs/EventsHub.cs @@ -1,25 +1,9 @@ -using MadWorldNL.MantaRayPlan.Events; -using MadWorldNL.MantaRayPlan.MassTransit; using Microsoft.AspNetCore.SignalR; +using SignalRSwaggerGen.Attributes; namespace MadWorldNL.MantaRayPlan.Hubs; -public class EventsHub : Hub +[SignalRHub] +public class EventsHub(EventHandlerService _) : Hub { - public EventsHub() - { - EventPublisher.OnMessageReceived += SendEventToClient; - } - - void SendEventToClient(IEvent newEvent) - { - - } - - public new void Dispose() - { - EventPublisher.OnMessageReceived -= SendEventToClient; - - base.Dispose(); - } } \ No newline at end of file diff --git a/src/Clients.Admin.Bff/Program.cs b/src/Clients.Admin.Bff/Program.cs index 938b1f4..6172957 100644 --- a/src/Clients.Admin.Bff/Program.cs +++ b/src/Clients.Admin.Bff/Program.cs @@ -2,8 +2,11 @@ using MadWorldNL.MantaRayPlan.Api; using MadWorldNL.MantaRayPlan.Configurations; using MadWorldNL.MantaRayPlan.Endpoints; +using MadWorldNL.MantaRayPlan.Events; using MadWorldNL.MantaRayPlan.Hubs; +using MadWorldNL.MantaRayPlan.MassTransit; using MadWorldNL.MantaRayPlan.OpenTelemetry; +using MassTransit; using Microsoft.AspNetCore.RateLimiting; var builder = WebApplication.CreateBuilder(args); @@ -14,6 +17,7 @@ builder.AddDefaultOpenTelemetry(openTelemetryConfig); builder.Services.AddSignalR(); +builder.Services.AddSingleton(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(options => @@ -23,6 +27,25 @@ builder.Services.AddHealthChecks(); +builder.Services.AddMassTransit(x => +{ + x.SetKebabCaseEndpointNameFormatter(); + + x.AddConsumer>(); + + x.UsingRabbitMq((context,cfg) => + { + var messageBusSettings = builder.Configuration.GetSection(MessageBusSettings.Key).Get()!; + + cfg.Host(messageBusSettings.Host, messageBusSettings.Port, "/", h => { + h.Username(messageBusSettings.Username); + h.Password(messageBusSettings.Password); + }); + + cfg.ConfigureEndpoints(context); + }); +}); + var apiSettingsSection = builder.Configuration.GetSection(ApiSettings.Key); builder.Services.AddOptions() .Bind(apiSettingsSection) diff --git a/src/Clients.Admin.Bff/appsettings.Development.json b/src/Clients.Admin.Bff/appsettings.Development.json index 7e33399..4829981 100644 --- a/src/Clients.Admin.Bff/appsettings.Development.json +++ b/src/Clients.Admin.Bff/appsettings.Development.json @@ -12,5 +12,11 @@ "Application": "Admin.Bff", "LoggerEndpoint": "http://localhost:5341", "LoggerApiKey": "" + }, + "MessageBus": { + "Host": "localhost", + "Port": 5672, + "Username": "development", + "Password": "Secret1234" } } diff --git a/src/Clients.Admin.Bff/appsettings.json b/src/Clients.Admin.Bff/appsettings.json index cc1ddc7..7d60c8d 100644 --- a/src/Clients.Admin.Bff/appsettings.json +++ b/src/Clients.Admin.Bff/appsettings.json @@ -13,5 +13,11 @@ "Application": "Admin.Bff", "LoggerEndpoint": "http://localhost:5341", "LoggerApiKey": "" + }, + "MessageBus": { + "Host": "localhost", + "Port": 5672, + "Username": "development", + "Password": "Secret1234" } } diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 728ebe8..ba8714e 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -25,9 +25,9 @@ - + - + @@ -36,7 +36,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all diff --git a/src/Server.Logic.Domain/MessageBuses/MessageBusSettings.cs b/src/MadWorldNL.AspNetCore/MassTransit/MessageBusSettings.cs similarity index 85% rename from src/Server.Logic.Domain/MessageBuses/MessageBusSettings.cs rename to src/MadWorldNL.AspNetCore/MassTransit/MessageBusSettings.cs index 53171d2..b0b3d91 100644 --- a/src/Server.Logic.Domain/MessageBuses/MessageBusSettings.cs +++ b/src/MadWorldNL.AspNetCore/MassTransit/MessageBusSettings.cs @@ -1,4 +1,4 @@ -namespace MadWorldNL.MantaRayPlan.MessageBuses; +namespace MadWorldNL.MantaRayPlan.MassTransit; public class MessageBusSettings { diff --git a/src/Server.Controllers.Api.MessageBus/Program.cs b/src/Server.Controllers.Api.MessageBus/Program.cs index 9142845..1e53942 100644 --- a/src/Server.Controllers.Api.MessageBus/Program.cs +++ b/src/Server.Controllers.Api.MessageBus/Program.cs @@ -2,6 +2,7 @@ using MadWorldNL.MantaRayPlan; using MadWorldNL.MantaRayPlan.Extensions; +using MadWorldNL.MantaRayPlan.MassTransit; using MadWorldNL.MantaRayPlan.MessageBuses; using MadWorldNL.MantaRayPlan.OpenTelemetry; using MassTransit; From e7b3aeb2dce5bda8861ffb839c9ab26c1e604672 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Fri, 27 Sep 2024 13:30:15 +0200 Subject: [PATCH 11/47] Finish events to web socket. Only frontend left --- src/Clients.Admin.Bff/Hubs/EventHandlerService.cs | 8 +++++++- src/Clients.Admin.Bff/Program.cs | 7 +++++++ .../MassTransit/EventPusherConsumer.cs | 2 ++ src/Server.Controllers.Api.Grpc/Program.cs | 7 +++++++ src/Server.Controllers.Api.MessageBus/Program.cs | 2 ++ src/docker-compose.env | 0 6 files changed, 25 insertions(+), 1 deletion(-) delete mode 100644 src/docker-compose.env diff --git a/src/Clients.Admin.Bff/Hubs/EventHandlerService.cs b/src/Clients.Admin.Bff/Hubs/EventHandlerService.cs index 4389d04..9a68fb5 100644 --- a/src/Clients.Admin.Bff/Hubs/EventHandlerService.cs +++ b/src/Clients.Admin.Bff/Hubs/EventHandlerService.cs @@ -4,7 +4,7 @@ namespace MadWorldNL.MantaRayPlan.Hubs; -public class EventHandlerService +public sealed class EventHandlerService : IDisposable { private readonly IHubContext _context; @@ -19,4 +19,10 @@ private void SendEventToClient(IEvent newEvent) { _context.Clients.All.SendAsync("NewEvent", newEvent); } + + public void Dispose() + { + EventPublisher.OnMessageReceived -= SendEventToClient; + GC.SuppressFinalize(this); + } } \ No newline at end of file diff --git a/src/Clients.Admin.Bff/Program.cs b/src/Clients.Admin.Bff/Program.cs index 6172957..e9be4da 100644 --- a/src/Clients.Admin.Bff/Program.cs +++ b/src/Clients.Admin.Bff/Program.cs @@ -41,6 +41,13 @@ h.Username(messageBusSettings.Username); h.Password(messageBusSettings.Password); }); + + var appName = typeof(Program).Assembly.GetName().Name!; + cfg.ReceiveEndpoint(EventPusherConsumer.GetQueueName(appName, nameof(MessageBusStatusEvent)), + e => + { + e.ConfigureConsumer>(context); + }); cfg.ConfigureEndpoints(context); }); diff --git a/src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs b/src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs index 389eb85..fb82a9c 100644 --- a/src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs +++ b/src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs @@ -11,4 +11,6 @@ public Task Consume(ConsumeContext context) return Task.CompletedTask; } + + public static string GetQueueName(string backend, string messageType) => $"{backend}_{nameof(EventPusherConsumer)}_{messageType}"; } \ No newline at end of file diff --git a/src/Server.Controllers.Api.Grpc/Program.cs b/src/Server.Controllers.Api.Grpc/Program.cs index bfddf9f..9e8ae21 100644 --- a/src/Server.Controllers.Api.Grpc/Program.cs +++ b/src/Server.Controllers.Api.Grpc/Program.cs @@ -41,6 +41,13 @@ h.Password(messageBusSettings.Password); }); + var appName = typeof(Program).Assembly.GetName().Name!; + cfg.ReceiveEndpoint(EventPusherConsumer.GetQueueName(appName, nameof(MessageBusStatusEvent)), + e => + { + e.ConfigureConsumer>(context); + }); + cfg.ConfigureEndpoints(context); EndpointConvention.Map(new Uri(GetExchangeName())); diff --git a/src/Server.Controllers.Api.MessageBus/Program.cs b/src/Server.Controllers.Api.MessageBus/Program.cs index 1e53942..a2ce57a 100644 --- a/src/Server.Controllers.Api.MessageBus/Program.cs +++ b/src/Server.Controllers.Api.MessageBus/Program.cs @@ -1,11 +1,13 @@ // See https://aka.ms/new-console-template for more information using MadWorldNL.MantaRayPlan; +using MadWorldNL.MantaRayPlan.Events; using MadWorldNL.MantaRayPlan.Extensions; using MadWorldNL.MantaRayPlan.MassTransit; using MadWorldNL.MantaRayPlan.MessageBuses; using MadWorldNL.MantaRayPlan.OpenTelemetry; using MassTransit; +using MassTransit.Transports.Fabric; var builder = WebApplication.CreateBuilder(); diff --git a/src/docker-compose.env b/src/docker-compose.env deleted file mode 100644 index e69de29..0000000 From 0f8ecebac98d5116077a57e7adfaadb13725e83b Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Fri, 27 Sep 2024 21:20:50 +0200 Subject: [PATCH 12/47] Start with test page --- src/Clients.Admin.Web/Admin.Web.csproj | 1 + .../Pages/MessageBuses/MessageBus.razor | 18 ++++++++++++++++++ src/Clients.Admin.Web/Program.cs | 3 +++ .../MessageBuses/IMessageBusService.cs | 9 +++++++++ .../Services/MessageBuses/MessageBusService.cs | 16 ++++++++++++++++ 5 files changed, 47 insertions(+) create mode 100644 src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor create mode 100644 src/Clients.Admin.Web/Services/MessageBuses/IMessageBusService.cs create mode 100644 src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs diff --git a/src/Clients.Admin.Web/Admin.Web.csproj b/src/Clients.Admin.Web/Admin.Web.csproj index 31b6d38..a7a2bd3 100644 --- a/src/Clients.Admin.Web/Admin.Web.csproj +++ b/src/Clients.Admin.Web/Admin.Web.csproj @@ -20,6 +20,7 @@ + diff --git a/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor b/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor new file mode 100644 index 0000000..7632572 --- /dev/null +++ b/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor @@ -0,0 +1,18 @@ +@using MadWorldNL.MantaRayPlan.Web.Services.MessageBuses +@page "/MessageBus" + +@inject IMessageBusService Service; + +Status counter: @_counter + +@code { + private int _counter = 0; + + protected override Task OnInitializedAsync() + { + var status = Service.GetStatus(); + _counter = status.counter; + + return base.OnInitializedAsync(); + } +} \ No newline at end of file diff --git a/src/Clients.Admin.Web/Program.cs b/src/Clients.Admin.Web/Program.cs index 45f4973..9410949 100644 --- a/src/Clients.Admin.Web/Program.cs +++ b/src/Clients.Admin.Web/Program.cs @@ -1,4 +1,5 @@ using MadWorldNL.MantaRayPlan.Web; +using MadWorldNL.MantaRayPlan.Web.Services.MessageBuses; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; @@ -8,4 +9,6 @@ builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); +builder.Services.AddScoped(); + await builder.Build().RunAsync(); \ No newline at end of file diff --git a/src/Clients.Admin.Web/Services/MessageBuses/IMessageBusService.cs b/src/Clients.Admin.Web/Services/MessageBuses/IMessageBusService.cs new file mode 100644 index 0000000..d8c4a3d --- /dev/null +++ b/src/Clients.Admin.Web/Services/MessageBuses/IMessageBusService.cs @@ -0,0 +1,9 @@ +using MadWorldNL.MantaRayPlan.MessageBuses; + +namespace MadWorldNL.MantaRayPlan.Web.Services.MessageBuses; + +public interface IMessageBusService +{ + GetStatusResponse GetStatus(); + PostStatusResponse PostNewStatus(); +} \ No newline at end of file diff --git a/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs b/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs new file mode 100644 index 0000000..9940a33 --- /dev/null +++ b/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs @@ -0,0 +1,16 @@ +using MadWorldNL.MantaRayPlan.MessageBuses; + +namespace MadWorldNL.MantaRayPlan.Web.Services.MessageBuses; + +public class MessageBusService : IMessageBusService +{ + public GetStatusResponse GetStatus() + { + return new GetStatusResponse("", 10); + } + + public PostStatusResponse PostNewStatus() + { + return new PostStatusResponse(""); + } +} \ No newline at end of file From 58fa744a5c17a6ad7fe200ee085c8ad3e05ee444 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 28 Sep 2024 11:21:12 +0200 Subject: [PATCH 13/47] Add get request in the admin frontend --- src/Clients.Admin.Bff/Program.cs | 14 ++++++++++++++ src/Clients.Admin.Web/Admin.Web.csproj | 1 + .../Configurations/ApiSettings.cs | 8 ++++++++ src/Clients.Admin.Web/Configurations/ApiTypes.cs | 6 ++++++ .../Pages/MessageBuses/MessageBus.razor | 14 ++++++++++---- src/Clients.Admin.Web/Program.cs | 11 +++++++++++ .../Services/MessageBuses/IMessageBusService.cs | 4 ++-- .../Services/MessageBuses/MessageBusService.cs | 16 ++++++++++++---- src/Clients.Admin.Web/wwwroot/appsettings.json | 5 +++++ src/Clients.Viewer.Bff/Program.cs | 15 +++++++++++++++ src/Directory.Packages.props | 1 + src/Server.Controllers.Api.Grpc/Program.cs | 14 ++++++++++++++ src/Server.Controllers.Api.MessageBus/Program.cs | 15 +++++++++++++-- 13 files changed, 112 insertions(+), 12 deletions(-) create mode 100644 src/Clients.Admin.Web/Configurations/ApiSettings.cs create mode 100644 src/Clients.Admin.Web/Configurations/ApiTypes.cs create mode 100644 src/Clients.Admin.Web/wwwroot/appsettings.json diff --git a/src/Clients.Admin.Bff/Program.cs b/src/Clients.Admin.Bff/Program.cs index e9be4da..1393321 100644 --- a/src/Clients.Admin.Bff/Program.cs +++ b/src/Clients.Admin.Bff/Program.cs @@ -9,8 +9,21 @@ using MassTransit; using Microsoft.AspNetCore.RateLimiting; +const string corsName = "DefaultCors"; + var builder = WebApplication.CreateBuilder(args); +builder.Services.AddCors(options => +{ + options.AddPolicy(name: corsName, + policy => + { + policy.AllowAnyHeader(); + policy.AllowAnyMethod(); + policy.AllowAnyOrigin(); + }); +}); + var openTelemetryConfig = builder.Configuration.GetSection(OpenTelemetryConfig.Key).Get() ?? new OpenTelemetryConfig(); @@ -76,6 +89,7 @@ var app = builder.Build(); +app.UseCors(corsName); app.UseRateLimiter(); // Security Headers diff --git a/src/Clients.Admin.Web/Admin.Web.csproj b/src/Clients.Admin.Web/Admin.Web.csproj index a7a2bd3..9d54c4b 100644 --- a/src/Clients.Admin.Web/Admin.Web.csproj +++ b/src/Clients.Admin.Web/Admin.Web.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Clients.Admin.Web/Configurations/ApiSettings.cs b/src/Clients.Admin.Web/Configurations/ApiSettings.cs new file mode 100644 index 0000000..1b9a5eb --- /dev/null +++ b/src/Clients.Admin.Web/Configurations/ApiSettings.cs @@ -0,0 +1,8 @@ +namespace MadWorldNL.MantaRayPlan.Web.Configurations; + +public class ApiSettings +{ + public const string Key = "Api"; + + public string Address { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/src/Clients.Admin.Web/Configurations/ApiTypes.cs b/src/Clients.Admin.Web/Configurations/ApiTypes.cs new file mode 100644 index 0000000..9bc1dd2 --- /dev/null +++ b/src/Clients.Admin.Web/Configurations/ApiTypes.cs @@ -0,0 +1,6 @@ +namespace MadWorldNL.MantaRayPlan.Web.Configurations; + +public class ApiTypes +{ + public const string AdminBff = nameof(AdminBff); +} \ No newline at end of file diff --git a/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor b/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor index 7632572..589a296 100644 --- a/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor +++ b/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor @@ -3,16 +3,22 @@ @inject IMessageBusService Service; -Status counter: @_counter +

Message Bus Test Page

+@if (_isLoaded) +{ +

status counter: @_counter

+} @code { + private bool _isLoaded; private int _counter = 0; - protected override Task OnInitializedAsync() + protected override async Task OnInitializedAsync() { - var status = Service.GetStatus(); + var status = await Service.GetStatusAsync(); _counter = status.counter; + _isLoaded = true; - return base.OnInitializedAsync(); + await base.OnInitializedAsync(); } } \ No newline at end of file diff --git a/src/Clients.Admin.Web/Program.cs b/src/Clients.Admin.Web/Program.cs index 9410949..5b747ef 100644 --- a/src/Clients.Admin.Web/Program.cs +++ b/src/Clients.Admin.Web/Program.cs @@ -1,13 +1,24 @@ using MadWorldNL.MantaRayPlan.Web; +using MadWorldNL.MantaRayPlan.Web.Configurations; using MadWorldNL.MantaRayPlan.Web.Services.MessageBuses; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.Extensions.Options; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); +builder.Services + .AddOptions() + .Configure(builder.Configuration.GetSection(ApiSettings.Key).Bind); + builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); +builder.Services.AddHttpClient(ApiTypes.AdminBff, (serviceProvider, client) => + { + var apiUrlsOption = serviceProvider.GetService>()!; + client.BaseAddress = new Uri(apiUrlsOption.Value.Address); + }); builder.Services.AddScoped(); diff --git a/src/Clients.Admin.Web/Services/MessageBuses/IMessageBusService.cs b/src/Clients.Admin.Web/Services/MessageBuses/IMessageBusService.cs index d8c4a3d..17778fc 100644 --- a/src/Clients.Admin.Web/Services/MessageBuses/IMessageBusService.cs +++ b/src/Clients.Admin.Web/Services/MessageBuses/IMessageBusService.cs @@ -4,6 +4,6 @@ namespace MadWorldNL.MantaRayPlan.Web.Services.MessageBuses; public interface IMessageBusService { - GetStatusResponse GetStatus(); - PostStatusResponse PostNewStatus(); + Task GetStatusAsync(); + Task PostNewStatusAsync(); } \ No newline at end of file diff --git a/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs b/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs index 9940a33..52838ce 100644 --- a/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs +++ b/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs @@ -1,15 +1,23 @@ +using System.Net.Http.Json; using MadWorldNL.MantaRayPlan.MessageBuses; +using MadWorldNL.MantaRayPlan.Web.Configurations; namespace MadWorldNL.MantaRayPlan.Web.Services.MessageBuses; -public class MessageBusService : IMessageBusService +public class MessageBusService(IHttpClientFactory clientFactory) : IMessageBusService { - public GetStatusResponse GetStatus() + private const string EndpointSingular = "MessageBus"; + + private readonly HttpClient _client = clientFactory.CreateClient(ApiTypes.AdminBff); + + public async Task GetStatusAsync() { - return new GetStatusResponse("", 10); + const int emptyCounter = -1; + + return await _client.GetFromJsonAsync($"{EndpointSingular}/Status") ?? new GetStatusResponse("No response", emptyCounter); } - public PostStatusResponse PostNewStatus() + public async Task PostNewStatusAsync() { return new PostStatusResponse(""); } diff --git a/src/Clients.Admin.Web/wwwroot/appsettings.json b/src/Clients.Admin.Web/wwwroot/appsettings.json new file mode 100644 index 0000000..23d6c3c --- /dev/null +++ b/src/Clients.Admin.Web/wwwroot/appsettings.json @@ -0,0 +1,5 @@ +{ + "Api": { + "Address": "https://localhost:7284/" + } +} \ No newline at end of file diff --git a/src/Clients.Viewer.Bff/Program.cs b/src/Clients.Viewer.Bff/Program.cs index a740158..e90b93a 100644 --- a/src/Clients.Viewer.Bff/Program.cs +++ b/src/Clients.Viewer.Bff/Program.cs @@ -4,8 +4,22 @@ using MadWorldNL.MantaRayPlan.OpenTelemetry; using Microsoft.AspNetCore.RateLimiting; +const string corsName = "DefaultCors"; + var builder = WebApplication.CreateBuilder(args); +builder.Services.AddCors(options => +{ + options.AddPolicy(name: corsName, + policy => + { + policy.AllowAnyHeader(); + policy.AllowAnyMethod(); + policy.AllowAnyOrigin(); + }); +}); + + var openTelemetryConfig = builder.Configuration.GetSection(OpenTelemetryConfig.Key).Get() ?? new OpenTelemetryConfig(); @@ -27,6 +41,7 @@ var app = builder.Build(); +app.UseCors(corsName); app.UseRateLimiter(); // Security Headers diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index ba8714e..7fa270e 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -14,6 +14,7 @@ + diff --git a/src/Server.Controllers.Api.Grpc/Program.cs b/src/Server.Controllers.Api.Grpc/Program.cs index 9e8ae21..0b51aad 100644 --- a/src/Server.Controllers.Api.Grpc/Program.cs +++ b/src/Server.Controllers.Api.Grpc/Program.cs @@ -6,8 +6,21 @@ using MadWorldNL.MantaRayPlan.Services; using MassTransit; +const string corsName = "DefaultCors"; + var builder = WebApplication.CreateBuilder(args); +builder.Services.AddCors(options => +{ + options.AddPolicy(name: corsName, + policy => + { + policy.AllowAnyHeader(); + policy.AllowAnyMethod(); + policy.AllowAnyOrigin(); + }); +}); + var openTelemetryConfig = builder.Configuration.GetSection(OpenTelemetryConfig.Key).Get() ?? new OpenTelemetryConfig(); @@ -55,6 +68,7 @@ }); var app = builder.Build(); +app.UseCors(corsName); app.MapGrpcService(); app.MapGrpcService(); diff --git a/src/Server.Controllers.Api.MessageBus/Program.cs b/src/Server.Controllers.Api.MessageBus/Program.cs index a2ce57a..2f2cac0 100644 --- a/src/Server.Controllers.Api.MessageBus/Program.cs +++ b/src/Server.Controllers.Api.MessageBus/Program.cs @@ -1,16 +1,27 @@ // See https://aka.ms/new-console-template for more information using MadWorldNL.MantaRayPlan; -using MadWorldNL.MantaRayPlan.Events; using MadWorldNL.MantaRayPlan.Extensions; using MadWorldNL.MantaRayPlan.MassTransit; using MadWorldNL.MantaRayPlan.MessageBuses; using MadWorldNL.MantaRayPlan.OpenTelemetry; using MassTransit; -using MassTransit.Transports.Fabric; + +const string corsName = "DefaultCors"; var builder = WebApplication.CreateBuilder(); +builder.Services.AddCors(options => +{ + options.AddPolicy(name: corsName, + policy => + { + policy.AllowAnyHeader(); + policy.AllowAnyMethod(); + policy.AllowAnyOrigin(); + }); +}); + var openTelemetryConfig = builder.Configuration.GetSection(OpenTelemetryConfig.Key).Get() ?? new OpenTelemetryConfig(); From 964fa56b3401619aaeead54fbf5b0306c1049036 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 28 Sep 2024 12:08:05 +0200 Subject: [PATCH 14/47] Set post request in admin --- .../Pages/MessageBuses/MessageBus.razor | 10 ++++++++++ .../Services/MessageBuses/MessageBusService.cs | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor b/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor index 589a296..1dcacf9 100644 --- a/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor +++ b/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor @@ -7,6 +7,11 @@ @if (_isLoaded) {

status counter: @_counter

+

+ +

} @code { @@ -21,4 +26,9 @@ await base.OnInitializedAsync(); } + + private async Task UpdateStatus() + { + await Service.PostNewStatusAsync(); + } } \ No newline at end of file diff --git a/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs b/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs index 52838ce..02b5563 100644 --- a/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs +++ b/src/Clients.Admin.Web/Services/MessageBuses/MessageBusService.cs @@ -19,6 +19,13 @@ public async Task GetStatusAsync() public async Task PostNewStatusAsync() { - return new PostStatusResponse(""); + var response = await _client.PostAsJsonAsync($"{EndpointSingular}/Status", "{}"); + + if (response.IsSuccessStatusCode) + { + return await response.Content.ReadFromJsonAsync() ?? new PostStatusResponse("No Response"); + } + + return new PostStatusResponse("IsFailedStatusCode"); } } \ No newline at end of file From 0a1a715e8b3673c3c08dce8e1d570fda0a89dc41 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 29 Sep 2024 08:23:50 +0200 Subject: [PATCH 15/47] Add SignalR --- src/Clients.Admin.Web/Admin.Web.csproj | 2 + .../Pages/MessageBuses/MessageBus.razor | 20 +++++++-- src/Clients.Admin.Web/Program.cs | 2 + .../Services/Events/EventsService.cs | 45 +++++++++++++++++++ src/Directory.Packages.props | 1 + .../MessageBuses/MessageBusStatus.cs | 7 ++- 6 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 src/Clients.Admin.Web/Services/Events/EventsService.cs diff --git a/src/Clients.Admin.Web/Admin.Web.csproj b/src/Clients.Admin.Web/Admin.Web.csproj index 9d54c4b..6530570 100644 --- a/src/Clients.Admin.Web/Admin.Web.csproj +++ b/src/Clients.Admin.Web/Admin.Web.csproj @@ -10,6 +10,7 @@ + @@ -22,6 +23,7 @@ + diff --git a/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor b/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor index 1dcacf9..b16bbef 100644 --- a/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor +++ b/src/Clients.Admin.Web/Pages/MessageBuses/MessageBus.razor @@ -1,7 +1,10 @@ +@using MadWorldNL.MantaRayPlan.Events +@using MadWorldNL.MantaRayPlan.Web.Services.Events @using MadWorldNL.MantaRayPlan.Web.Services.MessageBuses @page "/MessageBus" -@inject IMessageBusService Service; +@inject IMessageBusService MessageBusService; +@inject EventsService EventsService

Message Bus Test Page

@if (_isLoaded) @@ -16,19 +19,28 @@ @code { private bool _isLoaded; - private int _counter = 0; + private int _counter; protected override async Task OnInitializedAsync() { - var status = await Service.GetStatusAsync(); + var status = await MessageBusService.GetStatusAsync(); _counter = status.counter; _isLoaded = true; + + EventsService.EventReceived += NewEventReceived; + await EventsService.StartAsync(); await base.OnInitializedAsync(); } + private void NewEventReceived(MessageBusStatusEvent @event) + { + _counter = @event.Count; + StateHasChanged(); + } + private async Task UpdateStatus() { - await Service.PostNewStatusAsync(); + await MessageBusService.PostNewStatusAsync(); } } \ No newline at end of file diff --git a/src/Clients.Admin.Web/Program.cs b/src/Clients.Admin.Web/Program.cs index 5b747ef..5d3fad4 100644 --- a/src/Clients.Admin.Web/Program.cs +++ b/src/Clients.Admin.Web/Program.cs @@ -1,5 +1,6 @@ using MadWorldNL.MantaRayPlan.Web; using MadWorldNL.MantaRayPlan.Web.Configurations; +using MadWorldNL.MantaRayPlan.Web.Services.Events; using MadWorldNL.MantaRayPlan.Web.Services.MessageBuses; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; @@ -21,5 +22,6 @@ }); builder.Services.AddScoped(); +builder.Services.AddSingleton(); await builder.Build().RunAsync(); \ No newline at end of file diff --git a/src/Clients.Admin.Web/Services/Events/EventsService.cs b/src/Clients.Admin.Web/Services/Events/EventsService.cs new file mode 100644 index 0000000..2a5d4da --- /dev/null +++ b/src/Clients.Admin.Web/Services/Events/EventsService.cs @@ -0,0 +1,45 @@ +using MadWorldNL.MantaRayPlan.Events; +using MadWorldNL.MantaRayPlan.Web.Configurations; +using Microsoft.AspNetCore.SignalR.Client; +using Microsoft.Extensions.Options; + +namespace MadWorldNL.MantaRayPlan.Web.Services.Events; + +public class EventsService : IAsyncDisposable +{ + private bool _isStarted; + private readonly HubConnection _hubConnection; + + public event Action? EventReceived; + + public EventsService(IOptions settings) + { + _hubConnection = new HubConnectionBuilder() + .WithUrl($"{settings.Value.Address}Events") + .Build(); + + _hubConnection.On("NewEvent", (@event) => + { + EventReceived?.Invoke(@event); + }); + } + + public Task StartAsync() + { + if (_isStarted) + { + return Task.CompletedTask; + } + + _isStarted = true; + return _hubConnection.StartAsync(); + } + + public async ValueTask DisposeAsync() + { + await _hubConnection.StopAsync(); + await _hubConnection.DisposeAsync(); + + GC.SuppressFinalize(this); + } +} \ No newline at end of file diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 7fa270e..f505402 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -9,6 +9,7 @@ + diff --git a/src/Server.Logic.Domain/MessageBuses/MessageBusStatus.cs b/src/Server.Logic.Domain/MessageBuses/MessageBusStatus.cs index 62a4751..fa35695 100644 --- a/src/Server.Logic.Domain/MessageBuses/MessageBusStatus.cs +++ b/src/Server.Logic.Domain/MessageBuses/MessageBusStatus.cs @@ -2,11 +2,16 @@ namespace MadWorldNL.MantaRayPlan.MessageBuses; public class MessageBusStatus { - public int Id { get; set; } + public int Id { get; init; } public int Count { get; set; } public void IncrementCount() { + if (Count >= int.MaxValue) + { + Count = 0; + } + Count++; } } \ No newline at end of file From e410222ca74f9c23702671ece3c11b751c47c612 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 29 Sep 2024 11:09:13 +0200 Subject: [PATCH 16/47] Fix docker compose to start up message bus status test --- src/MadWorldNL.MantaRayPlan.sln | 1 - src/docker-compose.yml | 14 ++++++++++++++ src/docker/Clients.Admin.Web/appsettings.json | 5 +++++ src/docker/Clients.Admin.Web/default.conf | 8 ++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/docker/Clients.Admin.Web/appsettings.json create mode 100644 src/docker/Clients.Admin.Web/default.conf diff --git a/src/MadWorldNL.MantaRayPlan.sln b/src/MadWorldNL.MantaRayPlan.sln index 2768202..ed7ae5c 100644 --- a/src/MadWorldNL.MantaRayPlan.sln +++ b/src/MadWorldNL.MantaRayPlan.sln @@ -72,7 +72,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "code", "code", "{941D883C-3 ProjectSection(SolutionItems) = preProject Directory.Build.props = Directory.Build.props Directory.Packages.props = Directory.Packages.props - docker-compose.env = docker-compose.env docker-compose.yml = docker-compose.yml Nuget.Config = Nuget.Config EndProjectSection diff --git a/src/docker-compose.yml b/src/docker-compose.yml index 83a46d7..d3d636e 100644 --- a/src/docker-compose.yml +++ b/src/docker-compose.yml @@ -7,12 +7,18 @@ services: build: context: . dockerfile: Clients.Admin.Bff/Dockerfile + depends_on: + messagebus: + condition: service_healthy environment: + - Api__Address=http://api-grpc:8080 - OpenTelemetry__LoggerEndpoint=http://seq:5341 + - MessageBus__Host=messagebus ports: - "8080:8080" - "8081:8081" networks: + - messagebus - seq admin-web: image: ghcr.io/madworldnl/mantarayplan-admin-web:latest @@ -24,6 +30,9 @@ services: ports: - "8082:80" - "8083:443" + volumes: + - ./docker/Clients.Admin.Web/appsettings.json:/usr/share/nginx/html/appsettings.json + - ./docker/Clients.Admin.Web/default.conf:/etc/nginx/conf.d/default.conf api-grpc: image: ghcr.io/madworldnl/mantarayplan-api-grpc:latest container_name: api-grpc @@ -39,6 +48,7 @@ services: environment: - Database__Host=postgres - OpenTelemetry__LoggerEndpoint=http://seq:5341 + - MessageBus__Host=messagebus ports: - "8084:8080" - "8085:8081" @@ -61,6 +71,7 @@ services: environment: - Database__Host=postgres - OpenTelemetry__LoggerEndpoint=http://seq:5341 + - MessageBus__Host=messagebus ports: - "8086:8080" - "8087:8081" @@ -76,11 +87,14 @@ services: context: . dockerfile: Clients.Viewer.Bff/Dockerfile environment: + - Api__Address=http://api-grpc:8084 - OpenTelemetry__LoggerEndpoint=http://seq:5341 + - MessageBus__Host=messagebus ports: - "8088:8080" - "8089:8081" networks: + - messagebus - seq viewer-web: image: ghcr.io/madworldnl/mantarayplan-viewer-web:latest diff --git a/src/docker/Clients.Admin.Web/appsettings.json b/src/docker/Clients.Admin.Web/appsettings.json new file mode 100644 index 0000000..72d7dab --- /dev/null +++ b/src/docker/Clients.Admin.Web/appsettings.json @@ -0,0 +1,5 @@ +{ + "Api": { + "Address": "http://localhost:8080/" + } + } \ No newline at end of file diff --git a/src/docker/Clients.Admin.Web/default.conf b/src/docker/Clients.Admin.Web/default.conf new file mode 100644 index 0000000..13cd2af --- /dev/null +++ b/src/docker/Clients.Admin.Web/default.conf @@ -0,0 +1,8 @@ +server { + listen 80; + + location / { + root /usr/share/nginx/html; + try_files $uri $uri/ /index.html =404; + } +} \ No newline at end of file From ddfe0c7bfb85b1f6e2ed3531f686801f30b9942d Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 29 Sep 2024 11:21:02 +0200 Subject: [PATCH 17/47] Refactor csproj files --- src/ClientSdk.Admin.Bff/ClientSdk.Admin.Bff.csproj | 3 +-- src/ClientSdk.Api.Grpc/ClientSdk.Api.Grpc.csproj | 1 + src/ClientSdk.Api.MessageBus/ClientSdk.Api.MessageBus.csproj | 3 +-- src/MadWorldNL.AspNetCore/MadWorldNL.AspNetCore.csproj | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ClientSdk.Admin.Bff/ClientSdk.Admin.Bff.csproj b/src/ClientSdk.Admin.Bff/ClientSdk.Admin.Bff.csproj index 3a63532..9da90f1 100644 --- a/src/ClientSdk.Admin.Bff/ClientSdk.Admin.Bff.csproj +++ b/src/ClientSdk.Admin.Bff/ClientSdk.Admin.Bff.csproj @@ -2,8 +2,7 @@ net8.0 - enable - enable + MadWorldNL.MantaRayPlan.ClientSdk.Admin.Bff
diff --git a/src/ClientSdk.Api.Grpc/ClientSdk.Api.Grpc.csproj b/src/ClientSdk.Api.Grpc/ClientSdk.Api.Grpc.csproj index 77a2068..849f536 100644 --- a/src/ClientSdk.Api.Grpc/ClientSdk.Api.Grpc.csproj +++ b/src/ClientSdk.Api.Grpc/ClientSdk.Api.Grpc.csproj @@ -2,6 +2,7 @@ net8.0 + MadWorldNL.MantaRayPlan.ClientSdk.Api.Grpc diff --git a/src/ClientSdk.Api.MessageBus/ClientSdk.Api.MessageBus.csproj b/src/ClientSdk.Api.MessageBus/ClientSdk.Api.MessageBus.csproj index 3a63532..9e12404 100644 --- a/src/ClientSdk.Api.MessageBus/ClientSdk.Api.MessageBus.csproj +++ b/src/ClientSdk.Api.MessageBus/ClientSdk.Api.MessageBus.csproj @@ -2,8 +2,7 @@ net8.0 - enable - enable + MadWorldNL.MantaRayPlan.ClientSdk.Api.MessageBus diff --git a/src/MadWorldNL.AspNetCore/MadWorldNL.AspNetCore.csproj b/src/MadWorldNL.AspNetCore/MadWorldNL.AspNetCore.csproj index 2ac3383..17dcc99 100644 --- a/src/MadWorldNL.AspNetCore/MadWorldNL.AspNetCore.csproj +++ b/src/MadWorldNL.AspNetCore/MadWorldNL.AspNetCore.csproj @@ -2,8 +2,7 @@ net8.0 - enable - enable + MadWorldNL.MantaRayPlan.AspNetCore From 7dc22e67544707d29eb4363c8fe65c958fcc332b Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 29 Sep 2024 11:56:30 +0200 Subject: [PATCH 18/47] Update nuget packages --- src/Directory.Packages.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index f505402..cf8000b 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -17,7 +17,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -39,7 +39,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 1a34f1a8ee88375712b7bb3085197eb7ef023eb9 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 29 Sep 2024 12:37:03 +0200 Subject: [PATCH 19/47] Update Readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cfa957..52e397d 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,8 @@ docker compose up *This project is required to set as startup project -`dotnet workload restore` is required to install the necessary workloads for the project. You don't need to run this command if you have already installed the workloads. +`dotnet workload restore` is required to install the necessary workloads for the project. However, when you download a new update, +it may be necessary to run this command to ensure all workloads are up to date. ### Running the tests Before running the tests, ensure Docker is up and running. From 50e2ed47f7fe5b737bcb2a0bb2a0a4138477f183 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 29 Sep 2024 15:58:15 +0200 Subject: [PATCH 20/47] Start with kubernetes --- .../templates/admin-bff.yaml | 14 ++- .../MantaRayPlanCloud/templates/api-grpc.yaml | 14 ++- .../templates/api-message-bus.yaml | 12 ++ .../templates/messagebus.yaml | 117 ++++++++++++++++++ .../templates/viewer-bff.yaml | 14 ++- deployment/MantaRayPlanCloud/values.yaml | 11 ++ 6 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 deployment/MantaRayPlanCloud/templates/messagebus.yaml diff --git a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml index 2c1000f..dfcebf5 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml @@ -37,7 +37,19 @@ spec: valueFrom: secretKeyRef: name: {{ .Values.logging.seq.secrets.name }} - key: apiKeyAdmin + key: apiKeyAdmin + - name: MessageBus__Host + value: {{ .Values.messageBus.loadBalancer }} + - name: MessageBus__Username + valueFrom: + secretKeyRef: + name: {{ .Values.messageBus.secret.name }} + key: username + - name: MessageBus__Password + valueFrom: + secretKeyRef: + name: {{ .Values.messageBus.secret.name }} + key: password ports: - containerPort: 8080 --- diff --git a/deployment/MantaRayPlanCloud/templates/api-grpc.yaml b/deployment/MantaRayPlanCloud/templates/api-grpc.yaml index 044a3f6..8703365 100644 --- a/deployment/MantaRayPlanCloud/templates/api-grpc.yaml +++ b/deployment/MantaRayPlanCloud/templates/api-grpc.yaml @@ -55,7 +55,19 @@ spec: name: {{ .Values.logging.seq.secrets.name }} key: apiKeyGrpc - name: Kestrel__EndpointDefaults__Protocols - value: "Http1AndHttp2" + value: "Http1AndHttp2" + - name: MessageBus__Host + value: {{ .Values.messageBus.loadBalancer }} + - name: MessageBus__Username + valueFrom: + secretKeyRef: + name: {{ .Values.messageBus.secret.name }} + key: username + - name: MessageBus__Password + valueFrom: + secretKeyRef: + name: {{ .Values.messageBus.secret.name }} + key: password ports: - containerPort: 8080 --- diff --git a/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml b/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml index 37b1e6a..893a80f 100644 --- a/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml +++ b/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml @@ -56,5 +56,17 @@ spec: key: apiKeyMessageBus - name: Kestrel__EndpointDefaults__Protocols value: "Http1AndHttp2" + - name: MessageBus__Host + value: {{ .Values.messageBus.loadBalancer }} + - name: MessageBus__Username + valueFrom: + secretKeyRef: + name: {{ .Values.messageBus.secret.name }} + key: username + - name: MessageBus__Password + valueFrom: + secretKeyRef: + name: {{ .Values.messageBus.secret.name }} + key: password ports: - containerPort: 8080 \ No newline at end of file diff --git a/deployment/MantaRayPlanCloud/templates/messagebus.yaml b/deployment/MantaRayPlanCloud/templates/messagebus.yaml new file mode 100644 index 0000000..a3a97b9 --- /dev/null +++ b/deployment/MantaRayPlanCloud/templates/messagebus.yaml @@ -0,0 +1,117 @@ +{{- $messageBusSecrets := (lookup "v1" "Secret" .Values.namespace .Values.messageBus.secret.name ) -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.messageBusSecrets.secret.name }} + namespace: {{ .Values.namespace }} +type: kubernetes.io/basic-auth +data: + username: {{ .Values.pgadmin.username | b64enc }} +{{- if and $messageBusSecrets $messageBusSecrets.data }} + {{- if $messageBusSecrets.data.password }} + password: {{ $messageBusSecrets.data.password }} + {{- else }} + password: {{ "nonExistingKey1234" | b64enc }} + {{- end }} +{{- else }} + password: {{ "nonExistingKey1234" | b64enc }} +{{- end }} +--- +kind: PersistentVolume +apiVersion: v1 +metadata: + name: rabbitmq-pv-volume + namespace: {{ .Values.namespace }} + labels: + type: local + app: {{ .Values.messageBus.app }} +spec: + storageClassName: manual + capacity: + storage: 5Gi + volumeMode: Filesystem + accessModes: + - ReadWriteMany + hostPath: + path: "/MantaRayPlan/RabbitMQ" +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: rabbitmq-pv-claim + namespace: {{ .Values.namespace }} + labels: + app: {{ .Values.messageBus.app }} +spec: + storageClassName: manual + accessModes: + - ReadWriteMany + resources: + requests: + storage: 5Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.messageBus.deployment }} + namespace: {{ .Values.namespace }} + labels: + app: {{ .Values.messageBus.app }} + name: {{ .Values.messageBus.name }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Values.messageBus.app }} + task: {{ .Values.messageBus.name }} + template: + metadata: + labels: + app: {{ .Values.messageBus.app }} + task: {{ .Values.messageBus.name }} + spec: + containers: + - name: {{ .Values.messageBus.app }} + image: "{{ .Values.messageBus.image }}:{{ .Values.messageBus.tag }}" + imagePullPolicy: Always + env: + - name: RABBITMQ_DEFAULT_USER + valueFrom: + secretKeyRef: + name: {{ .Values.messageBus.secret.name }} + key: username + - name: RABBITMQ_DEFAULT_PASS + valueFrom: + secretKeyRef: + name: {{ .Values.messageBus.secret.name }} + key: password + ports: + - containerPort: 5672 + - containerPort: 15672 + volumeMounts: + - mountPath: "/var/lib/rabbitmq" + name: rabbitmqvolume + volumes: + - name: rabbitmqvolume + persistentVolumeClaim: + claimName: rabbitmq-pv-claim +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.messageBus.loadBalancer }} + namespace: {{ .Values.namespace }} +spec: + selector: + app: {{ .Values.messageBus.app }} + task: {{ .Values.messageBus.name }} + ports: + - protocol: TCP + name: http + port: 5672 + targetPort: 5672 + - protocol: TCP + name: http + port: 15672 + targetPort: 15672 + type: LoadBalancer \ No newline at end of file diff --git a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml index c0342f5..565b02c 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml @@ -37,7 +37,19 @@ spec: valueFrom: secretKeyRef: name: {{ .Values.logging.seq.secrets.name }} - key: apiKeyViewer + key: apiKeyViewer + - name: MessageBus__Host + value: {{ .Values.messageBus.loadBalancer }} + - name: MessageBus__Username + valueFrom: + secretKeyRef: + name: {{ .Values.messageBus.secret.name }} + key: username + - name: MessageBus__Password + valueFrom: + secretKeyRef: + name: {{ .Values.messageBus.secret.name }} + key: password ports: - containerPort: 8080 --- diff --git a/deployment/MantaRayPlanCloud/values.yaml b/deployment/MantaRayPlanCloud/values.yaml index 846147b..3907708 100644 --- a/deployment/MantaRayPlanCloud/values.yaml +++ b/deployment/MantaRayPlanCloud/values.yaml @@ -101,3 +101,14 @@ pgadmin: host: "database.mantarayplan" secret: name: pgadmin-secret + +messageBus: + app: rabbitmq + deployment: rabbitmq-deployment + loadBalancer: "rabbitmq-loadbalancer" + image: rabbitmq + tag: 3-management + name: rabbitmq + secret: + name: rabbitmq-secret + From e1e979cbd5e327eca7e940c1d6577e9f142fd842 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 29 Sep 2024 17:30:14 +0200 Subject: [PATCH 21/47] Finish kubernetes --- .../templates/admin-bff.yaml | 2 ++ .../templates/admin-web.yaml | 31 ++++++++++++----- .../templates/viewer-bff.yaml | 2 ++ .../templates/viewer-web.yaml | 33 ++++++++++++++----- src/docker/Clients.Admin.Web/appsettings.json | 2 +- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml index dfcebf5..8fd477f 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml @@ -31,6 +31,8 @@ spec: timeoutSeconds: 1 failureThreshold: 3 env: + - name: Api__Address + value: "{{ .Values.api.grpc.loadBalancer}}:8080" - name: OpenTelemetry__LoggerEndpoint value: "{{ .Values.logging.seq.host.internal }}" - name: OpenTelemetry__LoggerApiKey diff --git a/deployment/MantaRayPlanCloud/templates/admin-web.yaml b/deployment/MantaRayPlanCloud/templates/admin-web.yaml index 49c1712..ab8da61 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-web.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-web.yaml @@ -6,18 +6,13 @@ metadata: data: default.conf: | server { - listen 80; + listen 80; listen [::]:80; server_name localhost; location / { - root /usr/share/nginx/html; - index index.html index.htm; - } - - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; + root /usr/share/nginx/html; + try_files $uri $uri/ /index.html =404; } add_header X-Frame-Options "DENY" always; @@ -27,6 +22,19 @@ data: add_header content-security-policy "default-src 'self' https://{{ .Values.admin.bff.host }}; img-src 'self' data: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://{{ .Values.admin.bff.host }}; upgrade-insecure-requests; frame-ancestors 'self'"; } --- +apiVersion: v1 +kind: ConfigMap +metadata: + name: "{{ .Values.admin.web.app }}-appsetting-config" + namespace: {{ .Values.namespace }} +data: + default.conf: | + { + "Api": { + "Address": "https://{{ .Values.admin.bff.host }}/" + } + } +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -64,12 +72,19 @@ spec: mountPath: /etc/nginx/conf.d/default.conf subPath: default.conf readOnly: true + - name: "{{ .Values.admin.web.app }}-appsettings-config-volume" + mountPath: /usr/share/nginx/html/appsettings.json + subPath: appsettings.json + readOnly: true ports: - containerPort: 80 volumes: - name: "{{ .Values.admin.web.app }}-nginx-config-volume" configMap: name: "{{ .Values.admin.web.app }}-nginx-config" + - name: "{{ .Values.admin.web.app }}-appsettings-config-volume" + configMap: + name: "{{ .Values.admin.web.app }}-appsettings-config" --- apiVersion: v1 kind: Service diff --git a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml index 565b02c..e01bf35 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml @@ -31,6 +31,8 @@ spec: timeoutSeconds: 1 failureThreshold: 3 env: + - name: Api__Address + value: "{{ .Values.api.grpc.loadBalancer}}:8080" - name: OpenTelemetry__LoggerEndpoint value: "{{ .Values.logging.seq.host.internal }}" - name: OpenTelemetry__LoggerApiKey diff --git a/deployment/MantaRayPlanCloud/templates/viewer-web.yaml b/deployment/MantaRayPlanCloud/templates/viewer-web.yaml index 84c07ad..1cee320 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-web.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-web.yaml @@ -6,25 +6,33 @@ metadata: data: default.conf: | server { - listen 80; + listen 80; listen [::]:80; server_name localhost; location / { - root /usr/share/nginx/html; - index index.html index.htm; - } - - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; + root /usr/share/nginx/html; + try_files $uri $uri/ /index.html =404; } add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "no-referrer"; add_header X-Content-Type-Options "nosniff"; add_header Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), navigation-override=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()"; - add_header content-security-policy "default-src 'self' https://{{ .Values.viewer.bff.host }}; img-src 'self' data: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://{{ .Values.viewer.bff.host }}; upgrade-insecure-requests; frame-ancestors 'self'"; + add_header content-security-policy "default-src 'self' https://{{ .Values.viewer.bff.host }}; img-src 'self' data: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://{{ .Values.viewer.bff.host }}; upgrade-insecure-requests; frame-ancestors 'self'"; + } +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: "{{ .Values.admin.web.app }}-appsetting-config" + namespace: {{ .Values.namespace }} +data: + default.conf: | + { + "Api": { + "Address": "https://{{ .Values.viewer.bff.host }}/" + } } --- apiVersion: apps/v1 @@ -64,12 +72,19 @@ spec: mountPath: /etc/nginx/conf.d/default.conf subPath: default.conf readOnly: true + - name: "{{ .Values.admin.web.app }}-appsettings-config-volume" + mountPath: /usr/share/nginx/html/appsettings.json + subPath: appsettings.json + readOnly: true ports: - containerPort: 80 volumes: - name: "{{ .Values.viewer.web.app }}-nginx-config-volume" configMap: name: "{{ .Values.viewer.web.app }}-nginx-config" + - name: "{{ .Values.admin.web.app }}-appsettings-config-volume" + configMap: + name: "{{ .Values.admin.web.app }}-appsettings-config" --- apiVersion: v1 kind: Service diff --git a/src/docker/Clients.Admin.Web/appsettings.json b/src/docker/Clients.Admin.Web/appsettings.json index 72d7dab..e61d946 100644 --- a/src/docker/Clients.Admin.Web/appsettings.json +++ b/src/docker/Clients.Admin.Web/appsettings.json @@ -2,4 +2,4 @@ "Api": { "Address": "http://localhost:8080/" } - } \ No newline at end of file +} \ No newline at end of file From 6d117a5f6b123acfa18353620c813ae53ac73662 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Thu, 3 Oct 2024 22:28:32 +0200 Subject: [PATCH 22/47] Start with test containers --- src/Directory.Packages.props | 1 + .../MadWorldNL.IntegrationTests.csproj | 5 ++ .../TestDefinitions.cs | 6 ++ src/MadWorldNL.MantaRayPlan.sln | 7 +++ .../Api.MessageBus.IntegrationTests.csproj | 2 + .../Base/MessageBusFactory.cs | 55 +++++++++++++++++++ .../{ => Endpoints}/HealthCheckTests.cs | 7 ++- 7 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 src/MadWorldNL.IntegrationTests/MadWorldNL.IntegrationTests.csproj create mode 100644 src/MadWorldNL.IntegrationTests/TestDefinitions.cs create mode 100644 src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs rename src/Server.Controllers.Api.MessageBus.IntegrationTests/{ => Endpoints}/HealthCheckTests.cs (63%) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index cf8000b..2e4f2bd 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -39,6 +39,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + all diff --git a/src/MadWorldNL.IntegrationTests/MadWorldNL.IntegrationTests.csproj b/src/MadWorldNL.IntegrationTests/MadWorldNL.IntegrationTests.csproj new file mode 100644 index 0000000..71283eb --- /dev/null +++ b/src/MadWorldNL.IntegrationTests/MadWorldNL.IntegrationTests.csproj @@ -0,0 +1,5 @@ + + + net8.0 + + diff --git a/src/MadWorldNL.IntegrationTests/TestDefinitions.cs b/src/MadWorldNL.IntegrationTests/TestDefinitions.cs new file mode 100644 index 0000000..3601892 --- /dev/null +++ b/src/MadWorldNL.IntegrationTests/TestDefinitions.cs @@ -0,0 +1,6 @@ +namespace MadWorldNL.MantaRayPlan; + +public static class TestDefinitions +{ + public const string Default = nameof(Default); +} \ No newline at end of file diff --git a/src/MadWorldNL.MantaRayPlan.sln b/src/MadWorldNL.MantaRayPlan.sln index ed7ae5c..e4c6f70 100644 --- a/src/MadWorldNL.MantaRayPlan.sln +++ b/src/MadWorldNL.MantaRayPlan.sln @@ -120,6 +120,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientSdk.Admin.Bff", "Clie EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientSdk.Api.MessageBus", "ClientSdk.Api.MessageBus\ClientSdk.Api.MessageBus.csproj", "{F76D206C-3F80-4099-B4ED-3DAE193303FC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MadWorldNL.IntegrationTests", "MadWorldNL.IntegrationTests\MadWorldNL.IntegrationTests.csproj", "{8809E42F-C1B5-4BB0-8C9E-3B7964A4F7E1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -165,6 +167,7 @@ Global {6F2083BE-51EF-48D2-AA85-8C6A099C3E85} = {00C31373-91B2-410A-A8B7-F66F7CD51708} {B5FA9C6D-5F8A-4334-985F-4909833996AE} = {AD870EB2-89A9-471C-A5CB-C95FA4D917BC} {F76D206C-3F80-4099-B4ED-3DAE193303FC} = {00C31373-91B2-410A-A8B7-F66F7CD51708} + {8809E42F-C1B5-4BB0-8C9E-3B7964A4F7E1} = {0F97374D-45DB-4F78-905D-07A96CA2057F} EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C3AFAE1F-DDC9-4DB1-931D-1B934F9C9DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -251,5 +254,9 @@ Global {F76D206C-3F80-4099-B4ED-3DAE193303FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {F76D206C-3F80-4099-B4ED-3DAE193303FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {F76D206C-3F80-4099-B4ED-3DAE193303FC}.Release|Any CPU.Build.0 = Release|Any CPU + {8809E42F-C1B5-4BB0-8C9E-3B7964A4F7E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8809E42F-C1B5-4BB0-8C9E-3B7964A4F7E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8809E42F-C1B5-4BB0-8C9E-3B7964A4F7E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8809E42F-C1B5-4BB0-8C9E-3B7964A4F7E1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Api.MessageBus.IntegrationTests.csproj b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Api.MessageBus.IntegrationTests.csproj index 6499e27..c3794df 100644 --- a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Api.MessageBus.IntegrationTests.csproj +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Api.MessageBus.IntegrationTests.csproj @@ -13,6 +13,7 @@ + @@ -22,6 +23,7 @@ + diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs new file mode 100644 index 0000000..386cabe --- /dev/null +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs @@ -0,0 +1,55 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.Configuration; +using Testcontainers.PostgreSql; + +namespace MadWorldNL.MantaRayPlan.Base; + +public class MessageBusFactory : WebApplicationFactory +{ + private const string DbName = "MantaRayPlan"; + private const string DbUser = "postgres"; + private const string DbPassword = "Password"; + + private PostgreSqlContainer? _postgreSqlContainer; + + public MessageBusFactory() + { + InitializeAsync().GetAwaiter().GetResult(); + } + + public async Task InitializeAsync() + { + _postgreSqlContainer = new PostgreSqlBuilder() + .WithImage("postgres:16") + .WithDatabase(DbName) + .WithUsername(DbUser) + .WithPassword(DbPassword) + .Build(); + + await _postgreSqlContainer.StartAsync(); + + } + + protected override void ConfigureWebHost(IWebHostBuilder builder) + { + builder.UseSetting("Database__Host", _postgreSqlContainer!.Hostname); + builder.UseSetting("Database__Port", _postgreSqlContainer.GetMappedPublicPort(5432).ToString()); + builder.UseSetting("Database__DbName", DbName); + builder.UseSetting("Database__User", DbUser); + builder.UseSetting("Database__Password", DbPassword); + + base.ConfigureWebHost(builder); + } + + public override async ValueTask DisposeAsync() + { + if (_postgreSqlContainer is not null) + { + await _postgreSqlContainer.DisposeAsync(); + } + + await base.DisposeAsync(); + GC.SuppressFinalize(this); + } +} \ No newline at end of file diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/HealthCheckTests.cs b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs similarity index 63% rename from src/Server.Controllers.Api.MessageBus.IntegrationTests/HealthCheckTests.cs rename to src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs index 97d63be..d3c156b 100644 --- a/src/Server.Controllers.Api.MessageBus.IntegrationTests/HealthCheckTests.cs +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs @@ -1,11 +1,12 @@ - using System.Net; +using MadWorldNL.MantaRayPlan.Base; using Microsoft.AspNetCore.Mvc.Testing; using Shouldly; -namespace MadWorldNL.MantaRayPlan; +namespace MadWorldNL.MantaRayPlan.Endpoints; -public class HealthCheckTests(WebApplicationFactory factory) : IClassFixture> +[CollectionDefinition(TestDefinitions.Default)] +public class HealthCheckTests(MessageBusFactory factory) : IClassFixture { [Fact] public async Task Healthz_GivenEmptyRequest_ShouldBeHealthy() From be55c417e8fc29d81a44d21196a2554264701a7f Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Fri, 4 Oct 2024 13:45:42 +0200 Subject: [PATCH 23/47] Can override config settings in integration tests + test containers --- .../Base/MessageBusFactory.cs | 38 +++++---- .../Base/SharedTestCollection.cs | 6 ++ .../Endpoints/HealthCheckTests.cs | 9 ++- .../Program.cs | 79 ++++++++++--------- 4 files changed, 75 insertions(+), 57 deletions(-) create mode 100644 src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/SharedTestCollection.cs diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs index 386cabe..986efde 100644 --- a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs @@ -1,22 +1,19 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; using Testcontainers.PostgreSql; namespace MadWorldNL.MantaRayPlan.Base; -public class MessageBusFactory : WebApplicationFactory +public class MessageBusFactory : WebApplicationFactory, IAsyncLifetime { private const string DbName = "MantaRayPlan"; private const string DbUser = "postgres"; - private const string DbPassword = "Password"; + private const string DbPassword = "Password1234!"; private PostgreSqlContainer? _postgreSqlContainer; - - public MessageBusFactory() - { - InitializeAsync().GetAwaiter().GetResult(); - } public async Task InitializeAsync() { @@ -28,21 +25,28 @@ public async Task InitializeAsync() .Build(); await _postgreSqlContainer.StartAsync(); - } - - protected override void ConfigureWebHost(IWebHostBuilder builder) + + protected override IHost CreateHost(IHostBuilder builder) { - builder.UseSetting("Database__Host", _postgreSqlContainer!.Hostname); - builder.UseSetting("Database__Port", _postgreSqlContainer.GetMappedPublicPort(5432).ToString()); - builder.UseSetting("Database__DbName", DbName); - builder.UseSetting("Database__User", DbUser); - builder.UseSetting("Database__Password", DbPassword); + var newSettings = new Dictionary + { + ["Database:Host"] = _postgreSqlContainer!.Hostname, + ["Database:Port"] = _postgreSqlContainer.GetMappedPublicPort(5432).ToString(), + ["Database:DbName"] = DbName, + ["Database:User"] = DbUser, + ["Database:Password"] = DbPassword + }; + + builder.ConfigureHostConfiguration(config => + { + config.AddInMemoryCollection(newSettings!); + }); - base.ConfigureWebHost(builder); + return base.CreateHost(builder); } - public override async ValueTask DisposeAsync() + public new async Task DisposeAsync() { if (_postgreSqlContainer is not null) { diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/SharedTestCollection.cs b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/SharedTestCollection.cs new file mode 100644 index 0000000..5ef7f2f --- /dev/null +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/SharedTestCollection.cs @@ -0,0 +1,6 @@ +namespace MadWorldNL.MantaRayPlan.Base; + +[CollectionDefinition(TestDefinitions.Default)] +public class SharedTestCollection : ICollectionFixture +{ +} \ No newline at end of file diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs index d3c156b..4e19903 100644 --- a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs @@ -1,12 +1,11 @@ using System.Net; using MadWorldNL.MantaRayPlan.Base; -using Microsoft.AspNetCore.Mvc.Testing; using Shouldly; namespace MadWorldNL.MantaRayPlan.Endpoints; -[CollectionDefinition(TestDefinitions.Default)] -public class HealthCheckTests(MessageBusFactory factory) : IClassFixture +[Collection(TestDefinitions.Default)] +public class HealthCheckTests(MessageBusFactory factory) : IAsyncLifetime { [Fact] public async Task Healthz_GivenEmptyRequest_ShouldBeHealthy() @@ -20,4 +19,8 @@ public async Task Healthz_GivenEmptyRequest_ShouldBeHealthy() // Assert response.StatusCode.ShouldBe(HttpStatusCode.OK); } + + public Task InitializeAsync() => Task.CompletedTask; + + public Task DisposeAsync() => factory.DisposeAsync(); } \ No newline at end of file diff --git a/src/Server.Controllers.Api.MessageBus/Program.cs b/src/Server.Controllers.Api.MessageBus/Program.cs index 2f2cac0..5a2acd9 100644 --- a/src/Server.Controllers.Api.MessageBus/Program.cs +++ b/src/Server.Controllers.Api.MessageBus/Program.cs @@ -1,62 +1,67 @@ // See https://aka.ms/new-console-template for more information -using MadWorldNL.MantaRayPlan; using MadWorldNL.MantaRayPlan.Extensions; using MadWorldNL.MantaRayPlan.MassTransit; using MadWorldNL.MantaRayPlan.MessageBuses; using MadWorldNL.MantaRayPlan.OpenTelemetry; using MassTransit; -const string corsName = "DefaultCors"; +namespace MadWorldNL.MantaRayPlan; -var builder = WebApplication.CreateBuilder(); - -builder.Services.AddCors(options => +public class Program() { - options.AddPolicy(name: corsName, - policy => + private const string CorsName = "DefaultCors"; + + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + builder.Services.AddCors(options => { - policy.AllowAnyHeader(); - policy.AllowAnyMethod(); - policy.AllowAnyOrigin(); + options.AddPolicy(name: CorsName, + policy => + { + policy.AllowAnyHeader(); + policy.AllowAnyMethod(); + policy.AllowAnyOrigin(); + }); }); -}); -var openTelemetryConfig = builder.Configuration.GetSection(OpenTelemetryConfig.Key).Get() ?? - new OpenTelemetryConfig(); + var openTelemetryConfig = builder.Configuration.GetSection(OpenTelemetryConfig.Key).Get() ?? + new OpenTelemetryConfig(); -builder.AddDefaultOpenTelemetry(openTelemetryConfig); + builder.AddDefaultOpenTelemetry(openTelemetryConfig); -builder.AddDatabase(); + builder.AddDatabase(); -builder.Services.AddHealthChecks(); + builder.Services.AddHealthChecks(); -builder.Services.AddMassTransit(x => -{ - x.SetKebabCaseEndpointNameFormatter(); + builder.Services.AddMassTransit(x => + { + x.SetKebabCaseEndpointNameFormatter(); - x.AddConsumer(); + x.AddConsumer(); - x.UsingRabbitMq((context,cfg) => - { - var messageBusSettings = builder.Configuration.GetSection(MessageBusSettings.Key) - .Get()!; + x.UsingRabbitMq((context,cfg) => + { + var messageBusSettings = builder.Configuration.GetSection(MessageBusSettings.Key) + .Get()!; - cfg.Host(messageBusSettings.Host, messageBusSettings.Port, "/", h => { - h.Username(messageBusSettings.Username); - h.Password(messageBusSettings.Password); - }); + cfg.Host(messageBusSettings.Host, messageBusSettings.Port, "/", h => { + h.Username(messageBusSettings.Username); + h.Password(messageBusSettings.Password); + }); - cfg.ConfigureEndpoints(context); - }); -}); - -var app = builder.Build(); + cfg.ConfigureEndpoints(context); + }); + }); -app.MapHealthChecks("/healthz"); + var app = builder.Build(); -app.Services.MigrateDatabase(); + app.MapHealthChecks("/healthz"); -await app.RunAsync(); + app.Services.MigrateDatabase(); -public abstract partial class Program { } \ No newline at end of file + app.Run(); + } +} \ No newline at end of file From 9be417de72adaf75ca98042219196a8d7621c2dd Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Fri, 4 Oct 2024 22:39:02 +0200 Subject: [PATCH 24/47] Fix messagebus in one of the tests --- src/Directory.Packages.props | 2 ++ .../Api.MessageBus.IntegrationTests.csproj | 2 ++ .../Base/MessageBusFactory.cs | 36 ++++++++++++++++--- .../Endpoints/HealthCheckTests.cs | 4 ++- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 2e4f2bd..b3d2b2e 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -39,7 +39,9 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + all diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Api.MessageBus.IntegrationTests.csproj b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Api.MessageBus.IntegrationTests.csproj index c3794df..44be325 100644 --- a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Api.MessageBus.IntegrationTests.csproj +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Api.MessageBus.IntegrationTests.csproj @@ -13,7 +13,9 @@ + +
diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs index 986efde..769999c 100644 --- a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs @@ -1,9 +1,10 @@ -using Microsoft.AspNetCore.Hosting; +using MassTransit; using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Testcontainers.PostgreSql; +using Testcontainers.RabbitMq; namespace MadWorldNL.MantaRayPlan.Base; @@ -12,8 +13,12 @@ public class MessageBusFactory : WebApplicationFactory, IAsyncLifetime private const string DbName = "MantaRayPlan"; private const string DbUser = "postgres"; private const string DbPassword = "Password1234!"; + + private const string BusUser = "development"; + private const string BusPassword = "Password1234"; private PostgreSqlContainer? _postgreSqlContainer; + private RabbitMqContainer? _rabbitMqContainer; public async Task InitializeAsync() { @@ -23,8 +28,15 @@ public async Task InitializeAsync() .WithUsername(DbUser) .WithPassword(DbPassword) .Build(); - + + _rabbitMqContainer = new RabbitMqBuilder() + .WithImage("rabbitmq:3.11") + .WithUsername(BusUser) + .WithPassword(BusPassword) + .Build(); + await _postgreSqlContainer.StartAsync(); + await _rabbitMqContainer.StartAsync(); } protected override IHost CreateHost(IHostBuilder builder) @@ -35,17 +47,26 @@ protected override IHost CreateHost(IHostBuilder builder) ["Database:Port"] = _postgreSqlContainer.GetMappedPublicPort(5432).ToString(), ["Database:DbName"] = DbName, ["Database:User"] = DbUser, - ["Database:Password"] = DbPassword + ["Database:Password"] = DbPassword, + ["MessageBus:Host"] = _rabbitMqContainer!.Hostname, + ["MessageBus:Port"] = _rabbitMqContainer.GetMappedPublicPort(5672).ToString(), + ["MessageBus:Username"] = BusUser, + ["MessageBus:Password"] = BusPassword }; builder.ConfigureHostConfiguration(config => { config.AddInMemoryCollection(newSettings!); }); + + builder.ConfigureServices(services => + { + services.AddMassTransitTestHarness(); + }); return base.CreateHost(builder); } - + public new async Task DisposeAsync() { if (_postgreSqlContainer is not null) @@ -53,6 +74,11 @@ protected override IHost CreateHost(IHostBuilder builder) await _postgreSqlContainer.DisposeAsync(); } + if (_rabbitMqContainer is not null) + { + await _rabbitMqContainer.DisposeAsync(); + } + await base.DisposeAsync(); GC.SuppressFinalize(this); } diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs index 4e19903..b9106e8 100644 --- a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs @@ -1,5 +1,7 @@ using System.Net; using MadWorldNL.MantaRayPlan.Base; +using MassTransit; +using Microsoft.Extensions.DependencyInjection; using Shouldly; namespace MadWorldNL.MantaRayPlan.Endpoints; @@ -12,7 +14,7 @@ public async Task Healthz_GivenEmptyRequest_ShouldBeHealthy() { // Arrange var client = factory.CreateClient(); - + // Act var response = await client.GetAsync("/healthz"); From e279e4b99fa40b0634657cf44c49e233dbcb4155 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Fri, 4 Oct 2024 22:42:50 +0200 Subject: [PATCH 25/47] Add comment --- .../Base/MessageBusFactory.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs index 769999c..6118363 100644 --- a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs @@ -1,7 +1,6 @@ using MassTransit; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Testcontainers.PostgreSql; using Testcontainers.RabbitMq; @@ -61,6 +60,8 @@ protected override IHost CreateHost(IHostBuilder builder) builder.ConfigureServices(services => { + // For more info about testing message bus: + // https://masstransit.io/documentation/concepts/testing services.AddMassTransitTestHarness(); }); From 3129dba49a99a2cd370851901028da6bb0b09c1e Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 11:38:46 +0200 Subject: [PATCH 26/47] Fix all integration tests --- .../Admin.Bff.IntegrationTests.csproj | 2 + .../Base/AdminBffFactory.cs | 62 +++++++++++++ .../Base/SharedTestCollection.cs | 6 ++ .../{ => Endpoints}/HealthCheckTests.cs | 7 +- .../Base/SharedTestCollection.cs | 6 ++ .../Base/ViewerBffFactory.cs | 62 +++++++++++++ ...Clients.Viewer.Bff.IntegrationTests.csproj | 2 + .../{ => Endpoints}/HealthCheckTests.cs | 7 +- .../Api.Grpc.IntegrationTests.csproj | 3 + .../Base/GrpcFactory.cs | 90 +++++++++++++++++++ .../Base/SharedTestCollection.cs | 6 ++ .../{ => Endpoints}/HealthCheckTests.cs | 11 ++- .../Endpoints/HealthCheckTests.cs | 2 - 13 files changed, 255 insertions(+), 11 deletions(-) create mode 100644 src/Clients.Admin.Bff.IntegrationTests/Base/AdminBffFactory.cs create mode 100644 src/Clients.Admin.Bff.IntegrationTests/Base/SharedTestCollection.cs rename src/Clients.Admin.Bff.IntegrationTests/{ => Endpoints}/HealthCheckTests.cs (68%) create mode 100644 src/Clients.Viewer.Bff.IntegrationTests/Base/SharedTestCollection.cs create mode 100644 src/Clients.Viewer.Bff.IntegrationTests/Base/ViewerBffFactory.cs rename src/Clients.Viewer.Bff.IntegrationTests/{ => Endpoints}/HealthCheckTests.cs (68%) create mode 100644 src/Server.Controllers.Api.Grpc.IntegrationTests/Base/GrpcFactory.cs create mode 100644 src/Server.Controllers.Api.Grpc.IntegrationTests/Base/SharedTestCollection.cs rename src/Server.Controllers.Api.Grpc.IntegrationTests/{ => Endpoints}/HealthCheckTests.cs (55%) diff --git a/src/Clients.Admin.Bff.IntegrationTests/Admin.Bff.IntegrationTests.csproj b/src/Clients.Admin.Bff.IntegrationTests/Admin.Bff.IntegrationTests.csproj index d081186..9a0dcc1 100644 --- a/src/Clients.Admin.Bff.IntegrationTests/Admin.Bff.IntegrationTests.csproj +++ b/src/Clients.Admin.Bff.IntegrationTests/Admin.Bff.IntegrationTests.csproj @@ -13,6 +13,7 @@ + @@ -23,6 +24,7 @@ + diff --git a/src/Clients.Admin.Bff.IntegrationTests/Base/AdminBffFactory.cs b/src/Clients.Admin.Bff.IntegrationTests/Base/AdminBffFactory.cs new file mode 100644 index 0000000..7cb0dee --- /dev/null +++ b/src/Clients.Admin.Bff.IntegrationTests/Base/AdminBffFactory.cs @@ -0,0 +1,62 @@ +using MassTransit; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Testcontainers.RabbitMq; + +namespace MadWorldNL.MantaRayPlan.Base; + +public class AdminBffFactory : WebApplicationFactory, IAsyncLifetime +{ + private const string BusUser = "development"; + private const string BusPassword = "Password1234"; + + private RabbitMqContainer? _rabbitMqContainer; + + public async Task InitializeAsync() + { + _rabbitMqContainer = new RabbitMqBuilder() + .WithImage("rabbitmq:3.11") + .WithUsername(BusUser) + .WithPassword(BusPassword) + .Build(); + + await _rabbitMqContainer.StartAsync(); + } + + protected override IHost CreateHost(IHostBuilder builder) + { + var newSettings = new Dictionary + { + ["MessageBus:Host"] = _rabbitMqContainer!.Hostname, + ["MessageBus:Port"] = _rabbitMqContainer.GetMappedPublicPort(5672).ToString(), + ["MessageBus:Username"] = BusUser, + ["MessageBus:Password"] = BusPassword + }; + + builder.ConfigureHostConfiguration(config => + { + config.AddInMemoryCollection(newSettings!); + }); + + builder.ConfigureServices(services => + { + // For more info about testing message bus: + // https://masstransit.io/documentation/concepts/testing + services.AddMassTransitTestHarness(); + }); + + return base.CreateHost(builder); + } + + public new async Task DisposeAsync() + { + if (_rabbitMqContainer is not null) + { + await _rabbitMqContainer.DisposeAsync(); + } + + await base.DisposeAsync(); + GC.SuppressFinalize(this); + } +} \ No newline at end of file diff --git a/src/Clients.Admin.Bff.IntegrationTests/Base/SharedTestCollection.cs b/src/Clients.Admin.Bff.IntegrationTests/Base/SharedTestCollection.cs new file mode 100644 index 0000000..52c5ab4 --- /dev/null +++ b/src/Clients.Admin.Bff.IntegrationTests/Base/SharedTestCollection.cs @@ -0,0 +1,6 @@ +namespace MadWorldNL.MantaRayPlan.Base; + +[CollectionDefinition(TestDefinitions.Default)] +public class SharedTestCollection : ICollectionFixture +{ +} \ No newline at end of file diff --git a/src/Clients.Admin.Bff.IntegrationTests/HealthCheckTests.cs b/src/Clients.Admin.Bff.IntegrationTests/Endpoints/HealthCheckTests.cs similarity index 68% rename from src/Clients.Admin.Bff.IntegrationTests/HealthCheckTests.cs rename to src/Clients.Admin.Bff.IntegrationTests/Endpoints/HealthCheckTests.cs index 97d63be..58b7232 100644 --- a/src/Clients.Admin.Bff.IntegrationTests/HealthCheckTests.cs +++ b/src/Clients.Admin.Bff.IntegrationTests/Endpoints/HealthCheckTests.cs @@ -1,11 +1,12 @@ - using System.Net; +using MadWorldNL.MantaRayPlan.Base; using Microsoft.AspNetCore.Mvc.Testing; using Shouldly; -namespace MadWorldNL.MantaRayPlan; +namespace MadWorldNL.MantaRayPlan.Endpoints; -public class HealthCheckTests(WebApplicationFactory factory) : IClassFixture> +[Collection(TestDefinitions.Default)] +public class HealthCheckTests(AdminBffFactory factory) { [Fact] public async Task Healthz_GivenEmptyRequest_ShouldBeHealthy() diff --git a/src/Clients.Viewer.Bff.IntegrationTests/Base/SharedTestCollection.cs b/src/Clients.Viewer.Bff.IntegrationTests/Base/SharedTestCollection.cs new file mode 100644 index 0000000..bd6e772 --- /dev/null +++ b/src/Clients.Viewer.Bff.IntegrationTests/Base/SharedTestCollection.cs @@ -0,0 +1,6 @@ +namespace MadWorldNL.MantaRayPlan.Base; + +[CollectionDefinition(TestDefinitions.Default)] +public class SharedTestCollection : ICollectionFixture +{ +} \ No newline at end of file diff --git a/src/Clients.Viewer.Bff.IntegrationTests/Base/ViewerBffFactory.cs b/src/Clients.Viewer.Bff.IntegrationTests/Base/ViewerBffFactory.cs new file mode 100644 index 0000000..850a71c --- /dev/null +++ b/src/Clients.Viewer.Bff.IntegrationTests/Base/ViewerBffFactory.cs @@ -0,0 +1,62 @@ +using MassTransit; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Testcontainers.RabbitMq; + +namespace MadWorldNL.MantaRayPlan.Base; + +public class ViewerBffFactory : WebApplicationFactory, IAsyncLifetime +{ + private const string BusUser = "development"; + private const string BusPassword = "Password1234"; + + private RabbitMqContainer? _rabbitMqContainer; + + public async Task InitializeAsync() + { + _rabbitMqContainer = new RabbitMqBuilder() + .WithImage("rabbitmq:3.11") + .WithUsername(BusUser) + .WithPassword(BusPassword) + .Build(); + + await _rabbitMqContainer.StartAsync(); + } + + protected override IHost CreateHost(IHostBuilder builder) + { + var newSettings = new Dictionary + { + ["MessageBus:Host"] = _rabbitMqContainer!.Hostname, + ["MessageBus:Port"] = _rabbitMqContainer.GetMappedPublicPort(5672).ToString(), + ["MessageBus:Username"] = BusUser, + ["MessageBus:Password"] = BusPassword + }; + + builder.ConfigureHostConfiguration(config => + { + config.AddInMemoryCollection(newSettings!); + }); + + builder.ConfigureServices(services => + { + // For more info about testing message bus: + // https://masstransit.io/documentation/concepts/testing + //services.AddMassTransitTestHarness(); + }); + + return base.CreateHost(builder); + } + + public new async Task DisposeAsync() + { + if (_rabbitMqContainer is not null) + { + await _rabbitMqContainer.DisposeAsync(); + } + + await base.DisposeAsync(); + GC.SuppressFinalize(this); + } +} \ No newline at end of file diff --git a/src/Clients.Viewer.Bff.IntegrationTests/Clients.Viewer.Bff.IntegrationTests.csproj b/src/Clients.Viewer.Bff.IntegrationTests/Clients.Viewer.Bff.IntegrationTests.csproj index 4d7dbde..1c18fb9 100644 --- a/src/Clients.Viewer.Bff.IntegrationTests/Clients.Viewer.Bff.IntegrationTests.csproj +++ b/src/Clients.Viewer.Bff.IntegrationTests/Clients.Viewer.Bff.IntegrationTests.csproj @@ -13,6 +13,7 @@ + @@ -23,6 +24,7 @@ + diff --git a/src/Clients.Viewer.Bff.IntegrationTests/HealthCheckTests.cs b/src/Clients.Viewer.Bff.IntegrationTests/Endpoints/HealthCheckTests.cs similarity index 68% rename from src/Clients.Viewer.Bff.IntegrationTests/HealthCheckTests.cs rename to src/Clients.Viewer.Bff.IntegrationTests/Endpoints/HealthCheckTests.cs index 97d63be..467075a 100644 --- a/src/Clients.Viewer.Bff.IntegrationTests/HealthCheckTests.cs +++ b/src/Clients.Viewer.Bff.IntegrationTests/Endpoints/HealthCheckTests.cs @@ -1,11 +1,12 @@ - using System.Net; +using MadWorldNL.MantaRayPlan.Base; using Microsoft.AspNetCore.Mvc.Testing; using Shouldly; -namespace MadWorldNL.MantaRayPlan; +namespace MadWorldNL.MantaRayPlan.Endpoints; -public class HealthCheckTests(WebApplicationFactory factory) : IClassFixture> +[Collection(TestDefinitions.Default)] +public class HealthCheckTests(ViewerBffFactory factory) { [Fact] public async Task Healthz_GivenEmptyRequest_ShouldBeHealthy() diff --git a/src/Server.Controllers.Api.Grpc.IntegrationTests/Api.Grpc.IntegrationTests.csproj b/src/Server.Controllers.Api.Grpc.IntegrationTests/Api.Grpc.IntegrationTests.csproj index ae24c1f..4e9c264 100644 --- a/src/Server.Controllers.Api.Grpc.IntegrationTests/Api.Grpc.IntegrationTests.csproj +++ b/src/Server.Controllers.Api.Grpc.IntegrationTests/Api.Grpc.IntegrationTests.csproj @@ -13,6 +13,8 @@ + + @@ -22,6 +24,7 @@ + diff --git a/src/Server.Controllers.Api.Grpc.IntegrationTests/Base/GrpcFactory.cs b/src/Server.Controllers.Api.Grpc.IntegrationTests/Base/GrpcFactory.cs new file mode 100644 index 0000000..1036840 --- /dev/null +++ b/src/Server.Controllers.Api.Grpc.IntegrationTests/Base/GrpcFactory.cs @@ -0,0 +1,90 @@ +using MadWorldNL.MantaRayPlan.Extensions; +using MassTransit; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Testcontainers.PostgreSql; +using Testcontainers.RabbitMq; + +namespace MadWorldNL.MantaRayPlan.Base; + +public class GrpcFactory : WebApplicationFactory, IAsyncLifetime +{ + private const string DbName = "MantaRayPlan"; + private const string DbUser = "postgres"; + private const string DbPassword = "Password1234!"; + + private const string BusUser = "development"; + private const string BusPassword = "Password1234"; + + private PostgreSqlContainer? _postgreSqlContainer; + private RabbitMqContainer? _rabbitMqContainer; + + public async Task InitializeAsync() + { + _postgreSqlContainer = new PostgreSqlBuilder() + .WithImage("postgres:16") + .WithDatabase(DbName) + .WithUsername(DbUser) + .WithPassword(DbPassword) + .Build(); + + _rabbitMqContainer = new RabbitMqBuilder() + .WithImage("rabbitmq:3.11") + .WithUsername(BusUser) + .WithPassword(BusPassword) + .Build(); + + await _postgreSqlContainer.StartAsync(); + await _rabbitMqContainer.StartAsync(); + } + + protected override IHost CreateHost(IHostBuilder builder) + { + var newSettings = new Dictionary + { + ["Database:Host"] = _postgreSqlContainer!.Hostname, + ["Database:Port"] = _postgreSqlContainer.GetMappedPublicPort(5432).ToString(), + ["Database:DbName"] = DbName, + ["Database:User"] = DbUser, + ["Database:Password"] = DbPassword, + ["MessageBus:Host"] = _rabbitMqContainer!.Hostname, + ["MessageBus:Port"] = _rabbitMqContainer.GetMappedPublicPort(5672).ToString(), + ["MessageBus:Username"] = BusUser, + ["MessageBus:Password"] = BusPassword + }; + + builder.ConfigureHostConfiguration(config => + { + config.AddInMemoryCollection(newSettings!); + }); + + builder.ConfigureServices(services => + { + // For more info about testing message bus: + // https://masstransit.io/documentation/concepts/testing + services.AddMassTransitTestHarness(); + }); + + var host = base.CreateHost(builder); + host.Services.MigrateDatabase(); + return host; + } + + public new async Task DisposeAsync() + { + if (_postgreSqlContainer is not null) + { + await _postgreSqlContainer.DisposeAsync(); + } + + if (_rabbitMqContainer is not null) + { + await _rabbitMqContainer.DisposeAsync(); + } + + await base.DisposeAsync(); + GC.SuppressFinalize(this); + } +} \ No newline at end of file diff --git a/src/Server.Controllers.Api.Grpc.IntegrationTests/Base/SharedTestCollection.cs b/src/Server.Controllers.Api.Grpc.IntegrationTests/Base/SharedTestCollection.cs new file mode 100644 index 0000000..6201bbc --- /dev/null +++ b/src/Server.Controllers.Api.Grpc.IntegrationTests/Base/SharedTestCollection.cs @@ -0,0 +1,6 @@ +namespace MadWorldNL.MantaRayPlan.Base; + +[CollectionDefinition(TestDefinitions.Default)] +public class SharedTestCollection : ICollectionFixture +{ +} \ No newline at end of file diff --git a/src/Server.Controllers.Api.Grpc.IntegrationTests/HealthCheckTests.cs b/src/Server.Controllers.Api.Grpc.IntegrationTests/Endpoints/HealthCheckTests.cs similarity index 55% rename from src/Server.Controllers.Api.Grpc.IntegrationTests/HealthCheckTests.cs rename to src/Server.Controllers.Api.Grpc.IntegrationTests/Endpoints/HealthCheckTests.cs index 97d63be..37594c0 100644 --- a/src/Server.Controllers.Api.Grpc.IntegrationTests/HealthCheckTests.cs +++ b/src/Server.Controllers.Api.Grpc.IntegrationTests/Endpoints/HealthCheckTests.cs @@ -1,11 +1,12 @@ - using System.Net; +using MadWorldNL.MantaRayPlan.Base; using Microsoft.AspNetCore.Mvc.Testing; using Shouldly; -namespace MadWorldNL.MantaRayPlan; +namespace MadWorldNL.MantaRayPlan.Endpoints; -public class HealthCheckTests(WebApplicationFactory factory) : IClassFixture> +[Collection(TestDefinitions.Default)] +public class HealthCheckTests(GrpcFactory factory) : IAsyncLifetime { [Fact] public async Task Healthz_GivenEmptyRequest_ShouldBeHealthy() @@ -19,4 +20,8 @@ public async Task Healthz_GivenEmptyRequest_ShouldBeHealthy() // Assert response.StatusCode.ShouldBe(HttpStatusCode.OK); } + + public Task InitializeAsync() => Task.CompletedTask; + + public Task DisposeAsync() => factory.DisposeAsync(); } \ No newline at end of file diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs index b9106e8..2fbf9ff 100644 --- a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Endpoints/HealthCheckTests.cs @@ -1,7 +1,5 @@ using System.Net; using MadWorldNL.MantaRayPlan.Base; -using MassTransit; -using Microsoft.Extensions.DependencyInjection; using Shouldly; namespace MadWorldNL.MantaRayPlan.Endpoints; From 395f75782aa554dc5299183a579abcc77650dd90 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 11:57:24 +0200 Subject: [PATCH 27/47] Try new sonarqube --- .github/workflows/sonarqube.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 935581b..9a8ef02 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -8,8 +8,13 @@ on: jobs: build: name: Build and analyze - runs-on: windows-latest + runs-on: ubuntu-latest steps: + - name: Set up Docker + run: | + docker version + docker pull postgres:16 --platform=linux/amd64 + docker pull rabbitmq:3.11 --platform=linux/amd64 - name: Set up JDK 17 uses: actions/setup-java@v3 with: From add2b78d5d7aa4138072e5018a33301f07bd7aa4 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 12:00:39 +0200 Subject: [PATCH 28/47] Fix tool --- .github/workflows/sonarqube.yaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 9a8ef02..11a56d8 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -29,19 +29,16 @@ jobs: path: ~\sonar\cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - - name: Cache SonarCloud scanner - id: cache-sonar-scanner + - name: Cache SonarCloud packages uses: actions/cache@v3 with: - path: .\.sonar\scanner - key: ${{ runner.os }}-sonar-scanner - restore-keys: ${{ runner.os }}-sonar-scanner + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar - name: Install SonarCloud scanner if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' - shell: powershell run: | - New-Item -Path .\.sonar\scanner -ItemType Directory - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner + dotnet tool install --global dotnet-sonarscanner - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any From 2ff2680708565558257890d832798f9155bc7d0d Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 12:02:17 +0200 Subject: [PATCH 29/47] Remove powershell --- .github/workflows/sonarqube.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 11a56d8..d0499de 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -43,7 +43,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - shell: powershell run: | .\.sonar\scanner\dotnet-sonarscanner begin /k:"MadWorldNL_MantaRayPlan" /o:"madworldnl" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=TestResults/*/coverage.opencover.xml /d:sonar.coverage.exclusions="**Test*.cs" /d:sonar.exclusions="**/Clients.DefaultStyle/wwwroot/lib/**, **/Clients.DefaultStyle/wwwroot/app/**" dotnet workload restore ./src/MadWorldNL.MantaRayPlan.sln; From 92906697e20997d3f42851e3188300e288f606bf Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 12:03:48 +0200 Subject: [PATCH 30/47] Fix pipeline --- .github/workflows/sonarqube.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index d0499de..f60d86e 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -44,9 +44,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"MadWorldNL_MantaRayPlan" /o:"madworldnl" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=TestResults/*/coverage.opencover.xml /d:sonar.coverage.exclusions="**Test*.cs" /d:sonar.exclusions="**/Clients.DefaultStyle/wwwroot/lib/**, **/Clients.DefaultStyle/wwwroot/app/**" + dotnet-sonarscanner begin /k:"MadWorldNL_MantaRayPlan" /o:"madworldnl" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=TestResults/*/coverage.opencover.xml /d:sonar.coverage.exclusions="**Test*.cs" /d:sonar.exclusions="**/Clients.DefaultStyle/wwwroot/lib/**, **/Clients.DefaultStyle/wwwroot/app/**" dotnet workload restore ./src/MadWorldNL.MantaRayPlan.sln; dotnet restore ./src/MadWorldNL.MantaRayPlan.sln; dotnet build ./src/MadWorldNL.MantaRayPlan.sln --no-restore -c Release; dotnet test ./src/MadWorldNL.MantaRayPlan.sln --no-build --no-restore -c Release --blame-hang-timeout 5min --collect:"XPlat Code Coverage" --results-directory TestResults/ -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover; - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file + dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file From 2fdc9b4edf0140ece261d88eb0792638594649c0 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 12:10:22 +0200 Subject: [PATCH 31/47] Fix build on linux --- src/Clients.Viewer.Mobile/Viewer.Mobile.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Clients.Viewer.Mobile/Viewer.Mobile.csproj b/src/Clients.Viewer.Mobile/Viewer.Mobile.csproj index d2bb91f..b5e519a 100644 --- a/src/Clients.Viewer.Mobile/Viewer.Mobile.csproj +++ b/src/Clients.Viewer.Mobile/Viewer.Mobile.csproj @@ -2,7 +2,8 @@ False - net8.0-android;net8.0-ios; + net8.0-android + net8.0-ios From 717192f7ccf0088f45964ded7bc2f4e6197c7185 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 12:18:03 +0200 Subject: [PATCH 32/47] Install android sdk --- .github/workflows/sonarqube.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index f60d86e..9345365 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -45,6 +45,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | dotnet-sonarscanner begin /k:"MadWorldNL_MantaRayPlan" /o:"madworldnl" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=TestResults/*/coverage.opencover.xml /d:sonar.coverage.exclusions="**Test*.cs" /d:sonar.exclusions="**/Clients.DefaultStyle/wwwroot/lib/**, **/Clients.DefaultStyle/wwwroot/app/**" + dotnet build -t:InstallAndroidDependencies -f net8.0-android -p:AndroidSdkDirectory=c:\work\android-sdk -p:JavaSdkDirectory=c:\work\jdk -p:AcceptAndroidSdkLicenses=True dotnet workload restore ./src/MadWorldNL.MantaRayPlan.sln; dotnet restore ./src/MadWorldNL.MantaRayPlan.sln; dotnet build ./src/MadWorldNL.MantaRayPlan.sln --no-restore -c Release; From 69a0c7d640ddd62c9574137548847579ac1ef9e0 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 12:22:29 +0200 Subject: [PATCH 33/47] Fix it --- .github/workflows/sonarqube.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 9345365..f18adc3 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -45,7 +45,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | dotnet-sonarscanner begin /k:"MadWorldNL_MantaRayPlan" /o:"madworldnl" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=TestResults/*/coverage.opencover.xml /d:sonar.coverage.exclusions="**Test*.cs" /d:sonar.exclusions="**/Clients.DefaultStyle/wwwroot/lib/**, **/Clients.DefaultStyle/wwwroot/app/**" - dotnet build -t:InstallAndroidDependencies -f net8.0-android -p:AndroidSdkDirectory=c:\work\android-sdk -p:JavaSdkDirectory=c:\work\jdk -p:AcceptAndroidSdkLicenses=True + dotnet build -t:InstallAndroidDependencies -f net8.0-android -p:AcceptAndroidSdkLicenses=True dotnet workload restore ./src/MadWorldNL.MantaRayPlan.sln; dotnet restore ./src/MadWorldNL.MantaRayPlan.sln; dotnet build ./src/MadWorldNL.MantaRayPlan.sln --no-restore -c Release; From 4454dbc11300e29bf1753229e245ff8e916dd62c Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 14:05:17 +0200 Subject: [PATCH 34/47] Fix --- .github/workflows/sonarqube.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index f18adc3..6160530 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -45,7 +45,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | dotnet-sonarscanner begin /k:"MadWorldNL_MantaRayPlan" /o:"madworldnl" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=TestResults/*/coverage.opencover.xml /d:sonar.coverage.exclusions="**Test*.cs" /d:sonar.exclusions="**/Clients.DefaultStyle/wwwroot/lib/**, **/Clients.DefaultStyle/wwwroot/app/**" - dotnet build -t:InstallAndroidDependencies -f net8.0-android -p:AcceptAndroidSdkLicenses=True + dotnet workload install android dotnet workload restore ./src/MadWorldNL.MantaRayPlan.sln; dotnet restore ./src/MadWorldNL.MantaRayPlan.sln; dotnet build ./src/MadWorldNL.MantaRayPlan.sln --no-restore -c Release; From 668afcf4f38b9695815bf3e06616dd596966293b Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 14:11:56 +0200 Subject: [PATCH 35/47] Install android --- .github/workflows/sonarqube.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 6160530..4dfc9dd 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -23,6 +23,13 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Install Android SDK + run: | + sudo apt-get update + sudo apt-get install -y android-sdk + env: + ANDROID_HOME: /usr/lib/android-sdk + ANDROID_SDK_ROOT: /usr/lib/android-sdk - name: Cache SonarCloud packages uses: actions/cache@v3 with: From bd229b06a1423bad04d22d107c5d2d29410b3eb9 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 14:16:06 +0200 Subject: [PATCH 36/47] Fix android --- .github/workflows/sonarqube.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 4dfc9dd..1a2206e 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -27,6 +27,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y android-sdk + export AndroidSdkDirectory=/usr/lib/android-sdk env: ANDROID_HOME: /usr/lib/android-sdk ANDROID_SDK_ROOT: /usr/lib/android-sdk From 20211297db18aa68819ab3709b8f6c0c1e8db472 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 14:20:15 +0200 Subject: [PATCH 37/47] Fix again --- .github/workflows/sonarqube.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 1a2206e..15c5449 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -56,6 +56,6 @@ jobs: dotnet workload install android dotnet workload restore ./src/MadWorldNL.MantaRayPlan.sln; dotnet restore ./src/MadWorldNL.MantaRayPlan.sln; - dotnet build ./src/MadWorldNL.MantaRayPlan.sln --no-restore -c Release; + dotnet build ./src/MadWorldNL.MantaRayPlan.sln --no-restore -c Release /p:AndroidSdkDirectory="$(AndroidSdkDirectory)"; dotnet test ./src/MadWorldNL.MantaRayPlan.sln --no-build --no-restore -c Release --blame-hang-timeout 5min --collect:"XPlat Code Coverage" --results-directory TestResults/ -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover; dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file From c5463e1bbfdad350f6cbf22a8485948ac6ce0657 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 5 Oct 2024 14:24:20 +0200 Subject: [PATCH 38/47] Try again --- .github/workflows/sonarqube.yaml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sonarqube.yaml b/.github/workflows/sonarqube.yaml index 15c5449..1442e4c 100644 --- a/.github/workflows/sonarqube.yaml +++ b/.github/workflows/sonarqube.yaml @@ -23,14 +23,8 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Install Android SDK - run: | - sudo apt-get update - sudo apt-get install -y android-sdk - export AndroidSdkDirectory=/usr/lib/android-sdk - env: - ANDROID_HOME: /usr/lib/android-sdk - ANDROID_SDK_ROOT: /usr/lib/android-sdk + - name: Setup Android SDK + uses: android-actions/setup-android@v3 - name: Cache SonarCloud packages uses: actions/cache@v3 with: @@ -56,6 +50,6 @@ jobs: dotnet workload install android dotnet workload restore ./src/MadWorldNL.MantaRayPlan.sln; dotnet restore ./src/MadWorldNL.MantaRayPlan.sln; - dotnet build ./src/MadWorldNL.MantaRayPlan.sln --no-restore -c Release /p:AndroidSdkDirectory="$(AndroidSdkDirectory)"; + dotnet build ./src/MadWorldNL.MantaRayPlan.sln --no-restore -c Release; dotnet test ./src/MadWorldNL.MantaRayPlan.sln --no-build --no-restore -c Release --blame-hang-timeout 5min --collect:"XPlat Code Coverage" --results-directory TestResults/ -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover; dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file From 73ea30cfdb75231a74c44880ed3bb940cc618d4a Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 6 Oct 2024 01:21:38 +0200 Subject: [PATCH 39/47] Fix C# sonarqube --- .../Base/AdminBffFactory.cs | 1 - .../Configurations/ApiTypes.cs | 2 +- .../Base/ViewerBffFactory.cs | 1 - .../Base/GrpcFactory.cs | 1 - .../Services/MessageBusServiceProxy.cs | 4 +- .../Base/MessageBusFactory.cs | 1 - .../Program.cs | 87 +++++++++---------- 7 files changed, 43 insertions(+), 54 deletions(-) diff --git a/src/Clients.Admin.Bff.IntegrationTests/Base/AdminBffFactory.cs b/src/Clients.Admin.Bff.IntegrationTests/Base/AdminBffFactory.cs index 7cb0dee..25caf1d 100644 --- a/src/Clients.Admin.Bff.IntegrationTests/Base/AdminBffFactory.cs +++ b/src/Clients.Admin.Bff.IntegrationTests/Base/AdminBffFactory.cs @@ -57,6 +57,5 @@ protected override IHost CreateHost(IHostBuilder builder) } await base.DisposeAsync(); - GC.SuppressFinalize(this); } } \ No newline at end of file diff --git a/src/Clients.Admin.Web/Configurations/ApiTypes.cs b/src/Clients.Admin.Web/Configurations/ApiTypes.cs index 9bc1dd2..770b053 100644 --- a/src/Clients.Admin.Web/Configurations/ApiTypes.cs +++ b/src/Clients.Admin.Web/Configurations/ApiTypes.cs @@ -1,6 +1,6 @@ namespace MadWorldNL.MantaRayPlan.Web.Configurations; -public class ApiTypes +public static class ApiTypes { public const string AdminBff = nameof(AdminBff); } \ No newline at end of file diff --git a/src/Clients.Viewer.Bff.IntegrationTests/Base/ViewerBffFactory.cs b/src/Clients.Viewer.Bff.IntegrationTests/Base/ViewerBffFactory.cs index 850a71c..05bf91e 100644 --- a/src/Clients.Viewer.Bff.IntegrationTests/Base/ViewerBffFactory.cs +++ b/src/Clients.Viewer.Bff.IntegrationTests/Base/ViewerBffFactory.cs @@ -57,6 +57,5 @@ protected override IHost CreateHost(IHostBuilder builder) } await base.DisposeAsync(); - GC.SuppressFinalize(this); } } \ No newline at end of file diff --git a/src/Server.Controllers.Api.Grpc.IntegrationTests/Base/GrpcFactory.cs b/src/Server.Controllers.Api.Grpc.IntegrationTests/Base/GrpcFactory.cs index 1036840..b2fa01f 100644 --- a/src/Server.Controllers.Api.Grpc.IntegrationTests/Base/GrpcFactory.cs +++ b/src/Server.Controllers.Api.Grpc.IntegrationTests/Base/GrpcFactory.cs @@ -85,6 +85,5 @@ protected override IHost CreateHost(IHostBuilder builder) } await base.DisposeAsync(); - GC.SuppressFinalize(this); } } \ No newline at end of file diff --git a/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs b/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs index 89647bb..c15e240 100644 --- a/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs +++ b/src/Server.Controllers.Api.Grpc/Services/MessageBusServiceProxy.cs @@ -24,9 +24,9 @@ public override async Task GetStatus(Empty request, Se Counter = status.Message.Count, }; } - catch (RequestFaultException exception) when (exception.Fault?.Exceptions.Any(ex => + catch (RequestFaultException exception) when (Array.Exists(exception.Fault?.Exceptions ?? [], ex => ex.InnerException?.ExceptionType == - "Npgsql.NpgsqlException") ?? false) + "Npgsql.NpgsqlException")) { logger.LogError(exception, "Unable to connect with database"); diff --git a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs index 6118363..b8bf468 100644 --- a/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs +++ b/src/Server.Controllers.Api.MessageBus.IntegrationTests/Base/MessageBusFactory.cs @@ -81,6 +81,5 @@ protected override IHost CreateHost(IHostBuilder builder) } await base.DisposeAsync(); - GC.SuppressFinalize(this); } } \ No newline at end of file diff --git a/src/Server.Controllers.Api.MessageBus/Program.cs b/src/Server.Controllers.Api.MessageBus/Program.cs index 5a2acd9..e2051a1 100644 --- a/src/Server.Controllers.Api.MessageBus/Program.cs +++ b/src/Server.Controllers.Api.MessageBus/Program.cs @@ -1,67 +1,60 @@ -// See https://aka.ms/new-console-template for more information - +using MadWorldNL.MantaRayPlan; using MadWorldNL.MantaRayPlan.Extensions; using MadWorldNL.MantaRayPlan.MassTransit; using MadWorldNL.MantaRayPlan.MessageBuses; using MadWorldNL.MantaRayPlan.OpenTelemetry; using MassTransit; -namespace MadWorldNL.MantaRayPlan; +const string corsName = "DefaultCors"; -public class Program() -{ - private const string CorsName = "DefaultCors"; - - public static void Main(string[] args) - { - var builder = WebApplication.CreateBuilder(args); +var builder = WebApplication.CreateBuilder(args); - builder.Services.AddCors(options => +builder.Services.AddCors(options => +{ + options.AddPolicy(name: corsName, + policy => { - options.AddPolicy(name: CorsName, - policy => - { - policy.AllowAnyHeader(); - policy.AllowAnyMethod(); - policy.AllowAnyOrigin(); - }); + policy.AllowAnyHeader(); + policy.AllowAnyMethod(); + policy.AllowAnyOrigin(); }); +}); - var openTelemetryConfig = builder.Configuration.GetSection(OpenTelemetryConfig.Key).Get() ?? - new OpenTelemetryConfig(); +var openTelemetryConfig = builder.Configuration.GetSection(OpenTelemetryConfig.Key).Get() ?? + new OpenTelemetryConfig(); - builder.AddDefaultOpenTelemetry(openTelemetryConfig); +builder.AddDefaultOpenTelemetry(openTelemetryConfig); - builder.AddDatabase(); +builder.AddDatabase(); - builder.Services.AddHealthChecks(); +builder.Services.AddHealthChecks(); - builder.Services.AddMassTransit(x => - { - x.SetKebabCaseEndpointNameFormatter(); - - x.AddConsumer(); - - x.UsingRabbitMq((context,cfg) => - { - var messageBusSettings = builder.Configuration.GetSection(MessageBusSettings.Key) - .Get()!; - - cfg.Host(messageBusSettings.Host, messageBusSettings.Port, "/", h => { - h.Username(messageBusSettings.Username); - h.Password(messageBusSettings.Password); - }); - - cfg.ConfigureEndpoints(context); - }); +builder.Services.AddMassTransit(x => +{ + x.SetKebabCaseEndpointNameFormatter(); + + x.AddConsumer(); + + x.UsingRabbitMq((context,cfg) => + { + var messageBusSettings = builder.Configuration.GetSection(MessageBusSettings.Key) + .Get()!; + + cfg.Host(messageBusSettings.Host, messageBusSettings.Port, "/", h => { + h.Username(messageBusSettings.Username); + h.Password(messageBusSettings.Password); }); - var app = builder.Build(); + cfg.ConfigureEndpoints(context); + }); +}); + +var app = builder.Build(); + +app.MapHealthChecks("/healthz"); - app.MapHealthChecks("/healthz"); +app.Services.MigrateDatabase(); - app.Services.MigrateDatabase(); +app.Run(); - app.Run(); - } -} \ No newline at end of file +public abstract partial class Program; \ No newline at end of file From c4b100a588566e5a515aa07faab2ce3479f4653a Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 6 Oct 2024 01:30:35 +0200 Subject: [PATCH 40/47] Start feedback kubernetes --- deployment/MantaRayPlanCloud/templates/admin-bff.yaml | 7 +++++++ deployment/MantaRayPlanCloud/templates/admin-web.yaml | 7 +++++++ deployment/MantaRayPlanCloud/templates/api-grpc.yaml | 7 +++++++ .../MantaRayPlanCloud/templates/api-message-bus.yaml | 7 +++++++ deployment/MantaRayPlanCloud/templates/messagebus.yaml | 7 +++++++ deployment/MantaRayPlanCloud/templates/pg-admin.yaml | 7 +++++++ deployment/MantaRayPlanCloud/templates/seq.yaml | 7 +++++++ deployment/MantaRayPlanCloud/templates/viewer-bff.yaml | 7 +++++++ deployment/MantaRayPlanCloud/templates/viewer-web.yaml | 9 ++++++++- 9 files changed, 64 insertions(+), 1 deletion(-) diff --git a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml index 8fd477f..0c7a42c 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml @@ -22,6 +22,13 @@ spec: - name: {{ .Values.admin.bff.app }} image: "{{ .Values.admin.bff.image }}:{{ .Values.image.tag }}" imagePullPolicy: Always + resources: + requests: + ephemeral-storage: "1Gi" + memory: "500Mi" + limits: + ephemeral-storage: "2Gi" + memory: "1Gi" livenessProbe: httpGet: path: /healthz diff --git a/deployment/MantaRayPlanCloud/templates/admin-web.yaml b/deployment/MantaRayPlanCloud/templates/admin-web.yaml index ab8da61..9d57789 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-web.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-web.yaml @@ -59,6 +59,13 @@ spec: - name: {{ .Values.admin.web.app }} image: "{{ .Values.admin.web.image }}:{{ .Values.image.tag }}" imagePullPolicy: Always + resources: + requests: + ephemeral-storage: "1Gi" + memory: "500Mi" + limits: + ephemeral-storage: "2Gi" + memory: "1Gi" livenessProbe: httpGet: path: /healthz.txt diff --git a/deployment/MantaRayPlanCloud/templates/api-grpc.yaml b/deployment/MantaRayPlanCloud/templates/api-grpc.yaml index 8703365..cc1ed4a 100644 --- a/deployment/MantaRayPlanCloud/templates/api-grpc.yaml +++ b/deployment/MantaRayPlanCloud/templates/api-grpc.yaml @@ -22,6 +22,13 @@ spec: - name: {{ .Values.api.grpc.app }} image: "{{ .Values.api.grpc.image }}:{{ .Values.image.tag }}" imagePullPolicy: Always + resources: + requests: + ephemeral-storage: "1Gi" + memory: "500Mi" + limits: + ephemeral-storage: "2Gi" + memory: "1Gi" livenessProbe: httpGet: path: /healthz diff --git a/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml b/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml index 893a80f..eb622fc 100644 --- a/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml +++ b/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml @@ -22,6 +22,13 @@ spec: - name: {{ .Values.api.messageBus.app }} image: "{{ .Values.api.messageBus.image }}:{{ .Values.image.tag }}" imagePullPolicy: Always + resources: + requests: + ephemeral-storage: "1Gi" + memory: "500Mi" + limits: + ephemeral-storage: "2Gi" + memory: "1Gi" livenessProbe: httpGet: path: /healthz diff --git a/deployment/MantaRayPlanCloud/templates/messagebus.yaml b/deployment/MantaRayPlanCloud/templates/messagebus.yaml index a3a97b9..1652077 100644 --- a/deployment/MantaRayPlanCloud/templates/messagebus.yaml +++ b/deployment/MantaRayPlanCloud/templates/messagebus.yaml @@ -74,6 +74,13 @@ spec: - name: {{ .Values.messageBus.app }} image: "{{ .Values.messageBus.image }}:{{ .Values.messageBus.tag }}" imagePullPolicy: Always + resources: + requests: + ephemeral-storage: "1Gi" + memory: "500Mi" + limits: + ephemeral-storage: "2Gi" + memory: "1Gi" env: - name: RABBITMQ_DEFAULT_USER valueFrom: diff --git a/deployment/MantaRayPlanCloud/templates/pg-admin.yaml b/deployment/MantaRayPlanCloud/templates/pg-admin.yaml index aec9746..386354d 100644 --- a/deployment/MantaRayPlanCloud/templates/pg-admin.yaml +++ b/deployment/MantaRayPlanCloud/templates/pg-admin.yaml @@ -74,6 +74,13 @@ spec: - name: {{ .Values.pgadmin.app }} image: "dpage/pgadmin4:latest" imagePullPolicy: Always + resources: + requests: + ephemeral-storage: "1Gi" + memory: "500Mi" + limits: + ephemeral-storage: "2Gi" + memory: "1Gi" securityContext: runAsUser: 0 runAsGroup: 0 diff --git a/deployment/MantaRayPlanCloud/templates/seq.yaml b/deployment/MantaRayPlanCloud/templates/seq.yaml index af40bd5..24a55a8 100644 --- a/deployment/MantaRayPlanCloud/templates/seq.yaml +++ b/deployment/MantaRayPlanCloud/templates/seq.yaml @@ -91,6 +91,13 @@ spec: - name: {{ .Values.logging.seq.app }} image: "{{ .Values.logging.seq.image }}:{{ .Values.logging.seq.tag }}" imagePullPolicy: Always + resources: + requests: + ephemeral-storage: "1Gi" + memory: "500Mi" + limits: + ephemeral-storage: "2Gi" + memory: "1Gi" env: - name: ACCEPT_EULA value: "Y" diff --git a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml index e01bf35..e666e48 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml @@ -22,6 +22,13 @@ spec: - name: {{ .Values.viewer.bff.app }} image: "{{ .Values.viewer.bff.image }}:{{ .Values.image.tag }}" imagePullPolicy: Always + resources: + requests: + ephemeral-storage: "1Gi" + memory: "1Gi" + limits: + ephemeral-storage: "2Gi" + memory: "1Gi" livenessProbe: httpGet: path: /healthz diff --git a/deployment/MantaRayPlanCloud/templates/viewer-web.yaml b/deployment/MantaRayPlanCloud/templates/viewer-web.yaml index 1cee320..426fe86 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-web.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-web.yaml @@ -59,6 +59,13 @@ spec: - name: {{ .Values.viewer.web.app }} image: "{{ .Values.viewer.web.image }}:{{ .Values.image.tag }}" imagePullPolicy: Always + resources: + requests: + ephemeral-storage: "1Gi" + memory: "500Mi" + limits: + ephemeral-storage: "2Gi" + memory: "1Gi" livenessProbe: httpGet: path: /healthz.txt @@ -72,7 +79,7 @@ spec: mountPath: /etc/nginx/conf.d/default.conf subPath: default.conf readOnly: true - - name: "{{ .Values.admin.web.app }}-appsettings-config-volume" + Y- name: "{{ .Values.admin.web.app }}-appsettings-config-volume" mountPath: /usr/share/nginx/html/appsettings.json subPath: appsettings.json readOnly: true From 4a0d6393e57427a61f24b5359917922b49e620e3 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 6 Oct 2024 01:31:22 +0200 Subject: [PATCH 41/47] RunAsync --- src/Server.Controllers.Api.MessageBus/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Server.Controllers.Api.MessageBus/Program.cs b/src/Server.Controllers.Api.MessageBus/Program.cs index e2051a1..aa91cfd 100644 --- a/src/Server.Controllers.Api.MessageBus/Program.cs +++ b/src/Server.Controllers.Api.MessageBus/Program.cs @@ -55,6 +55,6 @@ app.Services.MigrateDatabase(); -app.Run(); +await app.RunAsync(); public abstract partial class Program; \ No newline at end of file From 1b8a5fc69b726cef976e315d1b528d6fc01d8081 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 6 Oct 2024 01:52:20 +0200 Subject: [PATCH 42/47] Remove some feedback --- deployment/MantaRayPlanCloud/templates/admin-bff.yaml | 2 +- deployment/MantaRayPlanCloud/templates/viewer-bff.yaml | 4 ++-- src/MadWorldNL.AspNetCore/MassTransit/EventPublisher.cs | 2 +- src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml index 0c7a42c..2adb45a 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml @@ -39,7 +39,7 @@ spec: failureThreshold: 3 env: - name: Api__Address - value: "{{ .Values.api.grpc.loadBalancer}}:8080" + value: "{{ .Values.api.grpc.loadBalancer }}:8080" - name: OpenTelemetry__LoggerEndpoint value: "{{ .Values.logging.seq.host.internal }}" - name: OpenTelemetry__LoggerApiKey diff --git a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml index e666e48..d370e3e 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml @@ -25,7 +25,7 @@ spec: resources: requests: ephemeral-storage: "1Gi" - memory: "1Gi" + memory: "500Mi" limits: ephemeral-storage: "2Gi" memory: "1Gi" @@ -39,7 +39,7 @@ spec: failureThreshold: 3 env: - name: Api__Address - value: "{{ .Values.api.grpc.loadBalancer}}:8080" + value: "{{ .Values.api.grpc.loadBalancer }}:8080" - name: OpenTelemetry__LoggerEndpoint value: "{{ .Values.logging.seq.host.internal }}" - name: OpenTelemetry__LoggerApiKey diff --git a/src/MadWorldNL.AspNetCore/MassTransit/EventPublisher.cs b/src/MadWorldNL.AspNetCore/MassTransit/EventPublisher.cs index e9e0016..7532dbb 100644 --- a/src/MadWorldNL.AspNetCore/MassTransit/EventPublisher.cs +++ b/src/MadWorldNL.AspNetCore/MassTransit/EventPublisher.cs @@ -4,5 +4,5 @@ namespace MadWorldNL.MantaRayPlan.MassTransit; public static class EventPublisher { - public static Action OnMessageReceived { get; set; } = _ => { }; + public static Action? OnMessageReceived { get; set; } = _ => { }; } \ No newline at end of file diff --git a/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs b/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs index 674d23a..ef39088 100644 --- a/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs +++ b/src/Server.Controllers.Api.Grpc/Services/EventServiceProxy.cs @@ -17,8 +17,9 @@ public override Task Subscribe(Empty request, IServerStreamWriter resp { Thread.Sleep(1000); } - + EventPublisher.OnMessageReceived -= SendEventToClient; + return Task.CompletedTask; void SendEventToClient(IEvent newEvent) From d5d7c16185e0ee24525c1b7b5606d21f38739417 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 6 Oct 2024 10:03:44 +0200 Subject: [PATCH 43/47] Add service account in kubernetes --- deployment/MantaRayPlanCloud/templates/admin-bff.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/admin-web.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/api-grpc.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/api-message-bus.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/messagebus.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/pg-admin.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/seq.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/service-account.yaml | 6 ++++++ deployment/MantaRayPlanCloud/templates/viewer-bff.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/viewer-web.yaml | 2 ++ deployment/MantaRayPlanCloud/values.yaml | 3 +++ .../MassTransit/EventPusherConsumer.cs | 5 +++++ 12 files changed, 32 insertions(+) create mode 100644 deployment/MantaRayPlanCloud/templates/service-account.yaml diff --git a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml index 2adb45a..1384a99 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml @@ -7,6 +7,8 @@ metadata: app: {{ .Values.admin.bff.app }} name: {{ .Values.admin.bff.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false replicas: 1 selector: matchLabels: diff --git a/deployment/MantaRayPlanCloud/templates/admin-web.yaml b/deployment/MantaRayPlanCloud/templates/admin-web.yaml index 9d57789..b74b2b5 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-web.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-web.yaml @@ -44,6 +44,8 @@ metadata: app: {{ .Values.admin.web.app }} name: {{ .Values.admin.web.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false replicas: 1 selector: matchLabels: diff --git a/deployment/MantaRayPlanCloud/templates/api-grpc.yaml b/deployment/MantaRayPlanCloud/templates/api-grpc.yaml index cc1ed4a..2011d9e 100644 --- a/deployment/MantaRayPlanCloud/templates/api-grpc.yaml +++ b/deployment/MantaRayPlanCloud/templates/api-grpc.yaml @@ -7,6 +7,8 @@ metadata: app: {{ .Values.api.grpc.app }} name: {{ .Values.api.grpc.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false replicas: 1 selector: matchLabels: diff --git a/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml b/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml index eb622fc..35821f3 100644 --- a/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml +++ b/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml @@ -7,6 +7,8 @@ metadata: app: {{ .Values.api.messageBus.app }} name: {{ .Values.api.messageBus.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false replicas: 1 selector: matchLabels: diff --git a/deployment/MantaRayPlanCloud/templates/messagebus.yaml b/deployment/MantaRayPlanCloud/templates/messagebus.yaml index 1652077..88010c9 100644 --- a/deployment/MantaRayPlanCloud/templates/messagebus.yaml +++ b/deployment/MantaRayPlanCloud/templates/messagebus.yaml @@ -59,6 +59,8 @@ metadata: app: {{ .Values.messageBus.app }} name: {{ .Values.messageBus.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false replicas: 1 selector: matchLabels: diff --git a/deployment/MantaRayPlanCloud/templates/pg-admin.yaml b/deployment/MantaRayPlanCloud/templates/pg-admin.yaml index 386354d..ef8a0ba 100644 --- a/deployment/MantaRayPlanCloud/templates/pg-admin.yaml +++ b/deployment/MantaRayPlanCloud/templates/pg-admin.yaml @@ -59,6 +59,8 @@ metadata: app: {{ .Values.pgadmin.app }} name: {{ .Values.pgadmin.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false replicas: 1 selector: matchLabels: diff --git a/deployment/MantaRayPlanCloud/templates/seq.yaml b/deployment/MantaRayPlanCloud/templates/seq.yaml index 24a55a8..18dfc2c 100644 --- a/deployment/MantaRayPlanCloud/templates/seq.yaml +++ b/deployment/MantaRayPlanCloud/templates/seq.yaml @@ -76,6 +76,8 @@ metadata: app: {{ .Values.logging.seq.app }} name: {{ .Values.logging.seq.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false replicas: 1 selector: matchLabels: diff --git a/deployment/MantaRayPlanCloud/templates/service-account.yaml b/deployment/MantaRayPlanCloud/templates/service-account.yaml new file mode 100644 index 0000000..bfd4a19 --- /dev/null +++ b/deployment/MantaRayPlanCloud/templates/service-account.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.serveraccount.name }} + namespace: {{ .Values.namespace }} +automountServiceAccountToken: false \ No newline at end of file diff --git a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml index d370e3e..09e7a00 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml @@ -7,6 +7,8 @@ metadata: app: {{ .Values.viewer.bff.app }} name: {{ .Values.viewer.bff.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false replicas: 1 selector: matchLabels: diff --git a/deployment/MantaRayPlanCloud/templates/viewer-web.yaml b/deployment/MantaRayPlanCloud/templates/viewer-web.yaml index 426fe86..ff5a452 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-web.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-web.yaml @@ -44,6 +44,8 @@ metadata: app: {{ .Values.viewer.web.app }} name: {{ .Values.viewer.web.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false replicas: 1 selector: matchLabels: diff --git a/deployment/MantaRayPlanCloud/values.yaml b/deployment/MantaRayPlanCloud/values.yaml index 3907708..9d28ceb 100644 --- a/deployment/MantaRayPlanCloud/values.yaml +++ b/deployment/MantaRayPlanCloud/values.yaml @@ -17,6 +17,9 @@ domain: ingress: name: "ingress" +serveraccount: + name: manta-plan-account + api: grpc: deployment: "api-grpc-deployment" diff --git a/src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs b/src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs index fb82a9c..f5594f7 100644 --- a/src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs +++ b/src/MadWorldNL.AspNetCore/MassTransit/EventPusherConsumer.cs @@ -7,6 +7,11 @@ public class EventPusherConsumer : IConsumer where TMessage { public Task Consume(ConsumeContext context) { + if (EventPublisher.OnMessageReceived is null) + { + return Task.CompletedTask; + } + EventPublisher.OnMessageReceived(context.Message); return Task.CompletedTask; From 6442bcac45fe6a9ceb2338edcc55d7dc70a8a10e Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 6 Oct 2024 10:07:24 +0200 Subject: [PATCH 44/47] Feedback --- src/Clients.Admin.Bff/Hubs/EventsHub.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Clients.Admin.Bff/Hubs/EventsHub.cs b/src/Clients.Admin.Bff/Hubs/EventsHub.cs index f243fc4..5da2226 100644 --- a/src/Clients.Admin.Bff/Hubs/EventsHub.cs +++ b/src/Clients.Admin.Bff/Hubs/EventsHub.cs @@ -4,6 +4,9 @@ namespace MadWorldNL.MantaRayPlan.Hubs; [SignalRHub] +// The 'EventHandlerService' needs to be injected by DI but does not need to be used directly. +#pragma warning disable CS9113 // Parameter is unread. public class EventsHub(EventHandlerService _) : Hub +#pragma warning restore CS9113 // Parameter is unread. { } \ No newline at end of file From be0bc225ff2fba5804587cb817c5169e6fd23246 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 6 Oct 2024 10:15:22 +0200 Subject: [PATCH 45/47] Fix --- deployment/MantaRayPlanCloud/templates/admin-bff.yaml | 4 ++-- deployment/MantaRayPlanCloud/templates/admin-web.yaml | 4 ++-- deployment/MantaRayPlanCloud/templates/api-grpc.yaml | 4 ++-- deployment/MantaRayPlanCloud/templates/api-message-bus.yaml | 4 ++-- deployment/MantaRayPlanCloud/templates/messagebus.yaml | 4 ++-- deployment/MantaRayPlanCloud/templates/seq.yaml | 4 ++-- deployment/MantaRayPlanCloud/templates/viewer-bff.yaml | 4 ++-- deployment/MantaRayPlanCloud/templates/viewer-web.yaml | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml index 1384a99..211de63 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml @@ -7,8 +7,6 @@ metadata: app: {{ .Values.admin.bff.app }} name: {{ .Values.admin.bff.name }} spec: - serviceAccountName: {{ .Values.serveraccount.name }} - automountServiceAccountToken: false replicas: 1 selector: matchLabels: @@ -20,6 +18,8 @@ spec: app: {{ .Values.admin.bff.app }} task: {{ .Values.admin.bff.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false containers: - name: {{ .Values.admin.bff.app }} image: "{{ .Values.admin.bff.image }}:{{ .Values.image.tag }}" diff --git a/deployment/MantaRayPlanCloud/templates/admin-web.yaml b/deployment/MantaRayPlanCloud/templates/admin-web.yaml index b74b2b5..884d031 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-web.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-web.yaml @@ -44,8 +44,6 @@ metadata: app: {{ .Values.admin.web.app }} name: {{ .Values.admin.web.name }} spec: - serviceAccountName: {{ .Values.serveraccount.name }} - automountServiceAccountToken: false replicas: 1 selector: matchLabels: @@ -57,6 +55,8 @@ spec: app: {{ .Values.admin.web.app }} task: {{ .Values.admin.web.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false containers: - name: {{ .Values.admin.web.app }} image: "{{ .Values.admin.web.image }}:{{ .Values.image.tag }}" diff --git a/deployment/MantaRayPlanCloud/templates/api-grpc.yaml b/deployment/MantaRayPlanCloud/templates/api-grpc.yaml index 2011d9e..b484ebc 100644 --- a/deployment/MantaRayPlanCloud/templates/api-grpc.yaml +++ b/deployment/MantaRayPlanCloud/templates/api-grpc.yaml @@ -7,8 +7,6 @@ metadata: app: {{ .Values.api.grpc.app }} name: {{ .Values.api.grpc.name }} spec: - serviceAccountName: {{ .Values.serveraccount.name }} - automountServiceAccountToken: false replicas: 1 selector: matchLabels: @@ -20,6 +18,8 @@ spec: app: {{ .Values.api.grpc.app }} task: {{ .Values.api.grpc.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false containers: - name: {{ .Values.api.grpc.app }} image: "{{ .Values.api.grpc.image }}:{{ .Values.image.tag }}" diff --git a/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml b/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml index 35821f3..eb6e079 100644 --- a/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml +++ b/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml @@ -7,8 +7,6 @@ metadata: app: {{ .Values.api.messageBus.app }} name: {{ .Values.api.messageBus.name }} spec: - serviceAccountName: {{ .Values.serveraccount.name }} - automountServiceAccountToken: false replicas: 1 selector: matchLabels: @@ -20,6 +18,8 @@ spec: app: {{ .Values.api.messageBus.app }} task: {{ .Values.api.messageBus.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false containers: - name: {{ .Values.api.messageBus.app }} image: "{{ .Values.api.messageBus.image }}:{{ .Values.image.tag }}" diff --git a/deployment/MantaRayPlanCloud/templates/messagebus.yaml b/deployment/MantaRayPlanCloud/templates/messagebus.yaml index 88010c9..09f1781 100644 --- a/deployment/MantaRayPlanCloud/templates/messagebus.yaml +++ b/deployment/MantaRayPlanCloud/templates/messagebus.yaml @@ -59,8 +59,6 @@ metadata: app: {{ .Values.messageBus.app }} name: {{ .Values.messageBus.name }} spec: - serviceAccountName: {{ .Values.serveraccount.name }} - automountServiceAccountToken: false replicas: 1 selector: matchLabels: @@ -72,6 +70,8 @@ spec: app: {{ .Values.messageBus.app }} task: {{ .Values.messageBus.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false containers: - name: {{ .Values.messageBus.app }} image: "{{ .Values.messageBus.image }}:{{ .Values.messageBus.tag }}" diff --git a/deployment/MantaRayPlanCloud/templates/seq.yaml b/deployment/MantaRayPlanCloud/templates/seq.yaml index 18dfc2c..ae6f12e 100644 --- a/deployment/MantaRayPlanCloud/templates/seq.yaml +++ b/deployment/MantaRayPlanCloud/templates/seq.yaml @@ -76,8 +76,6 @@ metadata: app: {{ .Values.logging.seq.app }} name: {{ .Values.logging.seq.name }} spec: - serviceAccountName: {{ .Values.serveraccount.name }} - automountServiceAccountToken: false replicas: 1 selector: matchLabels: @@ -89,6 +87,8 @@ spec: app: {{ .Values.logging.seq.app }} task: {{ .Values.logging.seq.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false containers: - name: {{ .Values.logging.seq.app }} image: "{{ .Values.logging.seq.image }}:{{ .Values.logging.seq.tag }}" diff --git a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml index 09e7a00..4ea086e 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml @@ -7,8 +7,6 @@ metadata: app: {{ .Values.viewer.bff.app }} name: {{ .Values.viewer.bff.name }} spec: - serviceAccountName: {{ .Values.serveraccount.name }} - automountServiceAccountToken: false replicas: 1 selector: matchLabels: @@ -20,6 +18,8 @@ spec: app: {{ .Values.viewer.bff.app }} task: {{ .Values.viewer.bff.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false containers: - name: {{ .Values.viewer.bff.app }} image: "{{ .Values.viewer.bff.image }}:{{ .Values.image.tag }}" diff --git a/deployment/MantaRayPlanCloud/templates/viewer-web.yaml b/deployment/MantaRayPlanCloud/templates/viewer-web.yaml index ff5a452..65d3499 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-web.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-web.yaml @@ -44,8 +44,6 @@ metadata: app: {{ .Values.viewer.web.app }} name: {{ .Values.viewer.web.name }} spec: - serviceAccountName: {{ .Values.serveraccount.name }} - automountServiceAccountToken: false replicas: 1 selector: matchLabels: @@ -57,6 +55,8 @@ spec: app: {{ .Values.viewer.web.app }} task: {{ .Values.viewer.web.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false containers: - name: {{ .Values.viewer.web.app }} image: "{{ .Values.viewer.web.image }}:{{ .Values.image.tag }}" From 97aa08c3f11eb13d0b89972ad20a4eb41b67b362 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 6 Oct 2024 10:23:30 +0200 Subject: [PATCH 46/47] Add cpu to kubernetes --- deployment/MantaRayPlanCloud/templates/admin-bff.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/admin-web.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/api-grpc.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/api-message-bus.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/messagebus.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/pg-admin.yaml | 6 ++++-- deployment/MantaRayPlanCloud/templates/seq.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/viewer-bff.yaml | 2 ++ deployment/MantaRayPlanCloud/templates/viewer-web.yaml | 2 ++ 9 files changed, 20 insertions(+), 2 deletions(-) diff --git a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml index 211de63..c2a4e9b 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-bff.yaml @@ -27,9 +27,11 @@ spec: resources: requests: ephemeral-storage: "1Gi" + cpu: 0.5 memory: "500Mi" limits: ephemeral-storage: "2Gi" + cpu: 1 memory: "1Gi" livenessProbe: httpGet: diff --git a/deployment/MantaRayPlanCloud/templates/admin-web.yaml b/deployment/MantaRayPlanCloud/templates/admin-web.yaml index 884d031..d202b3c 100644 --- a/deployment/MantaRayPlanCloud/templates/admin-web.yaml +++ b/deployment/MantaRayPlanCloud/templates/admin-web.yaml @@ -64,9 +64,11 @@ spec: resources: requests: ephemeral-storage: "1Gi" + cpu: 0.5 memory: "500Mi" limits: ephemeral-storage: "2Gi" + cpu: 1 memory: "1Gi" livenessProbe: httpGet: diff --git a/deployment/MantaRayPlanCloud/templates/api-grpc.yaml b/deployment/MantaRayPlanCloud/templates/api-grpc.yaml index b484ebc..c1dad47 100644 --- a/deployment/MantaRayPlanCloud/templates/api-grpc.yaml +++ b/deployment/MantaRayPlanCloud/templates/api-grpc.yaml @@ -27,9 +27,11 @@ spec: resources: requests: ephemeral-storage: "1Gi" + cpu: 0.5 memory: "500Mi" limits: ephemeral-storage: "2Gi" + cpu: 1 memory: "1Gi" livenessProbe: httpGet: diff --git a/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml b/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml index eb6e079..75a987d 100644 --- a/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml +++ b/deployment/MantaRayPlanCloud/templates/api-message-bus.yaml @@ -27,9 +27,11 @@ spec: resources: requests: ephemeral-storage: "1Gi" + cpu: 0.5 memory: "500Mi" limits: ephemeral-storage: "2Gi" + cpu: 1 memory: "1Gi" livenessProbe: httpGet: diff --git a/deployment/MantaRayPlanCloud/templates/messagebus.yaml b/deployment/MantaRayPlanCloud/templates/messagebus.yaml index 09f1781..c77f748 100644 --- a/deployment/MantaRayPlanCloud/templates/messagebus.yaml +++ b/deployment/MantaRayPlanCloud/templates/messagebus.yaml @@ -79,9 +79,11 @@ spec: resources: requests: ephemeral-storage: "1Gi" + cpu: 0.5 memory: "500Mi" limits: ephemeral-storage: "2Gi" + cpu: 1 memory: "1Gi" env: - name: RABBITMQ_DEFAULT_USER diff --git a/deployment/MantaRayPlanCloud/templates/pg-admin.yaml b/deployment/MantaRayPlanCloud/templates/pg-admin.yaml index ef8a0ba..786bfa4 100644 --- a/deployment/MantaRayPlanCloud/templates/pg-admin.yaml +++ b/deployment/MantaRayPlanCloud/templates/pg-admin.yaml @@ -59,8 +59,6 @@ metadata: app: {{ .Values.pgadmin.app }} name: {{ .Values.pgadmin.name }} spec: - serviceAccountName: {{ .Values.serveraccount.name }} - automountServiceAccountToken: false replicas: 1 selector: matchLabels: @@ -72,6 +70,8 @@ spec: app: {{ .Values.pgadmin.app }} task: {{ .Values.pgadmin.name }} spec: + serviceAccountName: {{ .Values.serveraccount.name }} + automountServiceAccountToken: false containers: - name: {{ .Values.pgadmin.app }} image: "dpage/pgadmin4:latest" @@ -79,9 +79,11 @@ spec: resources: requests: ephemeral-storage: "1Gi" + cpu: 0.5 memory: "500Mi" limits: ephemeral-storage: "2Gi" + cpu: 1 memory: "1Gi" securityContext: runAsUser: 0 diff --git a/deployment/MantaRayPlanCloud/templates/seq.yaml b/deployment/MantaRayPlanCloud/templates/seq.yaml index ae6f12e..c635936 100644 --- a/deployment/MantaRayPlanCloud/templates/seq.yaml +++ b/deployment/MantaRayPlanCloud/templates/seq.yaml @@ -96,9 +96,11 @@ spec: resources: requests: ephemeral-storage: "1Gi" + cpu: 0.5 memory: "500Mi" limits: ephemeral-storage: "2Gi" + cpu: 1 memory: "1Gi" env: - name: ACCEPT_EULA diff --git a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml index 4ea086e..d5faf82 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-bff.yaml @@ -27,9 +27,11 @@ spec: resources: requests: ephemeral-storage: "1Gi" + cpu: 0.5 memory: "500Mi" limits: ephemeral-storage: "2Gi" + cpu: 1 memory: "1Gi" livenessProbe: httpGet: diff --git a/deployment/MantaRayPlanCloud/templates/viewer-web.yaml b/deployment/MantaRayPlanCloud/templates/viewer-web.yaml index 65d3499..2d6f723 100644 --- a/deployment/MantaRayPlanCloud/templates/viewer-web.yaml +++ b/deployment/MantaRayPlanCloud/templates/viewer-web.yaml @@ -64,9 +64,11 @@ spec: resources: requests: ephemeral-storage: "1Gi" + cpu: 0.5 memory: "500Mi" limits: ephemeral-storage: "2Gi" + cpu: 1 memory: "1Gi" livenessProbe: httpGet: From 5076cfdc0b69c2b349fa256b0e1482f5cfa2c607 Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sun, 6 Oct 2024 10:31:24 +0200 Subject: [PATCH 47/47] Change to new version --- .../MantaRayPlanCloud/environments/values-production.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/MantaRayPlanCloud/environments/values-production.yaml b/deployment/MantaRayPlanCloud/environments/values-production.yaml index 18ff046..3d47a8f 100644 --- a/deployment/MantaRayPlanCloud/environments/values-production.yaml +++ b/deployment/MantaRayPlanCloud/environments/values-production.yaml @@ -1,7 +1,7 @@ namespace: "manta-ray-plan-production" image: - tag: "v0.4.7" + tag: "v0.5.0" clusterIssuer: enabled: true