Browse Source

Standard names fix

pull/223/head
Christian Arenas 7 years ago
parent
commit
1a9adad2f4
8 changed files with 57 additions and 34 deletions
  1. +0
    -16
      src/Services/SagaManager/SagaManager/IntegrationEvents/ConfirmGracePeriodEvent.cs
  2. +2
    -2
      src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommandMsg.cs
  3. +0
    -9
      src/Services/SagaManager/SagaManager/IntegrationEvents/IConfirmGracePeriodEvent.cs
  4. +10
    -0
      src/Services/SagaManager/SagaManager/IntegrationEvents/ISagaManagingIntegrationEventService.cs
  5. +35
    -0
      src/Services/SagaManager/SagaManager/IntegrationEvents/SagaManagingIntegrationEventService.cs
  6. +1
    -1
      src/Services/SagaManager/SagaManager/Program.cs
  7. +2
    -0
      src/Services/SagaManager/SagaManager/SagaManager.csproj
  8. +7
    -6
      src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs

+ 0
- 16
src/Services/SagaManager/SagaManager/IntegrationEvents/ConfirmGracePeriodEvent.cs View File

@ -1,16 +0,0 @@
namespace SagaManager.IntegrationEvents
{
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using System;
public class ConfirmGracePeriodEvent : IConfirmGracePeriodEvent
{
private readonly IEventBus _eventBus;
public ConfirmGracePeriodEvent(IEventBus eventBus) =>
_eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
public void PublishThroughEventBus(IntegrationEvent evt) => _eventBus.Publish(evt);
}
}

src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodIntegrationEvent.cs → src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommandMsg.cs View File

@ -5,10 +5,10 @@
// Integration Events notes:
// An Event is “something that has happened in the past”, therefore its name has to be
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
public class ConfirmGracePeriodIntegrationEvent : IntegrationEvent
public class ConfirmGracePeriodCommandMsg : IntegrationEvent
{
public int OrderId { get;}
public ConfirmGracePeriodIntegrationEvent(int orderId) => OrderId = orderId;
public ConfirmGracePeriodCommandMsg(int orderId) => OrderId = orderId;
}
}

+ 0
- 9
src/Services/SagaManager/SagaManager/IntegrationEvents/IConfirmGracePeriodEvent.cs View File

@ -1,9 +0,0 @@
namespace SagaManager.IntegrationEvents
{
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
public interface IConfirmGracePeriodEvent
{
void PublishThroughEventBus(IntegrationEvent evt);
}
}

+ 10
- 0
src/Services/SagaManager/SagaManager/IntegrationEvents/ISagaManagingIntegrationEventService.cs View File

@ -0,0 +1,10 @@
namespace SagaManager.IntegrationEvents
{
using System.Threading.Tasks;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
public interface ISagaManagingIntegrationEventService
{
Task PublishThroughEventBusAsync(IntegrationEvent evt);
}
}

+ 35
- 0
src/Services/SagaManager/SagaManager/IntegrationEvents/SagaManagingIntegrationEventService.cs View File

@ -0,0 +1,35 @@
namespace SagaManager.IntegrationEvents
{
using System.Data.Common;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
using System;
public class SagaManagingIntegrationEventService : ISagaManagingIntegrationEventService
{
private readonly Func<DbConnection, IIntegrationEventLogService> _integrationEventLogServiceFactory;
private readonly IEventBus _eventBus;
private readonly OrderingContext _orderingContext;
private readonly IIntegrationEventLogService _eventLogService;
public SagaManagingIntegrationEventService(IEventBus eventBus, OrderingContext orderingContext,
Func<DbConnection, IIntegrationEventLogService> integrationEventLogServiceFactory)
{
_orderingContext = orderingContext ?? throw new ArgumentNullException(nameof(orderingContext));
_integrationEventLogServiceFactory = integrationEventLogServiceFactory ?? throw new ArgumentNullException(nameof(integrationEventLogServiceFactory));
_eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
_eventLogService = _integrationEventLogServiceFactory(_orderingContext.Database.GetDbConnection());
}
public async Task PublishThroughEventBusAsync(IntegrationEvent evt)
{
_eventBus.Publish(evt);
await _eventLogService.MarkEventAsPublishedAsync(evt);
}
}
}

+ 1
- 1
src/Services/SagaManager/SagaManager/Program.cs View File

@ -55,7 +55,7 @@ namespace SagaManager
.AddOptions()
.Configure<SagaManagerSettings>(Configuration)
.AddSingleton<ISagaManagerService, SagaManagerService>()
.AddSingleton<IConfirmGracePeriodEvent, ConfirmGracePeriodEvent>()
.AddSingleton<ISagaManagingIntegrationEventService, SagaManagingIntegrationEventService>()
.AddSingleton<IEventBus, EventBusRabbitMQ>()
.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>()
.AddSingleton<IRabbitMQPersistentConnection>(sp =>


+ 2
- 0
src/Services/SagaManager/SagaManager/SagaManager.csproj View File

@ -21,6 +21,8 @@
<ItemGroup>
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\IntegrationEventLogEF\IntegrationEventLogEF.csproj" />
<ProjectReference Include="..\..\Ordering\Ordering.Infrastructure\Ordering.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>


+ 7
- 6
src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs View File

@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace SagaManager.Services
@ -13,15 +14,15 @@ namespace SagaManager.Services
public class SagaManagerService : ISagaManagerService
{
private readonly SagaManagerSettings _settings;
private readonly IConfirmGracePeriodEvent _confirmGracePeriodEvent;
private readonly ISagaManagingIntegrationEventService _sagaManagingIntegrationEventService;
private readonly ILogger<SagaManagerService> _logger;
public SagaManagerService(IOptions<SagaManagerSettings> settings,
IConfirmGracePeriodEvent confirmGracePeriodEvent,
ISagaManagingIntegrationEventService sagaManagingIntegrationEventService,
ILogger<SagaManagerService> logger)
{
_settings = settings.Value;
_confirmGracePeriodEvent = confirmGracePeriodEvent;
_sagaManagingIntegrationEventService = sagaManagingIntegrationEventService;
_logger = logger;
}
@ -59,12 +60,12 @@ namespace SagaManager.Services
return orderIds;
}
private void Publish(int orderId)
private async Task Publish(int orderId)
{
var confirmGracePeriodEvent = new ConfirmGracePeriodIntegrationEvent(orderId);
var confirmGracePeriodEvent = new ConfirmGracePeriodCommandMsg(orderId);
// Publish through the Event Bus
_confirmGracePeriodEvent.PublishThroughEventBus(confirmGracePeriodEvent);
await _sagaManagingIntegrationEventService.PublishThroughEventBusAsync(confirmGracePeriodEvent);
}
}
}

Loading…
Cancel
Save