Skip to content

Commit b9e6e8c

Browse files
committed
Update appsettings and refactor code for services
Extensive modifications to `appsettings.json`: - Enabled and configured services: seq, consul, fabio, httpClient, jaeger, jwt, metrics, mongodb, outbox, rabbitMq, redis, restEase, swagger, security, and vault. - Updated logger settings: changed logging level to `debug`, updated excluded paths and properties, added Azure and ELK configurations. Code refactoring: - Removed conditional check for `VaultOptions.Enabled` in `Extensions.cs`. - Refactored `ProductServiceClient.cs` to use `ArgumentNullException.ThrowIfNull` for null checks.
1 parent 828c7a7 commit b9e6e8c

File tree

8 files changed

+340
-130
lines changed

8 files changed

+340
-130
lines changed

src/Genocs.Core.Demo.Worker/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"interval": "day"
100100
},
101101
"seq": {
102-
"enabled": false,
102+
"enabled": true,
103103
"url": "http://localhost:5341",
104104
"apiKey": "secret"
105105
},

src/Genocs.Secrets.Vault/Extensions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ private static IServiceCollection AddVault(this IServiceCollection services, str
8686
}
8787

8888
VaultOptions options = configuration.GetOptions<VaultOptions>(sectionName);
89-
if (!options.Enabled)
90-
{
91-
return services;
92-
}
9389

9490
VerifyOptions(options);
9591
services.AddSingleton(options);

src/apps/api-gateway/Genocs.APIGateway/appsettings.json

