1+ namespace Shared . Extensions
2+ {
3+ using System ;
4+ using System . Net . Http ;
5+ using General ;
6+ using Microsoft . Extensions . DependencyInjection ;
7+ using Microsoft . Extensions . Diagnostics . HealthChecks ;
8+
9+ /// <summary>
10+ ///
11+ /// </summary>
12+ public static class HealthChecksBuilderExtensions
13+ {
14+ #region Methods
15+
16+ /// <summary>
17+ /// Adds the estate management service.
18+ /// </summary>
19+ /// <param name="builder">The builder.</param>
20+ /// <param name="customHttpHandler">The custom HTTP handler.</param>
21+ /// <returns></returns>
22+ public static IHealthChecksBuilder AddEstateManagementService ( this IHealthChecksBuilder builder ,
23+ Func < IServiceProvider , HttpClientHandler > customHttpHandler = null )
24+ {
25+ Uri uri = new Uri ( $ "{ ConfigurationReader . GetValue ( "AppSettings" , "EstateManagementApi" ) } /health") ;
26+
27+ return builder . AddUrlGroup ( uri ,
28+ HttpMethod . Get ,
29+ "Estate Management Service" ,
30+ HealthStatus . Unhealthy ,
31+ new [ ] { "estatemanagement" } ,
32+ configureHttpMessageHandler : customHttpHandler ) ;
33+ }
34+
35+ /// <summary>
36+ /// Adds the estate reporting service.
37+ /// </summary>
38+ /// <param name="builder">The builder.</param>
39+ /// <param name="customHttpHandler">The custom HTTP handler.</param>
40+ /// <returns></returns>
41+ public static IHealthChecksBuilder AddEstateReportingService ( this IHealthChecksBuilder builder ,
42+ Func < IServiceProvider , HttpClientHandler > customHttpHandler = null )
43+ {
44+ Uri uri = new Uri ( $ "{ ConfigurationReader . GetValue ( "AppSettings" , "EstateReportingApi" ) } /health") ;
45+
46+ return builder . AddUrlGroup ( uri ,
47+ HttpMethod . Get ,
48+ "Estate Reporting Service" ,
49+ HealthStatus . Unhealthy ,
50+ new [ ] { "estatereporting" } ,
51+ configureHttpMessageHandler : customHttpHandler ) ;
52+ }
53+
54+ /// <summary>
55+ /// Adds the file processor service.
56+ /// </summary>
57+ /// <param name="builder">The builder.</param>
58+ /// <param name="customHttpHandler">The custom HTTP handler.</param>
59+ /// <returns></returns>
60+ public static IHealthChecksBuilder AddFileProcessorService ( this IHealthChecksBuilder builder ,
61+ Func < IServiceProvider , HttpClientHandler > customHttpHandler = null )
62+ {
63+ Uri uri = new Uri ( $ "{ ConfigurationReader . GetValue ( "AppSettings" , "FileProcessorApi" ) } /health") ;
64+
65+ return builder . AddUrlGroup ( uri ,
66+ name : "File Processor Service" ,
67+ httpMethod : HttpMethod . Get ,
68+ failureStatus : HealthStatus . Unhealthy ,
69+ tags : new [ ] { "fileprocessing" } ,
70+ configureHttpMessageHandler : customHttpHandler ) ;
71+ }
72+
73+ /// <summary>
74+ /// Adds the messaging service.
75+ /// </summary>
76+ /// <param name="builder">The builder.</param>
77+ /// <param name="customHttpHandler">The custom HTTP handler.</param>
78+ /// <returns></returns>
79+ public static IHealthChecksBuilder AddMessagingService ( this IHealthChecksBuilder builder ,
80+ Func < IServiceProvider , HttpClientHandler > customHttpHandler = null )
81+ {
82+ Uri uri = new Uri ( $ "{ ConfigurationReader . GetValue ( "AppSettings" , "MessagingServiceApi" ) } /health") ;
83+
84+ return builder . AddUrlGroup ( uri ,
85+ HttpMethod . Get ,
86+ "Messaging Service" ,
87+ HealthStatus . Unhealthy ,
88+ new [ ] { "messaging" , "email" , "sms" } ,
89+ configureHttpMessageHandler : customHttpHandler ) ;
90+ }
91+
92+ /// <summary>
93+ /// Adds the security service.
94+ /// </summary>
95+ /// <param name="builder">The builder.</param>
96+ /// <param name="customHttpHandler">The custom HTTP handler.</param>
97+ /// <returns></returns>
98+ public static IHealthChecksBuilder AddSecurityService ( this IHealthChecksBuilder builder ,
99+ Func < IServiceProvider , HttpClientHandler > customHttpHandler = null )
100+ {
101+ Uri uri = new Uri ( $ "{ ConfigurationReader . GetValue ( "SecurityConfiguration" , "Authority" ) } /health") ;
102+ return builder . AddUrlGroup ( uri ,
103+ HttpMethod . Get ,
104+ "Security Service" ,
105+ HealthStatus . Unhealthy ,
106+ new [ ] { "security" , "authorisation" } ,
107+ configureHttpMessageHandler : customHttpHandler ) ;
108+ }
109+
110+ /// <summary>
111+ /// Adds the transaction processor service.
112+ /// </summary>
113+ /// <param name="builder">The builder.</param>
114+ /// <param name="customHttpHandler">The custom HTTP handler.</param>
115+ /// <returns></returns>
116+ public static IHealthChecksBuilder AddTransactionProcessorService ( this IHealthChecksBuilder builder ,
117+ Func < IServiceProvider , HttpClientHandler > customHttpHandler = null )
118+ {
119+ Uri uri = new Uri ( $ "{ ConfigurationReader . GetValue ( "AppSettings" , "TransactionProcessorApi" ) } /health") ;
120+
121+ return builder . AddUrlGroup ( uri ,
122+ name : "Transaction Processor Service" ,
123+ httpMethod : HttpMethod . Get ,
124+ failureStatus : HealthStatus . Unhealthy ,
125+ tags : new [ ] { "transactionprocessing" } ,
126+ configureHttpMessageHandler : customHttpHandler ) ;
127+ }
128+
129+ /// <summary>
130+ /// Adds the voucher management service.
131+ /// </summary>
132+ /// <param name="builder">The builder.</param>
133+ /// <param name="customHttpHandler">The custom HTTP handler.</param>
134+ /// <returns></returns>
135+ public static IHealthChecksBuilder AddVoucherManagementService ( this IHealthChecksBuilder builder ,
136+ Func < IServiceProvider , HttpClientHandler > customHttpHandler = null )
137+ {
138+ Uri uri = new Uri ( $ "{ ConfigurationReader . GetValue ( "AppSettings" , "VoucherManagementApi" ) } /health") ;
139+
140+ return builder . AddUrlGroup ( uri ,
141+ name : "Voucher Management Service" ,
142+ httpMethod : HttpMethod . Get ,
143+ failureStatus : HealthStatus . Unhealthy ,
144+ tags : new [ ] { "voucherprocessing" } ,
145+ configureHttpMessageHandler : customHttpHandler ) ;
146+ }
147+
148+ #endregion
149+ }
150+ }
0 commit comments