Swamy/04 jan2021-small-refactoring (#1571)
* Small Refactoring inside IntegrationEventLogEF * Small Refactoring inside BuildingBlocks folder
This commit is contained in:
parent
70a5e7bff6
commit
1e2760c366
@ -1,5 +1,4 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Devspaces.Support
|
namespace Devspaces.Support
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Devspaces.Support
|
namespace Devspaces.Support
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using System.Threading.Tasks;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.Threading.Tasks;
|
|||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
||||||
{
|
{
|
||||||
public interface IIntegrationEventHandler<in TIntegrationEvent> : IIntegrationEventHandler
|
public interface IIntegrationEventHandler<in TIntegrationEvent> : IIntegrationEventHandler
|
||||||
where TIntegrationEvent: IntegrationEvent
|
where TIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
Task Handle(TIntegrationEvent @event);
|
Task Handle(TIntegrationEvent @event);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
|
|||||||
public class SubscriptionInfo
|
public class SubscriptionInfo
|
||||||
{
|
{
|
||||||
public bool IsDynamic { get; }
|
public bool IsDynamic { get; }
|
||||||
public Type HandlerType{ get; }
|
public Type HandlerType { get; }
|
||||||
|
|
||||||
private SubscriptionInfo(bool isDynamic, Type handlerType)
|
private SubscriptionInfo(bool isDynamic, Type handlerType)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
||||||
{
|
{
|
||||||
public class DefaultServiceBusPersisterConnection :IServiceBusPersisterConnection
|
public class DefaultServiceBusPersisterConnection : IServiceBusPersisterConnection
|
||||||
{
|
{
|
||||||
private readonly ILogger<DefaultServiceBusPersisterConnection> _logger;
|
private readonly ILogger<DefaultServiceBusPersisterConnection> _logger;
|
||||||
private readonly ServiceBusConnectionStringBuilder _serviceBusConnectionStringBuilder;
|
private readonly ServiceBusConnectionStringBuilder _serviceBusConnectionStringBuilder;
|
||||||
@ -26,7 +26,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
|||||||
|
|
||||||
public ITopicClient CreateModel()
|
public ITopicClient CreateModel()
|
||||||
{
|
{
|
||||||
if(_topicClient.IsClosedOrClosing)
|
if (_topicClient.IsClosedOrClosing)
|
||||||
{
|
{
|
||||||
_topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
|
_topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
|
||||||
{
|
{
|
||||||
public enum EventStateEnum
|
public enum EventStateEnum
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
using System;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Reflection;
|
using System.Linq;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Common;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage;
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -15,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services
|
||||||
{
|
{
|
||||||
public class IntegrationEventLogService : IIntegrationEventLogService,IDisposable
|
public class IntegrationEventLogService : IIntegrationEventLogService, IDisposable
|
||||||
{
|
{
|
||||||
private readonly IntegrationEventLogContext _integrationEventLogContext;
|
private readonly IntegrationEventLogContext _integrationEventLogContext;
|
||||||
private readonly DbConnection _dbConnection;
|
private readonly DbConnection _dbConnection;
|
||||||
@ -43,9 +38,10 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Servi
|
|||||||
var result = await _integrationEventLogContext.IntegrationEventLogs
|
var result = await _integrationEventLogContext.IntegrationEventLogs
|
||||||
.Where(e => e.TransactionId == tid && e.State == EventStateEnum.NotPublished).ToListAsync();
|
.Where(e => e.TransactionId == tid && e.State == EventStateEnum.NotPublished).ToListAsync();
|
||||||
|
|
||||||
if(result != null && result.Any()){
|
if (result != null && result.Any())
|
||||||
|
{
|
||||||
return result.OrderBy(o => o.CreationTime)
|
return result.OrderBy(o => o.CreationTime)
|
||||||
.Select(e => e.DeserializeJsonContent(_eventTypes.Find(t=> t.Name == e.EventTypeShortName)));
|
.Select(e => e.DeserializeJsonContent(_eventTypes.Find(t => t.Name == e.EventTypeShortName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new List<IntegrationEventLogEntry>();
|
return new List<IntegrationEventLogEntry>();
|
||||||
@ -83,7 +79,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Servi
|
|||||||
var eventLogEntry = _integrationEventLogContext.IntegrationEventLogs.Single(ie => ie.EventId == eventId);
|
var eventLogEntry = _integrationEventLogContext.IntegrationEventLogs.Single(ie => ie.EventId == eventId);
|
||||||
eventLogEntry.State = status;
|
eventLogEntry.State = status;
|
||||||
|
|
||||||
if(status == EventStateEnum.InProgress)
|
if (status == EventStateEnum.InProgress)
|
||||||
eventLogEntry.TimesSent++;
|
eventLogEntry.TimesSent++;
|
||||||
|
|
||||||
_integrationEventLogContext.IntegrationEventLogs.Update(eventLogEntry);
|
_integrationEventLogContext.IntegrationEventLogs.Update(eventLogEntry);
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Storage;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data.Common;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Utilities
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Utilities
|
||||||
@ -16,7 +10,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Utili
|
|||||||
private ResilientTransaction(DbContext context) =>
|
private ResilientTransaction(DbContext context) =>
|
||||||
_context = context ?? throw new ArgumentNullException(nameof(context));
|
_context = context ?? throw new ArgumentNullException(nameof(context));
|
||||||
|
|
||||||
public static ResilientTransaction New (DbContext context) =>
|
public static ResilientTransaction New(DbContext context) =>
|
||||||
new ResilientTransaction(context);
|
new ResilientTransaction(context);
|
||||||
|
|
||||||
public async Task ExecuteAsync(Func<Task> action)
|
public async Task ExecuteAsync(Func<Task> action)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user