Lines changed: 137 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,40 @@
77
"displayBanner": true,
88
"displayVersion": true
99
},
10+
"consul": {
11+
"enabled": true,
12+
"url": "http://localhost:8500",
13+
"service": "api-gateway",
14+
"address": "docker.for.mac.localhost",
15+
"port": "5501",
16+
"pingEnabled": true,
17+
"pingEndpoint": "healthz",
18+
"pingInterval": 3,
19+
"removeAfterInterval": 3,
20+
"requestRetries": 3
21+
},
22+
"fabio": {
23+
"enabled": true,
24+
"url": "http://localhost:9999",
25+
"service": "api-gateway",
26+
"requestRetries": 3
27+
},
28+
"httpClient": {
29+
"type": "",
30+
"retries": 3,
31+
"services": {
32+
},
33+
"requestMasking": {
34+
"enabled": true,
35+
"maskTemplate": "*****"
36+
},
37+
"correlationIdHeader": "x-correlation-id"
38+
},
1039
"logger": {
1140
"level": "debug",
1241
"excludePaths": [
1342
"/",
14-
"/health",
43+
"/healthz",
1544
"/alive",
1645
"/metrics"
1746
],
@@ -32,6 +61,10 @@
3261
"console": {
3362
"enabled": true
3463
},
64+
"azure": {
65+
"enabled": true,
66+
"connectionString": "InstrumentationKey=1496274b-bda7-4ac6-88ab-9f73b4d3c7b8;IngestionEndpoint=https://italynorth-0.in.applicationinsights.azure.com/;LiveEndpoint=https://italynorth.livediagnostics.monitor.azure.com/;ApplicationId=c417f66d-3611-48a2-80fe-5a6d302bed4f"
67+
},
3568
"elk": {
3669
"enabled": false,
3770
"url": "http://localhost:9200"
@@ -48,34 +81,72 @@
4881
},
4982
"tags": {}
5083
},
84+
"jaeger": {
85+
"enabled": true,
86+
"serviceName": "api-gateway",
87+
"endpoint": "http://localhost:4317",
88+
"protocol": "Grpc",
89+
"processorType": "Batch",
90+
"maxQueueSize": 2048,
91+
"scheduledDelayMilliseconds": 5000,
92+
"exporterTimeoutMilliseconds": 30000,
93+
"maxExportBatchSize": 512
94+
},
5195
"jwt": {
96+
"enabled": true,
97+
"allowAnonymousEndpoints": [],
5298
"certificate": {
53-
"location": "certs/localhost.cer"
99+
"location": "certs/localhost.cer",
100+
"password": "test",
101+
"rawData": ""
54102
},
103+
"expiryMinutes": 30,
55104
"issuer": "genocs-identity-service",
56105
"validIssuer": "genocs-identity-service",
57106
"validateAudience": false,
58107
"validateIssuer": true,
59108
"validateLifetime": true,
60109
"expiry": "01:00:00"
61110
},
62-
"jaeger": {
111+
"metrics": {
63112
"enabled": true,
64-
"serviceName": "api-gateway",
65-
"udpHost": "localhost",
66-
"maxPacketSize": 65000
113+
"influxEnabled": false,
114+
"prometheusEnabled": false,
115+
"prometheusFormatter": null,
116+
"influxUrl": "http://localhost:8086",
117+
"database": "test",
118+
"env": "local",
119+
"interval": 5
120+
},
121+
"mongodb": {
122+
"connectionString": "mongodb://localhost:27017",
123+
"database": "api-gateway",
124+
"seed": false,
125+
"enableTracing": true
67126
},
68127
"prometheus": {
69128
"enabled": false,
70129
"endpoint": "/metrics"
71130
},
131+
"outbox": {
132+
"enabled": true,
133+
"type": "sequential",
134+
"expiry": 3600,
135+
"intervalMilliseconds": 2000,
136+
"inboxCollection": "inbox",
137+
"outboxCollection": "outbox",
138+
"disableTransactions": true
139+
},
72140
"rabbitMq": {
73141
"connectionName": "api-gateway",
142+
"messagesPersisted": true,
74143
"retries": 3,
75144
"retryInterval": 2,
76145
"conventionsCasing": "snakeCase",
77146
"logger": {
78-
"enabled": true
147+
"enabled": true,
148+
"logConnectionStatus": true,
149+
"logMessagePayload": true
79150
},
80151
"username": "guest",
81152
"password": "guest",
@@ -104,13 +175,66 @@
104175
"durable": true,
105176
"exclusive": false,
106177
"autoDelete": false,
107-
"template": "api-gateway/{{exchange}}.{{message}}"
178+
"template": "{{assembly}}/{{exchange}}.{{message}}"
108179
},
109180
"context": {
110181
"enabled": true,
111182
"header": "message_context"
112183
},
113-
"spanContextHeader": "span_context"
184+
"spanContextHeader": "span_context",
185+
"deadLetter": {
186+
"enabled": true,
187+
"prefix": "dlx-",
188+
"declare": true
189+
},
190+
"maxProducerChannels": 1000
191+
},
192+
"elk": {
193+
"enabled": false,
194+
"url": "http://localhost:9200",
195+
"indexFormat": "signalr-service-{0:yyyy.MM.dd}",
196+
"basicAuthEnabled": false,
197+
"username": "user",
198+
"password": "secret"
199+
},
200+
"redis": {
201+
"connectionString": "localhost",
202+
"instance": "api-gateway:",
203+
"database": 0
204+
},
205+
"restEase": {
206+
"loadBalancer": "",
207+
"services": []
208+
},
209+
"swagger": {
210+
"enabled": true,
211+
"reDocEnabled": false,
212+
"name": "Gateway",
213+
"title": "API Gateway",
214+
"version": "v01",
215+
"description": "API Gateway Service",
216+
"routePrefix": "swagger",
217+
"includeSecurity": true,
218+
"contactName": "Giovanni Nocco",
219+
"contactEmail": "[email protected]",
220+
"contactUrl": "https://www.genocs.com",
221+
"licenseName": "MIT",
222+
"licenseUrl": "https://www.genocs.com/license.html",
223+
"termsOfService": "https://www.genocs.com/terms_and_conditions.html",
224+
"serializeAsOpenApiV2": true,
225+
"servers": [
226+
{
227+
"url": "http://localhost:5501",
228+
"description": "Local version to be used for development"
229+
}
230+
]
231+
},
232+
"security": {
233+
"certificate": {
234+
"enabled": false,
235+
"header": "Certificate",
236+
"allowedHosts": [ "localhost", "identity" ]
237+
}
114238
},
115239
"reverseProxy": {
116240
"routes": {
@@ -198,26 +322,26 @@
198322
"username": "user",
199323
"password": "secret",
200324
"kv": {
201-
"enabled": true,
325+
"enabled": false,
202326
"engineVersion": 2,
203327
"mountPoint": "kv",
204328
"path": "api-gateway/settings"
205329
},
206330
"pki": {
207-
"enabled": true,
331+
"enabled": false,
208332
"roleName": "api-gateway",
209333
"commonName": "api-gateway.demo.io"
210334
},
211335
"lease": {
212336
"mongo": {
213337
"type": "database",
214338
"roleName": "api-gateway",
215-
"enabled": true,
339+
"enabled": false,
216340
"autoRenewal": true,
217341
"templates": {
218342
"connectionString": "mongodb://{{username}}:{{password}}@localhost:27017"
219343
}
220344
}
221345
}
222346
}
223-
}
347+
}

