From 0fe244cc804427beeeb9ae324a215e562d312dc8 Mon Sep 17 00:00:00 2001 From: Sumit Ghosh Date: Mon, 11 Oct 2021 17:57:30 +0530 Subject: [PATCH] Moved all the namespace to globalusings --- .../AutofacModules/ApplicationModule.cs | 28 +- ...aitingValidationIntegrationEventHandler.cs | 44 +- ...angedToCancelledIntegrationEventHandler.cs | 45 +- ...tusChangedToPaidIntegrationEventHandler.cs | 45 +- ...ChangedToShippedIntegrationEventHandler.cs | 45 +- ...ToStockConfirmedIntegrationEventHandler.cs | 47 +- ...angedToSubmittedIntegrationEventHandler.cs | 50 +-- ...gedToAwaitingValidationIntegrationEvent.cs | 25 +- ...tatusChangedToCancelledIntegrationEvent.cs | 24 +- ...rderStatusChangedToPaidIntegrationEvent.cs | 25 +- ...rStatusChangedToShippedIntegrationEvent.cs | 24 +- ...ChangedToStockConfirmedIntegrationEvent.cs | 23 +- ...tatusChangedToSubmittedIntegrationEvent.cs | 23 +- .../Ordering.SignalrHub/NotificationHub.cs | 30 +- .../Ordering/Ordering.SignalrHub/Program.cs | 10 +- .../Ordering/Ordering.SignalrHub/Startup.cs | 413 ++++++++---------- 16 files changed, 393 insertions(+), 508 deletions(-) diff --git a/src/Services/Ordering/Ordering.SignalrHub/AutofacModules/ApplicationModule.cs b/src/Services/Ordering/Ordering.SignalrHub/AutofacModules/ApplicationModule.cs index e7b09f636..9d28154ea 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/AutofacModules/ApplicationModule.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/AutofacModules/ApplicationModule.cs @@ -1,26 +1,20 @@ -using Autofac; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Ordering.SignalrHub.IntegrationEvents; -using System.Reflection; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.AutofacModules; -namespace Ordering.SignalrHub.AutofacModules +public class ApplicationModule + : Autofac.Module { - public class ApplicationModule - : Autofac.Module - { - public string QueriesConnectionString { get; } + public string QueriesConnectionString { get; } - public ApplicationModule() - { - } + public ApplicationModule() + { + } - protected override void Load(ContainerBuilder builder) - { + protected override void Load(ContainerBuilder builder) + { - builder.RegisterAssemblyTypes(typeof(OrderStatusChangedToAwaitingValidationIntegrationEvent).GetTypeInfo().Assembly) - .AsClosedTypesOf(typeof(IIntegrationEventHandler<>)); + builder.RegisterAssemblyTypes(typeof(OrderStatusChangedToAwaitingValidationIntegrationEvent).GetTypeInfo().Assembly) + .AsClosedTypesOf(typeof(IIntegrationEventHandler<>)); - } } } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs index 17e2efa90..341b781ab 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs @@ -1,36 +1,28 @@ -using Microsoft.AspNetCore.SignalR; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.Extensions.Logging; -using Serilog.Context; -using System; -using System.Threading.Tasks; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents; -namespace Ordering.SignalrHub.IntegrationEvents +public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler : IIntegrationEventHandler { - public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler : IIntegrationEventHandler - { - private readonly IHubContext _hubContext; - private readonly ILogger _logger; + private readonly IHubContext _hubContext; + private readonly ILogger _logger; - public OrderStatusChangedToAwaitingValidationIntegrationEventHandler( - IHubContext hubContext, - ILogger logger) - { - _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } + public OrderStatusChangedToAwaitingValidationIntegrationEventHandler( + IHubContext hubContext, + ILogger logger) + { + _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + } - public async Task Handle(OrderStatusChangedToAwaitingValidationIntegrationEvent @event) + public async Task Handle(OrderStatusChangedToAwaitingValidationIntegrationEvent @event) + { + using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) { - using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) - { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); + _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - await _hubContext.Clients - .Group(@event.BuyerName) - .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); - } + await _hubContext.Clients + .Group(@event.BuyerName) + .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); } } } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs index 829ec39b8..aba5091b9 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs @@ -1,37 +1,28 @@ -using Microsoft.AspNetCore.SignalR; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.Extensions.Logging; -using Ordering.SignalrHub.IntegrationEvents.Events; -using Serilog.Context; -using System; -using System.Threading.Tasks; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; -namespace Ordering.SignalrHub.IntegrationEvents.EventHandling +public class OrderStatusChangedToCancelledIntegrationEventHandler : IIntegrationEventHandler { - public class OrderStatusChangedToCancelledIntegrationEventHandler : IIntegrationEventHandler - { - private readonly IHubContext _hubContext; - private readonly ILogger _logger; + private readonly IHubContext _hubContext; + private readonly ILogger _logger; - public OrderStatusChangedToCancelledIntegrationEventHandler( - IHubContext hubContext, - ILogger logger) - { - _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } + public OrderStatusChangedToCancelledIntegrationEventHandler( + IHubContext hubContext, + ILogger logger) + { + _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + } - public async Task Handle(OrderStatusChangedToCancelledIntegrationEvent @event) + public async Task Handle(OrderStatusChangedToCancelledIntegrationEvent @event) + { + using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) { - using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) - { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); + _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - await _hubContext.Clients - .Group(@event.BuyerName) - .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); - } + await _hubContext.Clients + .Group(@event.BuyerName) + .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); } } } \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs index 836e02d3c..03fc04356 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs @@ -1,37 +1,28 @@ -using Microsoft.AspNetCore.SignalR; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.Extensions.Logging; -using Ordering.SignalrHub.IntegrationEvents.Events; -using Serilog.Context; -using System; -using System.Threading.Tasks; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; -namespace Ordering.SignalrHub.IntegrationEvents.EventHandling +public class OrderStatusChangedToPaidIntegrationEventHandler : IIntegrationEventHandler { - public class OrderStatusChangedToPaidIntegrationEventHandler : IIntegrationEventHandler - { - private readonly IHubContext _hubContext; - private readonly ILogger _logger; + private readonly IHubContext _hubContext; + private readonly ILogger _logger; - public OrderStatusChangedToPaidIntegrationEventHandler( - IHubContext hubContext, - ILogger logger) - { - _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } + public OrderStatusChangedToPaidIntegrationEventHandler( + IHubContext hubContext, + ILogger logger) + { + _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + } - public async Task Handle(OrderStatusChangedToPaidIntegrationEvent @event) + public async Task Handle(OrderStatusChangedToPaidIntegrationEvent @event) + { + using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) { - using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) - { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); + _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - await _hubContext.Clients - .Group(@event.BuyerName) - .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); - } + await _hubContext.Clients + .Group(@event.BuyerName) + .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); } } } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs index 40664c268..663f7ae3a 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs @@ -1,37 +1,28 @@ -using Microsoft.AspNetCore.SignalR; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.Extensions.Logging; -using Ordering.SignalrHub.IntegrationEvents.Events; -using Serilog.Context; -using System; -using System.Threading.Tasks; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; -namespace Ordering.SignalrHub.IntegrationEvents.EventHandling +public class OrderStatusChangedToShippedIntegrationEventHandler : IIntegrationEventHandler { - public class OrderStatusChangedToShippedIntegrationEventHandler : IIntegrationEventHandler - { - private readonly IHubContext _hubContext; - private readonly ILogger _logger; + private readonly IHubContext _hubContext; + private readonly ILogger _logger; - public OrderStatusChangedToShippedIntegrationEventHandler( - IHubContext hubContext, - ILogger logger) - { - _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } + public OrderStatusChangedToShippedIntegrationEventHandler( + IHubContext hubContext, + ILogger logger) + { + _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + } - public async Task Handle(OrderStatusChangedToShippedIntegrationEvent @event) + public async Task Handle(OrderStatusChangedToShippedIntegrationEvent @event) + { + using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) { - using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) - { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); + _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - await _hubContext.Clients - .Group(@event.BuyerName) - .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); - } + await _hubContext.Clients + .Group(@event.BuyerName) + .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); } } } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs index 3ffddfff9..aa662065d 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs @@ -1,38 +1,29 @@ -using Microsoft.AspNetCore.SignalR; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.Extensions.Logging; -using Ordering.SignalrHub.IntegrationEvents.Events; -using Serilog.Context; -using System; -using System.Threading.Tasks; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; -namespace Ordering.SignalrHub.IntegrationEvents.EventHandling +public class OrderStatusChangedToStockConfirmedIntegrationEventHandler : + IIntegrationEventHandler { - public class OrderStatusChangedToStockConfirmedIntegrationEventHandler : - IIntegrationEventHandler - { - private readonly IHubContext _hubContext; - private readonly ILogger _logger; + private readonly IHubContext _hubContext; + private readonly ILogger _logger; - public OrderStatusChangedToStockConfirmedIntegrationEventHandler( - IHubContext hubContext, - ILogger logger) - { - _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } + public OrderStatusChangedToStockConfirmedIntegrationEventHandler( + IHubContext hubContext, + ILogger logger) + { + _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + } - public async Task Handle(OrderStatusChangedToStockConfirmedIntegrationEvent @event) + public async Task Handle(OrderStatusChangedToStockConfirmedIntegrationEvent @event) + { + using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) { - using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) - { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); + _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - await _hubContext.Clients - .Group(@event.BuyerName) - .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); - } + await _hubContext.Clients + .Group(@event.BuyerName) + .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); } } } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs index e9109939e..4fa0d86d9 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs @@ -1,38 +1,28 @@ -using Microsoft.AspNetCore.SignalR; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.Extensions.Logging; -using Ordering.SignalrHub.IntegrationEvents.Events; -using Serilog.Context; -using System; -using System.Threading.Tasks; - -namespace Ordering.SignalrHub.IntegrationEvents.EventHandling +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; +public class OrderStatusChangedToSubmittedIntegrationEventHandler : + IIntegrationEventHandler { - public class OrderStatusChangedToSubmittedIntegrationEventHandler : - IIntegrationEventHandler - { - private readonly IHubContext _hubContext; - private readonly ILogger _logger; + private readonly IHubContext _hubContext; + private readonly ILogger _logger; - public OrderStatusChangedToSubmittedIntegrationEventHandler( - IHubContext hubContext, - ILogger logger) - { - _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } + public OrderStatusChangedToSubmittedIntegrationEventHandler( + IHubContext hubContext, + ILogger logger) + { + _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + } - public async Task Handle(OrderStatusChangedToSubmittedIntegrationEvent @event) + public async Task Handle(OrderStatusChangedToSubmittedIntegrationEvent @event) + { + using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) { - using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) - { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); + _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - await _hubContext.Clients - .Group(@event.BuyerName) - .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); - } + await _hubContext.Clients + .Group(@event.BuyerName) + .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); } } -} \ No newline at end of file +} diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs index dc1727951..acbbb6fe2 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs @@ -1,18 +1,15 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - -namespace Ordering.SignalrHub.IntegrationEvents +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents; +public record OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent { - public record OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent - { - public int OrderId { get; } - public string OrderStatus { get; } - public string BuyerName { get; } + public int OrderId { get; } + public string OrderStatus { get; } + public string BuyerName { get; } - public OrderStatusChangedToAwaitingValidationIntegrationEvent(int orderId, string orderStatus, string buyerName) - { - OrderId = orderId; - OrderStatus = orderStatus; - BuyerName = buyerName; - } + public OrderStatusChangedToAwaitingValidationIntegrationEvent(int orderId, string orderStatus, string buyerName) + { + OrderId = orderId; + OrderStatus = orderStatus; + BuyerName = buyerName; } } + diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs index 1ea290082..5df74ac78 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToCancelledIntegrationEvent.cs @@ -1,18 +1,16 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.Events; -namespace Ordering.SignalrHub.IntegrationEvents.Events +public record OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent { - public record OrderStatusChangedToCancelledIntegrationEvent : IntegrationEvent - { - public int OrderId { get; } - public string OrderStatus { get; } - public string BuyerName { get; } + public int OrderId { get; } + public string OrderStatus { get; } + public string BuyerName { get; } - public OrderStatusChangedToCancelledIntegrationEvent(int orderId, string orderStatus, string buyerName) - { - OrderId = orderId; - OrderStatus = orderStatus; - BuyerName = buyerName; - } + public OrderStatusChangedToCancelledIntegrationEvent(int orderId, string orderStatus, string buyerName) + { + OrderId = orderId; + OrderStatus = orderStatus; + BuyerName = buyerName; } } + diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs index e3bf88190..63246835d 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToPaidIntegrationEvent.cs @@ -1,19 +1,16 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.Events; -namespace Ordering.SignalrHub.IntegrationEvents.Events +public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent { - public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent - { - public int OrderId { get; } - public string OrderStatus { get; } - public string BuyerName { get; } + public int OrderId { get; } + public string OrderStatus { get; } + public string BuyerName { get; } - public OrderStatusChangedToPaidIntegrationEvent(int orderId, - string orderStatus, string buyerName) - { - OrderId = orderId; - OrderStatus = orderStatus; - BuyerName = buyerName; - } + public OrderStatusChangedToPaidIntegrationEvent(int orderId, + string orderStatus, string buyerName) + { + OrderId = orderId; + OrderStatus = orderStatus; + BuyerName = buyerName; } } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs index 436b5a95a..9306d198e 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToShippedIntegrationEvent.cs @@ -1,18 +1,16 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.Events; -namespace Ordering.SignalrHub.IntegrationEvents.Events +public record OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent { - public record OrderStatusChangedToShippedIntegrationEvent : IntegrationEvent - { - public int OrderId { get; } - public string OrderStatus { get; } - public string BuyerName { get; } + public int OrderId { get; } + public string OrderStatus { get; } + public string BuyerName { get; } - public OrderStatusChangedToShippedIntegrationEvent(int orderId, string orderStatus, string buyerName) - { - OrderId = orderId; - OrderStatus = orderStatus; - BuyerName = buyerName; - } + public OrderStatusChangedToShippedIntegrationEvent(int orderId, string orderStatus, string buyerName) + { + OrderId = orderId; + OrderStatus = orderStatus; + BuyerName = buyerName; } } + diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs index 137967ff6..896ef34cb 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToStockConfirmedIntegrationEvent.cs @@ -1,18 +1,15 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.Events; -namespace Ordering.SignalrHub.IntegrationEvents.Events +public record OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent { - public record OrderStatusChangedToStockConfirmedIntegrationEvent : IntegrationEvent - { - public int OrderId { get; } - public string OrderStatus { get; } - public string BuyerName { get; } + public int OrderId { get; } + public string OrderStatus { get; } + public string BuyerName { get; } - public OrderStatusChangedToStockConfirmedIntegrationEvent(int orderId, string orderStatus, string buyerName) - { - OrderId = orderId; - OrderStatus = orderStatus; - BuyerName = buyerName; - } + public OrderStatusChangedToStockConfirmedIntegrationEvent(int orderId, string orderStatus, string buyerName) + { + OrderId = orderId; + OrderStatus = orderStatus; + BuyerName = buyerName; } } diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToSubmittedIntegrationEvent.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToSubmittedIntegrationEvent.cs index 0d2de4abe..23f01044e 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToSubmittedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToSubmittedIntegrationEvent.cs @@ -1,18 +1,15 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.Events; -namespace Ordering.SignalrHub.IntegrationEvents.Events +public record OrderStatusChangedToSubmittedIntegrationEvent : IntegrationEvent { - public record OrderStatusChangedToSubmittedIntegrationEvent : IntegrationEvent - { - public int OrderId { get; } - public string OrderStatus { get; } - public string BuyerName { get; } + public int OrderId { get; } + public string OrderStatus { get; } + public string BuyerName { get; } - public OrderStatusChangedToSubmittedIntegrationEvent(int orderId, string orderStatus, string buyerName) - { - OrderId = orderId; - OrderStatus = orderStatus; - BuyerName = buyerName; - } + public OrderStatusChangedToSubmittedIntegrationEvent(int orderId, string orderStatus, string buyerName) + { + OrderId = orderId; + OrderStatus = orderStatus; + BuyerName = buyerName; } } diff --git a/src/Services/Ordering/Ordering.SignalrHub/NotificationHub.cs b/src/Services/Ordering/Ordering.SignalrHub/NotificationHub.cs index 7696a4da1..9f545bba4 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/NotificationHub.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/NotificationHub.cs @@ -1,24 +1,18 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.SignalR; -using System; -using System.Threading.Tasks; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub; -namespace Ordering.SignalrHub +[Authorize] +public class NotificationsHub : Hub { - [Authorize] - public class NotificationsHub : Hub - { - public override async Task OnConnectedAsync() - { - await Groups.AddToGroupAsync(Context.ConnectionId, Context.User.Identity.Name); - await base.OnConnectedAsync(); - } + public override async Task OnConnectedAsync() + { + await Groups.AddToGroupAsync(Context.ConnectionId, Context.User.Identity.Name); + await base.OnConnectedAsync(); + } - public override async Task OnDisconnectedAsync(Exception ex) - { - await Groups.RemoveFromGroupAsync(Context.ConnectionId, Context.User.Identity.Name); - await base.OnDisconnectedAsync(ex); - } + public override async Task OnDisconnectedAsync(Exception ex) + { + await Groups.RemoveFromGroupAsync(Context.ConnectionId, Context.User.Identity.Name); + await base.OnDisconnectedAsync(ex); } } diff --git a/src/Services/Ordering/Ordering.SignalrHub/Program.cs b/src/Services/Ordering/Ordering.SignalrHub/Program.cs index d73e1da2a..e472539fd 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/Program.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/Program.cs @@ -1,12 +1,4 @@ -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Serilog; -using System; -using System.IO; -using Ordering.SignalrHub; - -var configuration = GetConfiguration(); +var configuration = GetConfiguration(); Log.Logger = CreateSerilogLogger(configuration); diff --git a/src/Services/Ordering/Ordering.SignalrHub/Startup.cs b/src/Services/Ordering/Ordering.SignalrHub/Startup.cs index a4a5d08c7..944e82b52 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/Startup.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/Startup.cs @@ -1,274 +1,249 @@ -using Autofac; -using Autofac.Extensions.DependencyInjection; -using HealthChecks.UI.Client; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Diagnostics.HealthChecks; -using Microsoft.Azure.ServiceBus; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using Microsoft.Extensions.Logging; -using Ordering.SignalrHub.AutofacModules; -using Ordering.SignalrHub.IntegrationEvents; -using Ordering.SignalrHub.IntegrationEvents.EventHandling; -using Ordering.SignalrHub.IntegrationEvents.Events; -using RabbitMQ.Client; -using System; -using System.IdentityModel.Tokens.Jwt; -using System.Threading.Tasks; - -namespace Ordering.SignalrHub +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub; + +public class Startup { - public class Startup + public Startup(IConfiguration configuration) { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } + Configuration = configuration; + } + + public IConfiguration Configuration { get; } - public IConfiguration Configuration { get; } + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + public IServiceProvider ConfigureServices(IServiceCollection services) + { + services + .AddCustomHealthCheck(Configuration) + .AddCors(options => + { + options.AddPolicy("CorsPolicy", + builder => builder + .AllowAnyMethod() + .AllowAnyHeader() + .SetIsOriginAllowed((host) => true) + .AllowCredentials()); + }); - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - public IServiceProvider ConfigureServices(IServiceCollection services) + if (Configuration.GetValue("IsClusterEnv") == bool.TrueString) { services - .AddCustomHealthCheck(Configuration) - .AddCors(options => - { - options.AddPolicy("CorsPolicy", - builder => builder - .AllowAnyMethod() - .AllowAnyHeader() - .SetIsOriginAllowed((host) => true) - .AllowCredentials()); - }); - - if (Configuration.GetValue("IsClusterEnv") == bool.TrueString) - { - services - .AddSignalR() - .AddStackExchangeRedis(Configuration["SignalrStoreConnectionString"]); - } - else - { - services.AddSignalR(); - } + .AddSignalR() + .AddStackExchangeRedis(Configuration["SignalrStoreConnectionString"]); + } + else + { + services.AddSignalR(); + } - if (Configuration.GetValue("AzureServiceBusEnabled")) + if (Configuration.GetValue("AzureServiceBusEnabled")) + { + services.AddSingleton(sp => { - services.AddSingleton(sp => - { - var serviceBusConnectionString = Configuration["EventBusConnection"]; - var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString); + var serviceBusConnectionString = Configuration["EventBusConnection"]; + var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString); - var subscriptionClientName = Configuration["SubscriptionClientName"]; + var subscriptionClientName = Configuration["SubscriptionClientName"]; - return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName); - }); - } - else + return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName); + }); + } + else + { + services.AddSingleton(sp => { - services.AddSingleton(sp => + var logger = sp.GetRequiredService>(); + + + var factory = new ConnectionFactory() { - var logger = sp.GetRequiredService>(); + HostName = Configuration["EventBusConnection"], + DispatchConsumersAsync = true + }; + if (!string.IsNullOrEmpty(Configuration["EventBusUserName"])) + { + factory.UserName = Configuration["EventBusUserName"]; + } - var factory = new ConnectionFactory() - { - HostName = Configuration["EventBusConnection"], - DispatchConsumersAsync = true - }; + if (!string.IsNullOrEmpty(Configuration["EventBusPassword"])) + { + factory.Password = Configuration["EventBusPassword"]; + } - if (!string.IsNullOrEmpty(Configuration["EventBusUserName"])) - { - factory.UserName = Configuration["EventBusUserName"]; - } + var retryCount = 5; + if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) + { + retryCount = int.Parse(Configuration["EventBusRetryCount"]); + } - if (!string.IsNullOrEmpty(Configuration["EventBusPassword"])) - { - factory.Password = Configuration["EventBusPassword"]; - } + return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount); + }); + } - var retryCount = 5; - if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) - { - retryCount = int.Parse(Configuration["EventBusRetryCount"]); - } + ConfigureAuthService(services); - return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount); - }); - } + RegisterEventBus(services); - ConfigureAuthService(services); + services.AddOptions(); - RegisterEventBus(services); + //configure autofac + var container = new ContainerBuilder(); + container.RegisterModule(new ApplicationModule()); + container.Populate(services); - services.AddOptions(); + return new AutofacServiceProvider(container.Build()); + } - //configure autofac - var container = new ContainerBuilder(); - container.RegisterModule(new ApplicationModule()); - container.Populate(services); + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) + { + //loggerFactory.AddConsole(Configuration.GetSection("Logging")); + //loggerFactory.AddDebug(); + //loggerFactory.AddAzureWebAppDiagnostics(); + //loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace); - return new AutofacServiceProvider(container.Build()); - } + var pathBase = Configuration["PATH_BASE"]; - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) + if (!string.IsNullOrEmpty(pathBase)) { - //loggerFactory.AddConsole(Configuration.GetSection("Logging")); - //loggerFactory.AddDebug(); - //loggerFactory.AddAzureWebAppDiagnostics(); - //loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace); + loggerFactory.CreateLogger().LogDebug("Using PATH BASE '{pathBase}'", pathBase); + app.UsePathBase(pathBase); + } - var pathBase = Configuration["PATH_BASE"]; + app.UseRouting(); + app.UseCors("CorsPolicy"); + app.UseAuthentication(); + app.UseAuthorization(); - if (!string.IsNullOrEmpty(pathBase)) + app.UseEndpoints(endpoints => + { + endpoints.MapHealthChecks("/hc", new HealthCheckOptions() { - loggerFactory.CreateLogger().LogDebug("Using PATH BASE '{pathBase}'", pathBase); - app.UsePathBase(pathBase); - } - - app.UseRouting(); - app.UseCors("CorsPolicy"); - app.UseAuthentication(); - app.UseAuthorization(); - - app.UseEndpoints(endpoints => + Predicate = _ => true, + ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse + }); + endpoints.MapHealthChecks("/liveness", new HealthCheckOptions { - endpoints.MapHealthChecks("/hc", new HealthCheckOptions() - { - Predicate = _ => true, - ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse - }); - endpoints.MapHealthChecks("/liveness", new HealthCheckOptions - { - Predicate = r => r.Name.Contains("self") - }); - endpoints.MapHub("/hub/notificationhub"); + Predicate = r => r.Name.Contains("self") }); + endpoints.MapHub("/hub/notificationhub"); + }); - ConfigureEventBus(app); - } + ConfigureEventBus(app); + } - private void ConfigureEventBus(IApplicationBuilder app) - { - var eventBus = app.ApplicationServices.GetRequiredService(); - - eventBus.Subscribe(); - eventBus.Subscribe(); - eventBus.Subscribe(); - eventBus.Subscribe(); - eventBus.Subscribe(); - eventBus.Subscribe(); - } + private void ConfigureEventBus(IApplicationBuilder app) + { + var eventBus = app.ApplicationServices.GetRequiredService(); + + eventBus.Subscribe(); + eventBus.Subscribe(); + eventBus.Subscribe(); + eventBus.Subscribe(); + eventBus.Subscribe(); + eventBus.Subscribe(); + } - private void ConfigureAuthService(IServiceCollection services) - { - // prevent from mapping "sub" claim to nameidentifier. - JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub"); + private void ConfigureAuthService(IServiceCollection services) + { + // prevent from mapping "sub" claim to nameidentifier. + JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub"); - var identityUrl = Configuration.GetValue("IdentityUrl"); + var identityUrl = Configuration.GetValue("IdentityUrl"); - services.AddAuthentication(options => - { - options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - }).AddJwtBearer(options => + }).AddJwtBearer(options => + { + options.Authority = identityUrl; + options.RequireHttpsMetadata = false; + options.Audience = "orders.signalrhub"; + options.Events = new JwtBearerEvents { - options.Authority = identityUrl; - options.RequireHttpsMetadata = false; - options.Audience = "orders.signalrhub"; - options.Events = new JwtBearerEvents + OnMessageReceived = context => { - OnMessageReceived = context => + var accessToken = context.Request.Query["access_token"]; + + var path = context.HttpContext.Request.Path; + if (!string.IsNullOrEmpty(accessToken) && (path.StartsWithSegments("/hub/notificationhub"))) { - var accessToken = context.Request.Query["access_token"]; - - var path = context.HttpContext.Request.Path; - if (!string.IsNullOrEmpty(accessToken) && (path.StartsWithSegments("/hub/notificationhub"))) - { - context.Token = accessToken; - } - return Task.CompletedTask; + context.Token = accessToken; } - }; - }); - } + return Task.CompletedTask; + } + }; + }); + } - private void RegisterEventBus(IServiceCollection services) + private void RegisterEventBus(IServiceCollection services) + { + if (Configuration.GetValue("AzureServiceBusEnabled")) { - if (Configuration.GetValue("AzureServiceBusEnabled")) + services.AddSingleton(sp => { - services.AddSingleton(sp => - { - var serviceBusPersisterConnection = sp.GetRequiredService(); - var iLifetimeScope = sp.GetRequiredService(); - var logger = sp.GetRequiredService>(); - var eventBusSubcriptionsManager = sp.GetRequiredService(); - - return new EventBusServiceBus(serviceBusPersisterConnection, logger, - eventBusSubcriptionsManager, iLifetimeScope); - }); - } - else + var serviceBusPersisterConnection = sp.GetRequiredService(); + var iLifetimeScope = sp.GetRequiredService(); + var logger = sp.GetRequiredService>(); + var eventBusSubcriptionsManager = sp.GetRequiredService(); + + return new EventBusServiceBus(serviceBusPersisterConnection, logger, + eventBusSubcriptionsManager, iLifetimeScope); + }); + } + else + { + services.AddSingleton(sp => { - services.AddSingleton(sp => + var subscriptionClientName = Configuration["SubscriptionClientName"]; + var rabbitMQPersistentConnection = sp.GetRequiredService(); + var iLifetimeScope = sp.GetRequiredService(); + var logger = sp.GetRequiredService>(); + var eventBusSubcriptionsManager = sp.GetRequiredService(); + + var retryCount = 5; + if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) { - var subscriptionClientName = Configuration["SubscriptionClientName"]; - var rabbitMQPersistentConnection = sp.GetRequiredService(); - var iLifetimeScope = sp.GetRequiredService(); - var logger = sp.GetRequiredService>(); - var eventBusSubcriptionsManager = sp.GetRequiredService(); - - var retryCount = 5; - if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) - { - retryCount = int.Parse(Configuration["EventBusRetryCount"]); - } + retryCount = int.Parse(Configuration["EventBusRetryCount"]); + } - return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount); - }); - } - - services.AddSingleton(); + return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount); + }); } + + services.AddSingleton(); } +} - public static class CustomExtensionMethods +public static class CustomExtensionMethods +{ + public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration) { - public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration) - { - var hcBuilder = services.AddHealthChecks(); + var hcBuilder = services.AddHealthChecks(); - hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy()); + hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy()); - if (configuration.GetValue("AzureServiceBusEnabled")) - { - hcBuilder - .AddAzureServiceBusTopic( - configuration["EventBusConnection"], - topicName: "eshop_event_bus", - name: "signalr-servicebus-check", - tags: new string[] { "servicebus" }); - } - else - { - hcBuilder - .AddRabbitMQ( - $"amqp://{configuration["EventBusConnection"]}", - name: "signalr-rabbitmqbus-check", - tags: new string[] { "rabbitmqbus" }); - } - - return services; + if (configuration.GetValue("AzureServiceBusEnabled")) + { + hcBuilder + .AddAzureServiceBusTopic( + configuration["EventBusConnection"], + topicName: "eshop_event_bus", + name: "signalr-servicebus-check", + tags: new string[] { "servicebus" }); } + else + { + hcBuilder + .AddRabbitMQ( + $"amqp://{configuration["EventBusConnection"]}", + name: "signalr-rabbitmqbus-check", + tags: new string[] { "rabbitmqbus" }); + } + + return services; } }