|
|
@ -282,40 +282,4 @@ public class Startup |
|
|
|
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; |
|
|
|
} |
|
|
|
} |