Skip to content

Commit

Permalink
Merging main into dev.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmwebb-lv committed Apr 19, 2024
2 parents 99dc804 + 9a624da commit 30de666
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected override void OnBuildInitialized()
{
Log.Information("Generating NuGet packages for projects in solution");
int commitNum = 0;
string NuGetVersionCustom = "2.0.0.10";
string NuGetVersionCustom = "2.0.0.869";
//if it's not a tagged release - append the commit number to the package version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public async Task RouteEventsAsync(IEnumerable<ISerializableEvent> transactional
try
{
Guard.IsNotNull(transactionalEvents, nameof(transactionalEvents));
_logger.LogInformation("{0} is routing transactional events to event producers.", this.GetGenericTypeName());

// Seperate Async events from Sync Events
var syncEvents = transactionalEvents.Where(x => x is ISyncEvent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -10,14 +11,18 @@ namespace RCommon.EventHandling.Producers
public class PublishWithEventBusEventProducer : IEventProducer
{
private readonly IEventBus _eventBus;
private readonly ILogger<PublishWithEventBusEventProducer> _logger;

public PublishWithEventBusEventProducer(IEventBus eventBus)
public PublishWithEventBusEventProducer(IEventBus eventBus, ILogger<PublishWithEventBusEventProducer> logger)
{
_eventBus = eventBus;
_eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public async Task ProduceEventAsync<T>(T @event, CancellationToken cancellationToken = default)
where T : ISerializableEvent
{
Guard.IsNotNull(@event, nameof(@event));
_logger.LogInformation("{0} publishing event: {1}", new object[] { this.GetGenericTypeName(), @event });
await _eventBus.PublishAsync(@event);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MassTransit;
using Microsoft.Extensions.Logging;
using RCommon.EventHandling;
using RCommon.EventHandling.Producers;
using System;
Expand All @@ -12,15 +13,18 @@ namespace RCommon.MassTransit.Producers
public class PublishWithMassTransitEventProducer : IEventProducer
{
private readonly IBus _bus;
private readonly ILogger<PublishWithMassTransitEventProducer> _logger;

public PublishWithMassTransitEventProducer(IBus bus)
public PublishWithMassTransitEventProducer(IBus bus, ILogger<PublishWithMassTransitEventProducer> logger)
{
_bus = bus;
_bus = bus ?? throw new ArgumentNullException(nameof(bus));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

public async Task ProduceEventAsync<T>(T @event, CancellationToken cancellationToken = default) where T : ISerializableEvent
{
Console.WriteLine("{0} publishing event {1} to MassTransit", new object[] { this.GetGenericTypeName(), @event });
Guard.IsNotNull(@event, nameof(@event));
_logger.LogInformation("{0} publishing event: {1}", new object[] { this.GetGenericTypeName(), @event });
await _bus.Publish(@event, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using RCommon.EventHandling;
using MassTransit;
using Microsoft.Extensions.Logging;
using RCommon.EventHandling;
using RCommon.EventHandling.Producers;
using System;
using System.Collections.Generic;
Expand All @@ -10,15 +12,21 @@ namespace RCommon.MassTransit.Producers
{
public class SendWithMassTransitEventProducer : IEventProducer
{
public SendWithMassTransitEventProducer()

private readonly IBus _bus;
private readonly ILogger<PublishWithMassTransitEventProducer> _logger;

public SendWithMassTransitEventProducer(IBus bus, ILogger<PublishWithMassTransitEventProducer> logger)
{

_bus = bus ?? throw new ArgumentNullException(nameof(bus));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

public Task ProduceEventAsync<T>(T @event, CancellationToken cancellationToken = default)
where T : ISerializableEvent
public async Task ProduceEventAsync<T>(T @event, CancellationToken cancellationToken = default) where T : ISerializableEvent
{
throw new NotImplementedException();
Guard.IsNotNull(@event, nameof(@event));
_logger.LogInformation("{0} sending event: {1}", new object[] { this.GetGenericTypeName(), @event });
await _bus.Send(@event, cancellationToken);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MediatR;
using Microsoft.Extensions.Logging;
using RCommon.EventHandling;
using RCommon.EventHandling.Producers;
using RCommon.Mediator;
Expand All @@ -14,16 +15,19 @@ namespace RCommon.MediatR.Producers
public class PublishWithMediatREventProducer : IEventProducer
{
private readonly IMediatorService _mediatorService;
private readonly ILogger<PublishWithMediatREventProducer> _logger;

public PublishWithMediatREventProducer(IMediatorService mediatorService)
public PublishWithMediatREventProducer(IMediatorService mediatorService, ILogger<PublishWithMediatREventProducer> logger)
{
_mediatorService = mediatorService;
_mediatorService = mediatorService ?? throw new ArgumentNullException(nameof(mediatorService));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

public async Task ProduceEventAsync<TEvent>(TEvent @event, CancellationToken cancellationToken = default)
where TEvent : ISerializableEvent
{
Guard.IsNotNull(@event, nameof(@event));
_logger.LogInformation("{0} publishing event: {1}", new object[] { this.GetGenericTypeName(), @event });
await _mediatorService.Publish(@event, cancellationToken);
}
}
Expand Down
8 changes: 6 additions & 2 deletions Src/RCommon.Mediatr/Producers/SendWithMediatREventProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,26 @@
using MediatR;
using RCommon.MediatR.Subscribers;
using RCommon.Mediator;
using Microsoft.Extensions.Logging;

namespace RCommon.MediatR.Producers
{
public class SendWithMediatREventProducer : IEventProducer
{
private readonly IMediatorService _mediatorService;
private readonly ILogger<SendWithMediatREventProducer> _logger;

public SendWithMediatREventProducer(IMediatorService mediatorService)
public SendWithMediatREventProducer(IMediatorService mediatorService, ILogger<SendWithMediatREventProducer> logger)
{
_mediatorService = mediatorService;
_mediatorService = mediatorService ?? throw new ArgumentNullException(nameof(mediatorService));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

public async Task ProduceEventAsync<TEvent>(TEvent @event, CancellationToken cancellationToken = default)
where TEvent : ISerializableEvent
{
Guard.IsNotNull(@event, nameof(@event));
_logger.LogInformation("{0} sending event: {1}", new object[] { this.GetGenericTypeName(), @event });
await _mediatorService.Send(@event, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using RCommon.EventHandling;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Configuration;
using RCommon.EventHandling;
using RCommon.EventHandling.Producers;
using System;
using System.Collections.Generic;
Expand All @@ -12,14 +14,18 @@ namespace RCommon.Wolverine.Producers
public class PublishWithWolverineEventProducer : IEventProducer
{
private readonly IMessageBus _messageBus;
private readonly ILogger<PublishWithWolverineEventProducer> _logger;

public PublishWithWolverineEventProducer(IMessageBus messageBus)
public PublishWithWolverineEventProducer(IMessageBus messageBus, ILogger<PublishWithWolverineEventProducer> logger)
{
_messageBus = messageBus;
_messageBus = messageBus ?? throw new ArgumentNullException(nameof(messageBus));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

public async Task ProduceEventAsync<T>(T @event, CancellationToken cancellationToken = default) where T : ISerializableEvent
{
Guard.IsNotNull(@event, nameof(@event));
_logger.LogInformation("{0} publishing event: {1}", new object[] { this.GetGenericTypeName(), @event });
await _messageBus.PublishAsync<T>(@event);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RCommon.EventHandling;
using Microsoft.Extensions.Logging;
using RCommon.EventHandling;
using RCommon.EventHandling.Producers;
using System;
using System.Collections.Generic;
Expand All @@ -12,15 +13,19 @@ namespace RCommon.Wolverine.Producers
public class SendWithWolverineEventProducer : IEventProducer
{
private readonly IMessageBus _messageBus;
private readonly ILogger<SendWithWolverineEventProducer> _logger;

public SendWithWolverineEventProducer(IMessageBus messageBus)
public SendWithWolverineEventProducer(IMessageBus messageBus, ILogger<SendWithWolverineEventProducer> logger)
{
_messageBus = messageBus;
_messageBus = messageBus ?? throw new ArgumentNullException(nameof(messageBus));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}


public async Task ProduceEventAsync<T>(T @event, CancellationToken cancellationToken = default) where T : ISerializableEvent
{
Guard.IsNotNull(@event, nameof(@event));
_logger.LogInformation("{0} sending event: {1}", new object[] { this.GetGenericTypeName(), @event });
await _messageBus.SendAsync(@event);
}
}
Expand Down

0 comments on commit 30de666

Please sign in to comment.