Skip to content
Permalink
Browse files

ixing issues in event bus and logger

  • Loading branch information...
farajfarook committed Sep 19, 2018
1 parent 95651ea commit f6413339a2a12a107ed0e4d811a0d756d2b0f678
@@ -1,6 +1,6 @@
env:
global:
- PACKAGE_VERSION="1.1.10"
- PACKAGE_VERSION="1.1.11"
- PACKAGE_ICON="https://www.enbiso.com/logo.svg"
- PACKAGE_PROJECT="https://nlib.enbiso.com"
- PACKAGE_REPO="https://github.com/enbiso/Enbiso.NLib"
@@ -16,7 +16,9 @@ public static IServiceCollection AddCqrs(this IServiceCollection services)

public static IServiceCollection AddCqrs(this IServiceCollection services, params Assembly[] assemblies)
{
services.AddMediatR(assemblies);
if (services.All(s => s.ServiceType != typeof(IMediator)))
services.AddMediatR(assemblies);

services.AddScoped<ICommandBus, CommandBus>();
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidatorBehavior<,>));
@@ -16,7 +16,9 @@ public static IServiceCollection AddDomainEvents(this IServiceCollection service

public static IServiceCollection AddDomainEvents(this IServiceCollection services, params Assembly[] assemblies)
{
services.AddMediatR(assemblies);
if (services.All(s => s.ServiceType != typeof(IMediator)))
services.AddMediatR(assemblies);

services.AddScoped<IDomainEventBus, DomainEventBus>();
return services;
}
@@ -11,6 +11,8 @@ public class EventLogEntityConfig : IEntityTypeConfiguration<EventLog>
{
public void Configure(EntityTypeBuilder<EventLog> builder)
{
builder.Ignore(e => e.State);

builder.HasKey(e => e.EventId);

builder.Property(e => e.EventId)
@@ -22,8 +24,8 @@ public void Configure(EntityTypeBuilder<EventLog> builder)
builder.Property(e => e.CreationTime)
.IsRequired();

builder.Property(e => e.State)
.IsRequired();
builder.Property("_state")
.IsRequired().HasColumnName("State");

builder.Property(e => e.TimesSent)
.IsRequired();

This file was deleted.

@@ -8,7 +8,7 @@ public static class ServiceExtensions
public static void AddEventLogger<TDbContext>(this IServiceCollection services) where TDbContext: DbContext
{
services.AddEventLogger();
services.AddSingleton<IEventLogRepo, EntityEventLogRepo<TDbContext>>();
services.AddTransient<IEventLogRepo, EntityEventLogRepo<TDbContext>>();
}
}
}
@@ -18,9 +18,26 @@ public EventLog(IEvent @event)
}
public Guid EventId { get; private set; }
public string EventTypeName { get; private set; }
public EventState State { get; set; }
private string _state;

public EventState State
{
get => Enum.TryParse<EventState>(_state, out var val) ? val : default(EventState);
set => _state = value.ToString();
}

public int TimesSent { get; set; }
public DateTime CreationTime { get; private set; }
public string Content { get; private set; }
}

/// <summary>
/// Event states
/// </summary>
public enum EventState
{
NotPublished = 0,
Published = 1,
Failed = 2
}
}
@@ -6,7 +6,7 @@
namespace Enbiso.NLib.EventLogger
{
/// <summary>
/// EventLoger service
/// EventLogger service
/// </summary>
public interface IEventLoggerService
{

This file was deleted.

@@ -13,7 +13,7 @@ public static void AddEventLogger(this IServiceCollection services)
var eventService = services.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(IEventService));
if (eventService != null) services.Remove(eventService);

services.AddSingleton<IEventService, EventLoggerEventService>();
services.AddTransient<IEventService, EventLoggerEventService>();
}
}
}
@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;

namespace Enbiso.NLib.Exceptions
namespace Enbiso.NLib.GlobalExceptions
{
/// <summary>
/// Global exception handler interface
@@ -1,6 +1,6 @@
using System.Threading.Tasks;

namespace Enbiso.NLib.Exceptions
namespace Enbiso.NLib.GlobalExceptions
{
public static class GlobalExceptionHandlerExtensions
{
@@ -1,4 +1,4 @@
namespace Enbiso.NLib.Exceptions
namespace Enbiso.NLib.GlobalExceptions
{
/// <summary>
/// Exception handler response

0 comments on commit f641333

Please sign in to comment.
You can’t perform that action at this time.