@@ -88,7 +88,7 @@ protected virtual void ConfigureEventBus(IApplicationBuilder app)
88
88
}
89
89
}
90
90
91
- static class CustomExtensionMethods
91
+ internal static class CustomExtensionMethods
92
92
{
93
93
public static IServiceCollection AddAppInsight ( this IServiceCollection services , IConfiguration configuration )
94
94
{
@@ -171,53 +171,50 @@ public static IServiceCollection AddSwagger(this IServiceCollection services, IC
171
171
public static IServiceCollection AddEventBus ( this IServiceCollection services , IConfiguration configuration )
172
172
{
173
173
if ( configuration . GetValue < bool > ( "AzureServiceBusEnabled" ) )
174
+ {
175
+ services . AddSingleton < IEventBus , EventBusServiceBus > ( sp =>
174
176
{
175
- services . AddSingleton < IEventBus , EventBusServiceBus > ( sp =>
176
- {
177
- var serviceBusPersisterConnection = sp . GetRequiredService < IServiceBusPersisterConnection > ( ) ;
178
- var iLifetimeScope = sp . GetRequiredService < ILifetimeScope > ( ) ;
179
- var logger = sp . GetRequiredService < ILogger < EventBusServiceBus > > ( ) ;
180
- var eventBusSubcriptionsManager = sp . GetRequiredService < IEventBusSubscriptionsManager > ( ) ;
181
- string subscriptionName = configuration [ "SubscriptionClientName" ] ;
182
-
183
- return new EventBusServiceBus ( serviceBusPersisterConnection , logger ,
184
- eventBusSubcriptionsManager , iLifetimeScope , subscriptionName ) ;
185
- } ) ;
177
+ var serviceBusPersisterConnection = sp . GetRequiredService < IServiceBusPersisterConnection > ( ) ;
178
+ var iLifetimeScope = sp . GetRequiredService < ILifetimeScope > ( ) ;
179
+ var logger = sp . GetRequiredService < ILogger < EventBusServiceBus > > ( ) ;
180
+ var eventBusSubscriptionManager = sp . GetRequiredService < IEventBusSubscriptionsManager > ( ) ;
181
+ string subscriptionName = configuration [ "SubscriptionClientName" ] ;
182
+
183
+ return new EventBusServiceBus ( serviceBusPersisterConnection , logger ,
184
+ eventBusSubscriptionManager , iLifetimeScope , subscriptionName ) ;
185
+ } ) ;
186
186
187
- }
188
- else
187
+ }
188
+ else
189
+ {
190
+ services . AddSingleton < IEventBus , EventBusRabbitMQ > ( sp =>
189
191
{
190
- services . AddSingleton < IEventBus , EventBusRabbitMQ > ( sp =>
192
+ var subscriptionClientName = configuration [ "SubscriptionClientName" ] ;
193
+ var rabbitMQPersistentConnection = sp . GetRequiredService < IRabbitMQPersistentConnection > ( ) ;
194
+ var iLifetimeScope = sp . GetRequiredService < ILifetimeScope > ( ) ;
195
+ var logger = sp . GetRequiredService < ILogger < EventBusRabbitMQ > > ( ) ;
196
+ var eventBusSubscriptionManager = sp . GetRequiredService < IEventBusSubscriptionsManager > ( ) ;
197
+
198
+ var retryCount = 5 ;
199
+ if ( ! string . IsNullOrEmpty ( configuration [ "EventBusRetryCount" ] ) )
191
200
{
192
- var subscriptionClientName = configuration [ "SubscriptionClientName" ] ;
193
- var rabbitMQPersistentConnection = sp . GetRequiredService < IRabbitMQPersistentConnection > ( ) ;
194
- var iLifetimeScope = sp . GetRequiredService < ILifetimeScope > ( ) ;
195
- var logger = sp . GetRequiredService < ILogger < EventBusRabbitMQ > > ( ) ;
196
- var eventBusSubcriptionsManager = sp . GetRequiredService < IEventBusSubscriptionsManager > ( ) ;
197
-
198
- var retryCount = 5 ;
199
- if ( ! string . IsNullOrEmpty ( configuration [ "EventBusRetryCount" ] ) )
200
- {
201
- retryCount = int . Parse ( configuration [ "EventBusRetryCount" ] ) ;
202
- }
201
+ retryCount = int . Parse ( configuration [ "EventBusRetryCount" ] ) ;
202
+ }
203
203
204
- return new EventBusRabbitMQ ( rabbitMQPersistentConnection , logger , iLifetimeScope , eventBusSubcriptionsManager , subscriptionClientName , retryCount ) ;
205
- } ) ;
206
- }
204
+ return new EventBusRabbitMQ ( rabbitMQPersistentConnection , logger , iLifetimeScope , eventBusSubscriptionManager , subscriptionClientName , retryCount ) ;
205
+ } ) ;
206
+ }
207
207
208
- services . AddSingleton < IEventBusSubscriptionsManager , InMemoryEventBusSubscriptionsManager > ( ) ;
209
- services . AddTransient < ProductPriceChangedIntegrationEventHandler > ( ) ;
210
- services . AddTransient < OrderStatusChangedToShippedIntegrationEventHandler > ( ) ;
211
- services . AddTransient < OrderStatusChangedToPaidIntegrationEventHandler > ( ) ;
208
+ services . AddSingleton < IEventBusSubscriptionsManager , InMemoryEventBusSubscriptionsManager > ( ) ;
209
+ services . AddTransient < ProductPriceChangedIntegrationEventHandler > ( ) ;
210
+ services . AddTransient < OrderStatusChangedToShippedIntegrationEventHandler > ( ) ;
211
+ services . AddTransient < OrderStatusChangedToPaidIntegrationEventHandler > ( ) ;
212
212
213
- return services ;
213
+ return services ;
214
214
}
215
215
216
216
public static IServiceCollection AddCustomHealthCheck ( this IServiceCollection services , IConfiguration configuration )
217
217
{
218
- var accountName = configuration . GetValue < string > ( "AzureStorageAccountName" ) ;
219
- var accountKey = configuration . GetValue < string > ( "AzureStorageAccountKey" ) ;
220
-
221
218
var hcBuilder = services . AddHealthChecks ( ) ;
222
219
223
220
hcBuilder
0 commit comments