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

Commit

Permalink
Merge pull request #1955 from teghoz/dev
Browse files Browse the repository at this point in the history
move custom extension into a separate file
  • Loading branch information
erjain authored Sep 2, 2022
2 parents efb39de + 4857831 commit 8438a6a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
37 changes: 37 additions & 0 deletions src/Services/Basket/Basket.API/CustomExtensionMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Microsoft.eShopOnContainers.Services.Basket.API;

public static class CustomExtensionMethods
{
public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration)
{
var hcBuilder = services.AddHealthChecks();

hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());

hcBuilder
.AddRedis(
configuration["ConnectionString"],
name: "redis-check",
tags: new string[] { "redis" });

if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
{
hcBuilder
.AddAzureServiceBusTopic(
configuration["EventBusConnection"],
topicName: "eshop_event_bus",
name: "basket-servicebus-check",
tags: new string[] { "servicebus" });
}
else
{
hcBuilder
.AddRabbitMQ(
$"amqp://{configuration["EventBusConnection"]}",
name: "basket-rabbitmqbus-check",
tags: new string[] { "rabbitmqbus" });
}

return services;
}
}
36 changes: 0 additions & 36 deletions src/Services/Basket/Basket.API/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,40 +282,4 @@ private void ConfigureEventBus(IApplicationBuilder app)
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
eventBus.Subscribe<OrderStartedIntegrationEvent, OrderStartedIntegrationEventHandler>();
}
}

public static class CustomExtensionMethods
{
public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration)
{
var hcBuilder = services.AddHealthChecks();

hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());

hcBuilder
.AddRedis(
configuration["ConnectionString"],
name: "redis-check",
tags: new string[] { "redis" });

if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
{
hcBuilder
.AddAzureServiceBusTopic(
configuration["EventBusConnection"],
topicName: "eshop_event_bus",
name: "basket-servicebus-check",
tags: new string[] { "servicebus" });
}
else
{
hcBuilder
.AddRabbitMQ(
$"amqp://{configuration["EventBusConnection"]}",
name: "basket-rabbitmqbus-check",
tags: new string[] { "rabbitmqbus" });
}

return services;
}
}

0 comments on commit 8438a6a

Please sign in to comment.