Skip to content

Commit 7edec14

Browse files
committed
Refactored Core Infrastructure and Crosscutting (#61)
* Applied version to endpoints and ocelot routes. * Added crosscutting signalR API project. * Refactored Kafka consumer to ensure topic creation * Full replacement of Http/Integration services with Kiota clients. * Updated Kiota clients and client code with the latest API definitions. * Enhanced docker-compose and its service dependencies. * Ensured release build to github actions
1 parent 302b1c5 commit 7edec14

File tree

192 files changed

+4917
-1374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+4917
-1374
lines changed

EcommerceDDD.sln

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcommerceDDD.QuoteManagemen
6565
EndProject
6666
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcommerceDDD.InventoryManagement.Tests", "src\Services\EcommerceDDD.InventoryManagement.Tests\EcommerceDDD.InventoryManagement.Tests.csproj", "{487D7187-2669-4BB8-A3A7-F39031EC818B}"
6767
EndProject
68-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EcommerceDDD.ServiceClients", "src\Crosscutting\EcommerceDDD.ServiceClients\EcommerceDDD.ServiceClients.csproj", "{46F37BDA-92DA-439B-A31D-170D22EE88FE}"
68+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcommerceDDD.ServiceClients", "src\Crosscutting\EcommerceDDD.ServiceClients\EcommerceDDD.ServiceClients.csproj", "{46F37BDA-92DA-439B-A31D-170D22EE88FE}"
69+
EndProject
70+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EcommerceDDD.SignalR", "src\Crosscutting\EcommerceDDD.SignalR\EcommerceDDD.SignalR.csproj", "{F5E1FABB-0F84-4815-902E-A466964E80CA}"
6971
EndProject
7072
Global
7173
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -251,6 +253,14 @@ Global
251253
{46F37BDA-92DA-439B-A31D-170D22EE88FE}.Release|Any CPU.Build.0 = Release|Any CPU
252254
{46F37BDA-92DA-439B-A31D-170D22EE88FE}.Release|x64.ActiveCfg = Release|Any CPU
253255
{46F37BDA-92DA-439B-A31D-170D22EE88FE}.Release|x64.Build.0 = Release|Any CPU
256+
{F5E1FABB-0F84-4815-902E-A466964E80CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
257+
{F5E1FABB-0F84-4815-902E-A466964E80CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
258+
{F5E1FABB-0F84-4815-902E-A466964E80CA}.Debug|x64.ActiveCfg = Debug|Any CPU
259+
{F5E1FABB-0F84-4815-902E-A466964E80CA}.Debug|x64.Build.0 = Debug|Any CPU
260+
{F5E1FABB-0F84-4815-902E-A466964E80CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
261+
{F5E1FABB-0F84-4815-902E-A466964E80CA}.Release|Any CPU.Build.0 = Release|Any CPU
262+
{F5E1FABB-0F84-4815-902E-A466964E80CA}.Release|x64.ActiveCfg = Release|Any CPU
263+
{F5E1FABB-0F84-4815-902E-A466964E80CA}.Release|x64.Build.0 = Release|Any CPU
254264
EndGlobalSection
255265
GlobalSection(SolutionProperties) = preSolution
256266
HideSolutionNode = FALSE
@@ -284,6 +294,7 @@ Global
284294
{FD844762-CFC4-4A49-9831-042A86294BF3} = {7B1F8BA8-D8A4-4604-92F8-8AB9EA0485B8}
285295
{487D7187-2669-4BB8-A3A7-F39031EC818B} = {C90A4F2B-9DDF-40F8-B0EC-C5546622313E}
286296
{46F37BDA-92DA-439B-A31D-170D22EE88FE} = {2EBCF63E-7C14-47A7-B972-C7870434AD32}
297+
{F5E1FABB-0F84-4815-902E-A466964E80CA} = {2EBCF63E-7C14-47A7-B972-C7870434AD32}
287298
EndGlobalSection
288299
GlobalSection(ExtensibilityGlobals) = postSolution
289300
SolutionGuid = {920B9A56-71E3-492F-93BD-FA154EF349D2}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This project is an experimental full-stack application I use to combine several
3131
├── Crosscutting
3232
│ ├── ServiceClients
3333
│   ├── ApiGateway
34+
│   ├── SignalR
3435
│   └── IdentityServer
3536
3637
├── Services

docker-compose.yml

Lines changed: 99 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version: '3.8'
2+
13
services:
24
postgres:
35
image: postgres:latest
@@ -24,51 +26,57 @@ services:
2426
on-failure
2527

2628
zookeeper:
27-
image: confluentinc/cp-zookeeper:latest
28-
hostname: zookeeper
29+
image: confluentinc/cp-zookeeper:7.6.1
2930
container_name: zookeeper
30-
networks:
31-
- ecommercedddnet
3231
ports:
3332
- '2181:2181'
3433
environment:
3534
ZOOKEEPER_CLIENT_PORT: 2181
3635
ZOOKEEPER_TICK_TIME: 2000
37-
restart:
38-
on-failure
36+
volumes:
37+
- zookeeper-data:/var/lib/zookeeper/data
38+
- zookeeper-log:/var/lib/zookeeper/log
39+
networks:
40+
- ecommercedddnet
41+
restart: always
3942

4043
kafka:
41-
image: confluentinc/cp-kafka:latest
42-
hostname: kafka
44+
image: confluentinc/cp-kafka:7.6.1
4345
container_name: kafka
44-
healthcheck:
45-
test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "localhost:9092"]
46-
interval: 10s
47-
timeout: 5s
48-
retries: 5
49-
start_period: 20s
50-
networks:
51-
- ecommercedddnet
5246
ports:
5347
- '29092:29092'
5448
- '9092:9092'
5549
environment:
5650
KAFKA_BROKER_ID: 1
57-
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
58-
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT'
51+
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
52+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
5953
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://kafka:29092,PLAINTEXT_HOST://kafka:9092'
6054
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
6155
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
62-
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
63-
restart:
64-
on-failure
65-
depends_on:
56+
KAFKA_LOG_DIRS: /var/lib/kafka/data
57+
KAFKA_LOG_RETENTION_HOURS: 168
58+
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
59+
KAFKA_LOG_CLEANUP_POLICY: delete
60+
KAFKA_REPLICA_FETCH_MAX_BYTES: 104857600
61+
KAFKA_REPLICA_SOCKET_TIMEOUT_MS: 300000
62+
healthcheck:
63+
test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "kafka:29092"]
64+
interval: 20s
65+
timeout: 10s
66+
retries: 5
67+
start_period: 40s
68+
volumes:
69+
- kafka-data:/var/lib/kafka/data
70+
networks:
71+
- ecommercedddnet
72+
restart: always
73+
depends_on:
6674
zookeeper:
67-
condition: service_started
75+
condition: service_started
6876

6977
kafka_topics_ui:
7078
image: provectuslabs/kafka-ui:latest
71-
hostname: kafka-ui
79+
container_name: kafka-ui
7280
ports:
7381
- '8080:8080'
7482
environment:
@@ -78,32 +86,45 @@ services:
7886
- ecommercedddnet
7987
restart:
8088
on-failure
81-
depends_on:
82-
zookeeper:
83-
condition: service_started
89+
depends_on:
8490
kafka:
91+
condition: service_healthy
92+
postgres:
93+
condition: service_healthy
94+
connect:
95+
condition: service_started
96+
zookeeper:
8597
condition: service_started
8698

8799
connect:
88100
image: debezium/connect:2.5
89101
container_name: connect
90102
ports:
91-
- '8083:8083'
103+
- '8083:8083'
92104
environment:
93-
BOOTSTRAP_SERVERS: 'kafka:9092'
105+
BOOTSTRAP_SERVERS: 'kafka:29092'
94106
GROUP_ID: 1
95107
CONFIG_STORAGE_TOPIC: CONNECT_CONFIGS
96108
OFFSET_STORAGE_TOPIC: CONNECT_OFFSETS
97-
STATUS_STORAGE_TOPIC: CONNECT_STATUSES
109+
STATUS_STORAGE_TOPIC: CONNECT_STATUSES
110+
healthcheck:
111+
test: curl --fail http://localhost:8083/ || exit 1
112+
interval: 10s
113+
timeout: 5s
114+
retries: 10
115+
start_period: 40s
116+
volumes:
117+
- debezium-data:/kafka/data
98118
networks:
99119
- ecommercedddnet
100-
restart:
101-
on-failure
120+
restart: always
102121
depends_on:
103122
postgres:
104-
condition: service_started
123+
condition: service_healthy
105124
kafka:
106-
condition: service_started
125+
condition: service_healthy
126+
zookeeper:
127+
condition: service_started
107128

108129
pgadmin:
109130
image: dpage/pgadmin4:latest
@@ -115,7 +136,7 @@ services:
115136
volumes:
116137
- 'pgadmin:/var/lib/pgadmin'
117138
ports:
118-
- '$PGADMIN_PORT:80'
139+
- '8081:80'
119140
networks:
120141
- ecommercedddnet
121142
restart:
@@ -150,7 +171,7 @@ services:
150171
postgres:
151172
condition:
152173
service_healthy
153-
174+
154175
ecommerceddd-apigateway:
155176
image: ecommerceddd-apigateway
156177
container_name: ecommerceddd-apigateway
@@ -188,8 +209,36 @@ services:
188209
condition: service_started
189210
ecommerceddd-shipments:
190211
condition: service_started
212+
213+
ecommerceddd-signalr:
214+
image: ecommerceddd-signalr
215+
container_name: ecommerceddd-signalr
216+
build:
217+
context: .
218+
dockerfile: src/Crosscutting/EcommerceDDD.SignalR/Dockerfile
219+
environment:
220+
ASPNETCORE_ENVIRONMENT: '${ASPNETCORE_ENVIRONMENT:-Development}'
221+
ASPNETCORE_URLS: 'http://+:80'
222+
healthcheck:
223+
test: curl --fail http://ecommerceddd-signalr:80/health || exit 1
224+
interval: 10s
225+
timeout: 30s
226+
retries: 5
227+
start_period: 5s
228+
start_interval: 5s
229+
ports:
230+
- '5002:80'
231+
networks:
232+
- ecommercedddnet
233+
restart:
234+
always
235+
depends_on:
236+
ecommerceddd-identityserver:
237+
condition: service_started
238+
ecommerceddd-orders:
239+
condition: service_started
191240

192-
# Services
241+
# Services
193242
ecommerceddd-customers:
194243
image: ecommerceddd-customers
195244
container_name: ecommerceddd-customers
@@ -313,7 +362,7 @@ services:
313362
dockerfile: src/Services/EcommerceDDD.OrderProcessing/Dockerfile
314363
environment:
315364
ASPNETCORE_ENVIRONMENT: '${ASPNETCORE_ENVIRONMENT:-Development}'
316-
ASPNETCORE_URLS: 'http://+:80'
365+
ASPNETCORE_URLS: 'http://+:80'
317366
healthcheck:
318367
test: curl --fail http://ecommerceddd-orders:80/health || exit 1
319368
interval: 10s
@@ -329,15 +378,15 @@ services:
329378
on-failure
330379
depends_on:
331380
postgres:
332-
condition: service_healthy
381+
condition: service_healthy
333382
kafka:
334-
condition: service_healthy
335-
ecommerceddd-products:
336-
condition: service_started
383+
condition: service_healthy
337384
connect:
385+
condition: service_healthy
386+
ecommerceddd-products:
338387
condition: service_started
339388
ecommerceddd-identityserver:
340-
condition: service_started
389+
condition: service_started
341390

342391
ecommerceddd-payments:
343392
image: ecommerceddd-payments
@@ -410,7 +459,14 @@ services:
410459
networks:
411460
ecommercedddnet:
412461
driver: bridge
462+
ipam:
463+
config:
464+
- subnet: 172.28.0.0/16
413465

414466
volumes:
415467
postgres:
468+
zookeeper-data:
469+
zookeeper-log:
470+
kafka-data:
416471
pgadmin:
472+
debezium-data:
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
global using EcommerceDDD.Core.Infrastructure.Http;
21
global using EcommerceDDD.Core.Infrastructure.Identity;
3-
global using EcommerceDDD.Core.Infrastructure.Integration;
4-
global using EcommerceDDD.Core.Testing;
52
global using Microsoft.AspNetCore.Http;
63
global using Microsoft.Extensions.Caching.Memory;
7-
global using Newtonsoft.Json;
4+
global using Microsoft.Extensions.Options;
85
global using NSubstitute;
6+
global using System.IdentityModel.Tokens.Jwt;
97
global using System.Net;
8+
global using System.Text;
109
global using Xunit;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace EcommerceDDD.Core.Infrastructure.Tests.Http;
2+
3+
public class FakeHttpMessageHandler : HttpMessageHandler
4+
{
5+
private readonly HttpResponseMessage _fakeResponse;
6+
7+
public FakeHttpMessageHandler(HttpResponseMessage fakeResponse)
8+
{
9+
_fakeResponse = fakeResponse;
10+
}
11+
12+
protected override Task<HttpResponseMessage> SendAsync(
13+
HttpRequestMessage request,
14+
CancellationToken cancellationToken)
15+
{
16+
return Task.FromResult(_fakeResponse);
17+
}
18+
}

0 commit comments

Comments
 (0)