Skip to content

Commit 302b1c5

Browse files
authored
Improved Core Infrastructure: resilient Kafka, cleaner background workers, and API versioning (#61)
* Applied version to endpoints * Fixture for domain objects * Refactored Kafka consumer to ensure topic creation * Updated Kiota clients with the latest API definitions * Ensured release build to github actions
1 parent c14fc10 commit 302b1c5

File tree

39 files changed

+551
-591
lines changed

39 files changed

+551
-591
lines changed

.github/workflows/ecommerceddd-build.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,34 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
15-
- name: Setup .NET
16-
uses: actions/setup-dotnet@v1
17-
with:
18-
dotnet-version: 8.0.x
19-
- name: Restore dependencies
20-
run: dotnet restore EcommerceDDD.sln
21-
- name: Build
22-
run: dotnet build --no-restore EcommerceDDD.sln
23-
- name: Test
24-
run: dotnet test --no-build --verbosity normal EcommerceDDD.sln
14+
- uses: actions/checkout@v2
15+
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v1
18+
with:
19+
dotnet-version: 8.0.x
20+
21+
- name: Restore dependencies
22+
run: dotnet restore EcommerceDDD.sln
23+
24+
- name: Build (Release)
25+
run: dotnet build --no-restore -c Release EcommerceDDD.sln
26+
27+
- name: Test (Release)
28+
run: dotnet test --no-build --verbosity normal -c Release EcommerceDDD.sln
2529

2630
spa-test-verify:
2731
runs-on: ubuntu-latest
2832
defaults:
2933
run:
3034
working-directory: src/EcommerceDDD.Spa
35+
3136
steps:
3237
- uses: actions/checkout@v4
38+
3339
- uses: actions/setup-node@v4
3440
with:
3541
node-version: 18
42+
3643
- run: npm ci
3744
- run: npm run test
38-

docker-compose.yml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ services:
4646
interval: 10s
4747
timeout: 5s
4848
retries: 5
49-
start_period: 30s
49+
start_period: 20s
5050
networks:
5151
- ecommercedddnet
5252
ports:
@@ -59,31 +59,13 @@ services:
5959
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://kafka:29092,PLAINTEXT_HOST://kafka:9092'
6060
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
6161
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
62+
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
6263
restart:
6364
on-failure
6465
depends_on:
6566
zookeeper:
6667
condition: service_started
6768

68-
init-kafka:
69-
image: confluentinc/cp-kafka:latest
70-
entrypoint: [ '/bin/sh', '-c' ]
71-
networks:
72-
- ecommercedddnet
73-
environment:
74-
KAFKA_CLUSTERS_0_NAME: local
75-
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: 'kafka:29092'
76-
command: >
77-
/bin/sh -c "sleep 10 &&
78-
kafka-topics --bootstrap-server kafka:29092 --create --if-not-exists --topic Orders --replication-factor 1 --partitions 1 &&
79-
kafka-topics --bootstrap-server kafka:29092 --create --if-not-exists --topic Payments --replication-factor 1 --partitions 1 &&
80-
kafka-topics --bootstrap-server kafka:29092 --create --if-not-exists --topic Shipments --replication-factor 1 --partitions 1"
81-
restart:
82-
on-failure
83-
depends_on:
84-
kafka:
85-
condition: service_started
86-
8769
kafka_topics_ui:
8870
image: provectuslabs/kafka-ui:latest
8971
hostname: kafka-ui
@@ -349,7 +331,7 @@ services:
349331
postgres:
350332
condition: service_healthy
351333
kafka:
352-
condition: service_healthy
334+
condition: service_healthy
353335
ecommerceddd-products:
354336
condition: service_started
355337
connect:

src/Core/EcommerceDDD.Core.Infrastructure/EcommerceDDD.Core.Infrastructure.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<PackageReference Include="Scrutor" Version="6.0.1" />
3131
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="8.1.1" />
3232
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="8.1.1" />
33+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
3334
</ItemGroup>
3435

3536
<ItemGroup>

src/Core/EcommerceDDD.Core.Infrastructure/GlobalUsings.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
global using Confluent.Kafka;
2+
global using Duende.IdentityModel;
23
global using Duende.IdentityModel.Client;
34
global using EcommerceDDD.Core.CQRS.CommandHandling;
45
global using EcommerceDDD.Core.CQRS.QueryHandling;
@@ -14,10 +15,12 @@
1415
global using EcommerceDDD.Core.Infrastructure.Kafka.Serialization;
1516
global using EcommerceDDD.Core.Infrastructure.Kafka.Workers;
1617
global using EcommerceDDD.Core.Infrastructure.Marten;
18+
global using EcommerceDDD.Core.Infrastructure.Outbox;
1719
global using EcommerceDDD.Core.Infrastructure.Outbox.Workers;
1820
global using EcommerceDDD.Core.Infrastructure.WebApi;
1921
global using EcommerceDDD.Core.Infrastructure.Workers;
2022
global using EcommerceDDD.Core.Persistence;
23+
global using EcommerceDDD.Core.Reflection;
2124
global using EcommerceDDD.Core.Testing;
2225
global using Marten;
2326
global using Microsoft.AspNetCore.Authentication;
@@ -38,11 +41,11 @@
3841
global using Newtonsoft.Json;
3942
global using Newtonsoft.Json.Linq;
4043
global using Polly;
44+
global using System.Diagnostics;
4145
global using System.IdentityModel.Tokens.Jwt;
4246
global using System.Net.Http.Headers;
4347
global using System.Net.Mime;
4448
global using System.Reflection;
49+
global using System.Security.Claims;
4550
global using System.Text;
4651
global using Weasel.Core;
47-
global using Duende.IdentityModel;
48-
global using System.Security.Claims;

src/Core/EcommerceDDD.Core.Infrastructure/Identity/AuthPolicyBuilder.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
public static class AuthPolicyBuilder
44
{
5-
public static AuthorizationPolicy M2MAccess =>
6-
new AuthorizationPolicyBuilder()
7-
.RequireAuthenticatedUser()
8-
.RequireClaim("scope", "ecommerceddd-api.scope")
9-
.Build();
10-
115
public static AuthorizationPolicy CanRead =>
126
new AuthorizationPolicyBuilder()
137
.RequireAuthenticatedUser()
@@ -25,4 +19,4 @@ public static class AuthPolicyBuilder
2519
.RequireAuthenticatedUser()
2620
.RequireClaim("scope", "delete")
2721
.Build();
28-
}
22+
}

0 commit comments

Comments
 (0)