This repository was archived by the owner on Nov 17, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +37
-36
lines changed
src/Services/Basket/Basket.API Expand file tree Collapse file tree 2 files changed +37
-36
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments