Skip to content

Commit

Permalink
Event Handler Service: Subscribe to all events (and don't subscribe i…
Browse files Browse the repository at this point in the history
…n Consumer API anymore) (#604)

* wip

* fix: change the remove migration script

* feat: add new project

* chore: update solution file

* feat: Add Dockerfile

* wip

* feat: add service

* refactor: improve availability of the consumer api

* test: rename var

* feat: add json files

* refactoring: minor improvements

* refactor: various improvements

* fix: Update Dockerfile

* fix: Change Docker base image to aspnet-alpine

* feat: add package reference for GitHubActionsTestLoggger

* refactor: rename to EventHandlerService

* fix: remove prop from service configuration

* chore: make admin api and consumer api available from WSL

* fix: remove Worker property from configuration

* chore: change "service" property in log config

* chore: make blob storage work locally

* ci: add event handler service to pipeline docker-compose file

* ci: add building of ehs container image to test pipeline

* ci: add publish-ehs workflow

* fix: set DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=0

* fix: install libicu for EventHandlerService and IdentityDeletionJob

* ci: make buildContainerImage script executable

* fix: install icu-libs via apk add

* chore: change namein pipelines and dockerimage to event handler

* refactor: fix method naming

* chore: add .mono to .gitignore

* feat: add event handler to helm chart

* chore: remove unnecessary properties

* chore: add event handler to launch configuration

* chore: add Rider run configuration

* test: fix compiler error

---------

Co-authored-by: Mika Herrmann <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Timo Notheisen <[email protected]>
Co-authored-by: Timo Notheisen <[email protected]>
  • Loading branch information
5 people authored Apr 22, 2024
1 parent cd2bf90 commit 6afcb27
Show file tree
Hide file tree
Showing 25 changed files with 867 additions and 19 deletions.
16 changes: 16 additions & 0 deletions .ci/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ services:
- source: Config
target: app/appsettings.override.json

event-handler-service:
container_name: event-handler-service-test
build:
context: ..
dockerfile: EventHandlerService/src/EventHandlerService/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
depends_on:
database:
condition: service_started
rabbitmq:
condition: service_started
configs:
- source: Config
target: app/appsettings.override.json

### infrastructure ###

azure-storage-emulator:
Expand Down
11 changes: 11 additions & 0 deletions .ci/eh/buildContainerImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env node

import { $ } from "zx";
import { getRequiredEnvVar } from "../lib.js";

const tag = getRequiredEnvVar("TAG");

const platforms = process.env.PLATFORMS ?? "linux/amd64,linux/arm64";
const push = process.env.PUSH === "1" ? ["--push", "--provenance=true", "--sbom=true"] : "";

await $`docker buildx build --file ./EventHandlerService/src/EventHandlerService/Dockerfile --tag ghcr.io/nmshd/backbone-event-handler:${tag} --platform ${platforms} ${push} .`;
46 changes: 46 additions & 0 deletions .github/workflows/publish-ehs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish Event Handler Service Container Image

on:
push:
tags:
- "eh/*"

jobs:
publish-eh-container-image:
name: Publish Event Handler Service Container Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install script dependencies
run: npm install --prefix ./.ci
- name: Docker Login
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from git tag
id: extract-version-from-git-tag
run: echo "VERSION=$(./.ci/extractVersionFromGitTag.js)" >> $GITHUB_OUTPUT
env:
GIT_TAG: ${{ github.ref_name }}
- name: Log in to Docker Hub for accessing the cloud builder
uses: docker/login-action@v3
with:
username: ${{ secrets.CLOUD_BUILDER_USERNAME }}
password: ${{ secrets.CLOUD_BUILDER_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: cloud
endpoint: "jssoft/js-soft"
- name: Build and Push Container Image
run: ./.ci/eh/buildContainerImage.js
env:
TAG: ${{ steps.extract-version-from-git-tag.outputs.VERSION }}
PUSH: 1
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@ jobs:
TAG: test
PLATFORMS: linux/amd64

build-eh-container-image:
name: Build Event Handler Service Container Image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install script dependencies
run: npm install --prefix ./.ci
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
run: ./.ci/eh/buildContainerImage.js
env:
TAG: test
PLATFORMS: linux/amd64

build-aui-container-image:
name: Build Admin UI Container Image
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# mono
.mono

# Build results
[Dd]ebug/
[Dd]ebugPublic/
Expand Down
56 changes: 56 additions & 0 deletions .run/Multi-Launch_ Backbone.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Multi-Launch: Backbone" type="com.intellij.execution.configurations.multilaunch" factoryName="MultiLaunchConfiguration">
<rows>
<ExecutableRowSnapshot>
<option name="condition">
<ConditionSnapshot>
<option name="type" value="immediately"/>
</ConditionSnapshot>
</option>
<option name="disableDebugging" value="true"/>
<option name="executable">
<ExecutableSnapshot>
<option name="id" value="runConfig:Docker.docker-compose: Compose Deployment"/>
</ExecutableSnapshot>
</option>
</ExecutableRowSnapshot>
<ExecutableRowSnapshot>
<option name="condition">
<ConditionSnapshot>
<option name="type" value="immediately"/>
</ConditionSnapshot>
</option>
<option name="executable">
<ExecutableSnapshot>
<option name="id" value="runConfig:.NET Launch Settings Profile.ConsumerApi: Default"/>
</ExecutableSnapshot>
</option>
</ExecutableRowSnapshot>
<ExecutableRowSnapshot>
<option name="condition">
<ConditionSnapshot>
<option name="type" value="immediately"/>
</ConditionSnapshot>
</option>
<option name="executable">
<ExecutableSnapshot>
<option name="id" value="runConfig:.NET Launch Settings Profile.AdminApi: Default"/>
</ExecutableSnapshot>
</option>
</ExecutableRowSnapshot>
<ExecutableRowSnapshot>
<option name="condition">
<ConditionSnapshot>
<option name="type" value="immediately"/>
</ConditionSnapshot>
</option>
<option name="executable">
<ExecutableSnapshot>
<option name="id" value="runConfig:.NET Project.EventHandlerService"/>
</ExecutableSnapshot>
</option>
</ExecutableRowSnapshot>
</rows>
<method v="2"/>
</configuration>
</component>
2 changes: 1 addition & 1 deletion AdminApi/src/AdminApi/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Local",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy",
"ASPNETCORE_URLS": "http://localhost:8082"
"ASPNETCORE_URLS": "http://*:8082"
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions Backbone.sln
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Files.Infrastructure.Tests"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Messages.Domain.Tests", "Modules\Messages\test\Messages.Domain.Tests\Messages.Domain.Tests.csproj", "{83A86879-670B-4F22-8835-EE1D0AB49AA9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventHandlerService", "EventHandlerService", "{11FE034C-FA73-4766-99DB-D2C606018934}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D54A9259-7708-45C1-B8D9-448B97F43B80}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{2429FCAB-2058-4403-94DA-DA26B1655A7D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventHandlerService", "EventHandlerService\src\EventHandlerService\EventHandlerService.csproj", "{B4664E79-77A5-41AE-8480-C449ED5B2576}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventHandlerService.Tests", "EventHandlerService\test\EventHandlerService.Tests\EventHandlerService.Tests.csproj", "{D47E0FE1-23A0-4A96-AF57-E3CE71A132AD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -697,6 +707,14 @@ Global
{83A86879-670B-4F22-8835-EE1D0AB49AA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83A86879-670B-4F22-8835-EE1D0AB49AA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{83A86879-670B-4F22-8835-EE1D0AB49AA9}.Release|Any CPU.Build.0 = Release|Any CPU
{B4664E79-77A5-41AE-8480-C449ED5B2576}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4664E79-77A5-41AE-8480-C449ED5B2576}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4664E79-77A5-41AE-8480-C449ED5B2576}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4664E79-77A5-41AE-8480-C449ED5B2576}.Release|Any CPU.Build.0 = Release|Any CPU
{D47E0FE1-23A0-4A96-AF57-E3CE71A132AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D47E0FE1-23A0-4A96-AF57-E3CE71A132AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D47E0FE1-23A0-4A96-AF57-E3CE71A132AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D47E0FE1-23A0-4A96-AF57-E3CE71A132AD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -828,6 +846,10 @@ Global
{9AB91A36-1E62-490A-9CF3-2137CA15658F} = {4F812E23-62EB-4B79-8ECA-5CA72CF5D3BC}
{EE7F27E9-9DD9-41FC-923D-05D595829A03} = {2D0BC8E9-ED6B-49D9-937C-1616ED40FB3E}
{83A86879-670B-4F22-8835-EE1D0AB49AA9} = {BBE908B0-D642-4002-8A88-9F1726BA8CB6}
{D54A9259-7708-45C1-B8D9-448B97F43B80} = {11FE034C-FA73-4766-99DB-D2C606018934}
{2429FCAB-2058-4403-94DA-DA26B1655A7D} = {11FE034C-FA73-4766-99DB-D2C606018934}
{B4664E79-77A5-41AE-8480-C449ED5B2576} = {D54A9259-7708-45C1-B8D9-448B97F43B80}
{D47E0FE1-23A0-4A96-AF57-E3CE71A132AD} = {2429FCAB-2058-4403-94DA-DA26B1655A7D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1F3BD2C6-7CB3-450F-A21A-23EA520D5B7A}
Expand Down
9 changes: 7 additions & 2 deletions Backbone.slnLaunch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"Name": "Admin UI \u002B Consumer API",
"Name": "Backbone (Full)",
"Projects": [
{
"Name": "ConsumerApi\\ConsumerApi.csproj",
Expand All @@ -16,7 +16,12 @@
"Name": "AdminApi\\src\\AdminApi\\AdminApi.csproj",
"Action": "Start",
"DebugTarget": ""
},
{
"Name": "EventHandlerService\\src\\EventHandlerService\\EventHandlerService.csproj",
"Action": "Start",
"DebugTarget": ""
}
]
}
]
]
11 changes: 0 additions & 11 deletions ConsumerApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Autofac.Extensions.DependencyInjection;
using Backbone.BuildingBlocks.API;
using Backbone.BuildingBlocks.API.Extensions;
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.EventBus;
using Backbone.BuildingBlocks.Application.QuotaCheck;
using Backbone.BuildingBlocks.Infrastructure.Persistence.Database;
using Backbone.Common.Infrastructure;
Expand Down Expand Up @@ -218,16 +217,6 @@ static void Configure(WebApplication app)
});

app.UseResponseCaching();

var eventBus = app.Services.GetRequiredService<IEventBus>();
var modules = app.Services.GetRequiredService<IEnumerable<AbstractModule>>();

foreach (var module in modules)
{
module.ConfigureEventBus(eventBus);
}

eventBus.StartConsuming();
}

static void LoadConfiguration(WebApplicationBuilder webApplicationBuilder, string[] strings)
Expand Down
4 changes: 2 additions & 2 deletions ConsumerApi/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"Default": {
"commandName": "Project",
"environmentVariables": {
"Modules__Files__Infrastructure__BlobStorage__ConnectionInfo": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;",
"Modules__Files__Infrastructure__BlobStorage__ConnectionInfo": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;",
"ASPNETCORE_ENVIRONMENT": "Local",
"ASPNETCORE_URLS": "http://localhost:8081"
"ASPNETCORE_URLS": "http://*:8081"
}
}
}
Expand Down
Loading

0 comments on commit 6afcb27

Please sign in to comment.