Merge pull request #1955 from teghoz/dev
move custom extension into a separate file
This commit is contained in:
commit
8438a6a652
37
src/Services/Basket/Basket.API/CustomExtensionMethods.cs
Normal file
37
src/Services/Basket/Basket.API/CustomExtensionMethods.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -282,40 +282,4 @@ public class Startup
|
|||||||
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
|
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
|
||||||
eventBus.Subscribe<OrderStartedIntegrationEvent, OrderStartedIntegrationEventHandler>();
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user