37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
|
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;
|
|||
|
}
|
|||
|
}
|