Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 8438a6a

Browse files
authored
Merge pull request #1955 from teghoz/dev
move custom extension into a separate file
2 parents efb39de + 4857831 commit 8438a6a

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
namespace Microsoft.eShopOnContainers.Services.Basket.API;
2+
3+
public static class CustomExtensionMethods
4+
{
5+
public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration)
6+
{
7+
var hcBuilder = services.AddHealthChecks();
8+
9+
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
10+
11+
hcBuilder
12+
.AddRedis(
13+
configuration["ConnectionString"],
14+
name: "redis-check",
15+
tags: new string[] { "redis" });
16+
17+
if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
18+
{
19+
hcBuilder
20+
.AddAzureServiceBusTopic(
21+
configuration["EventBusConnection"],
22+
topicName: "eshop_event_bus",
23+
name: "basket-servicebus-check",
24+
tags: new string[] { "servicebus" });
25+
}
26+
else
27+
{
28+
hcBuilder
29+
.AddRabbitMQ(
30+
$"amqp://{configuration["EventBusConnection"]}",
31+
name: "basket-rabbitmqbus-check",
32+
tags: new string[] { "rabbitmqbus" });
33+
}
34+
35+
return services;
36+
}
37+
}

src/Services/Basket/Basket.API/Startup.cs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -282,40 +282,4 @@ private void ConfigureEventBus(IApplicationBuilder app)
282282
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
283283
eventBus.Subscribe<OrderStartedIntegrationEvent, OrderStartedIntegrationEventHandler>();
284284
}
285-
}
286-
287-
public static class CustomExtensionMethods
288-
{
289-
public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration)
290-
{
291-
var hcBuilder = services.AddHealthChecks();
292-
293-
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
294-
295-
hcBuilder
296-
.AddRedis(
297-
configuration["ConnectionString"],
298-
name: "redis-check",
299-
tags: new string[] { "redis" });
300-
301-
if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
302-
{
303-
hcBuilder
304-
.AddAzureServiceBusTopic(
305-
configuration["EventBusConnection"],
306-
topicName: "eshop_event_bus",
307-
name: "basket-servicebus-check",
308-
tags: new string[] { "servicebus" });
309-
}
310-
else
311-
{
312-
hcBuilder
313-
.AddRabbitMQ(
314-
$"amqp://{configuration["EventBusConnection"]}",
315-
name: "basket-rabbitmqbus-check",
316-
tags: new string[] { "rabbitmqbus" });
317-
}
318-
319-
return services;
320-
}
321285
}

0 commit comments

Comments
 (0)