src/apps/identity/Genocs.Identities.WebApi/appsettings.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636
"correlationIdHeader": "x-correlation-id"
3737
},
3838
"logger": {
39-
"level": "information",
39+
"level": "debug",
4040
"excludePaths": [
4141
"/",
42-
"/ping",
42+
"/healthz",
43+
"/alive",
4344
"/metrics"
4445
],
4546
"excludeProperties": [
@@ -73,22 +74,23 @@
7374
"interval": "day"
7475
},
7576
"seq": {
76-
"enabled": false,
77+
"enabled": true,
7778
"url": "http://localhost:5341",
7879
"apiKey": "secret"
79-
}
80+
},
8081
"tags": {}
8182
},
8283
"jaeger": {
8384
"enabled": true,
84-
"serviceName": "identity-service",
85+
"serviceName": "identity",
8586
"udpHost": "localhost",
8687
"udpPort": 6831,
8788
"maxPacketSize": 65000,
8889
"sampler": "const",
8990
"excludePaths": [
9091
"/",
91-
"/ping",
92+
"/healthz",
93+
"/alive",
9294
"/metrics"
9395
]
9496
},
@@ -117,7 +119,7 @@
117119
},
118120
"mongodb": {
119121
"connectionString": "mongodb://localhost:27017",
120-
"database": "genocs-identity-service",
122+
"database": "identities",
121123
"seed": false,
122124
"enableTracing": true
123125
},
@@ -165,7 +167,7 @@
165167
"durable": true,
166168
"autoDelete": false,
167169
"type": "topic",
168-
"name": "identity"
170+
"name": "identities"
169171
},
170172
"queue": {
171173
"declare": true,
@@ -195,7 +197,7 @@
195197
"enabled": true,
196198
"reDocEnabled": false,
197199
"name": "v1",
198-
"title": "API",
200+
"title": "Identities",
199201
"version": "v1",
200202
"routePrefix": "swagger",
201203
"includeSecurity": true

src/apps/orders/Genocs.Orders.WebApi/Services/ProductServiceClient.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,11 @@ public ProductServiceClient(
3232
{
3333
_client = client ?? throw new ArgumentNullException(nameof(client));
3434

35+
ArgumentNullException.ThrowIfNull(httpClientOptions);
3536

36-
if (httpClientOptions is null)
37-
{
38-
throw new ArgumentNullException(nameof(httpClientOptions));
39-
}
37+
ArgumentNullException.ThrowIfNull(vaultOptions);
4038

41-
if (vaultOptions is null)
42-
{
43-
throw new ArgumentNullException(nameof(vaultOptions));
44-
}
45-
46-
if (securityOptions is null)
47-
{
48-
throw new ArgumentNullException(nameof(securityOptions));
49-
}
39+
ArgumentNullException.ThrowIfNull(securityOptions);
5040

5141
string? url = httpClientOptions?.Services?["products"];
5242

0 commit comments

Comments
 (0)