Skip to content
Permalink
Browse files

Refactor the event Bus. Remove service bus

  • Loading branch information
farajfarook committed Nov 23, 2019
1 parent a7c609e commit fd96e07e55f60757d2ec10907655754d783dfd6e
Showing with 404 additions and 1,292 deletions.
  1. +1 −1 .travis.yml
  2. +0 −63 Enbiso.NLib.EventBus.Abstractions/IEventBus.cs
  3. +0 −110 Enbiso.NLib.EventBus.Abstractions/IEventBusSubscriptionsManager.cs
  4. +11 −22 Enbiso.NLib.EventBus.Abstractions/IEventHandler.cs
  5. +19 −0 Enbiso.NLib.EventBus.Abstractions/IEventPublisher.cs
  6. +32 −0 Enbiso.NLib.EventBus.Abstractions/IEventSubscriber.cs
  7. +0 −10 Enbiso.NLib.EventBus.Abstractions/ISubscriptionInfo.cs
  8. +5 −5 Enbiso.NLib.EventBus.Nats/{NatsPersistentConnection.cs → NatsConnection.cs}
  9. +0 −108 Enbiso.NLib.EventBus.Nats/NatsEventBus.cs
  10. +51 −0 Enbiso.NLib.EventBus.Nats/NatsEventPublisher.cs
  11. +48 −0 Enbiso.NLib.EventBus.Nats/NetsEventSubscriber.cs
  12. +8 −46 Enbiso.NLib.EventBus.Nats/ServiceExtensions.cs
  13. +7 −7 Enbiso.NLib.EventBus.RabbitMq/{RabbitMqPersistentConnection.cs → RabbitMqConnection.cs}
  14. +0 −201 Enbiso.NLib.EventBus.RabbitMq/RabbitMqEventBus.cs
  15. +75 −0 Enbiso.NLib.EventBus.RabbitMq/RabbitMqEventPublisher.cs
  16. +101 −0 Enbiso.NLib.EventBus.RabbitMq/RabbitMqEventSubscriber.cs
  17. +4 −44 Enbiso.NLib.EventBus.RabbitMq/ServiceExtensions.cs
  18. +0 −32 Enbiso.NLib.EventBus.ServiceBus/Enbiso.NLib.EventBus.ServiceBus.csproj
  19. +0 −195 Enbiso.NLib.EventBus.ServiceBus/ServiceBusEventBus.cs
  20. +0 −69 Enbiso.NLib.EventBus.ServiceBus/ServiceBusPersistenceConnection.cs
  21. +0 −181 Enbiso.NLib.EventBus/EventBusSubscriptionsManager.cs
  22. +26 −36 Enbiso.NLib.EventBus/EventProcessor.cs
  23. +4 −4 Enbiso.NLib.EventBus/EventService.cs
  24. +4 −63 Enbiso.NLib.EventBus/ServiceExtensions.cs
  25. +0 −47 Enbiso.NLib.EventBus/SubscriptionInfo.cs
  26. +2 −2 Enbiso.NLib.EventLogger/EventLoggerEventService.cs
  27. +6 −40 Enbiso.NLib.Tests/Enbiso.NLib.EventBus.Nats.Tests/NatsEventBusTests.cs
  28. +0 −6 Enbiso.NLib.sln
@@ -1,6 +1,6 @@
env:
global:
- PACKAGE_VERSION="3.0.0-rc8"
- PACKAGE_VERSION="3.0.0-rc9"
- PACKAGE_ICON="https://www.enbiso.com/logo.svg"
- PACKAGE_PROJECT="https://nlib.enbiso.com"
- PACKAGE_REPO="https://github.com/enbiso/Enbiso.NLib"

This file was deleted.

This file was deleted.

@@ -1,36 +1,25 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;

namespace Enbiso.NLib.EventBus
{
/// <inheritdoc />
/// <summary>
/// Integration event handler with type event
/// </summary>
/// <typeparam name="TEvent"></typeparam>
public interface IEventHandler<in TEvent> : IEventHandler where TEvent: IEvent
{
Task Handle(TEvent @event);
}

/// <summary>
/// Integration event handler
/// </summary>
public interface IEventHandler
{

Type GetEventType();
Task Handle(object @event);
}

/// <inheritdoc />

/// <summary>
/// Dynamic integration event handler interface
/// Abstract event handler
/// </summary>
public interface IDynamicEventHandler: IEventHandler
/// <typeparam name="TEvent"></typeparam>
public abstract class EventHandler<TEvent>: IEventHandler where TEvent : class, IEvent
{
/// <summary>
/// Handle dynamic event
/// </summary>
/// <param name="eventData"></param>
/// <returns></returns>
Task Handle(dynamic eventData);
protected abstract Task Handle(TEvent @event);
public Type GetEventType() => typeof(TEvent);
public Task Handle(object @event) => Handle(@event as TEvent);
}
}
@@ -0,0 +1,19 @@
using System.Threading;
using System.Threading.Tasks;

namespace Enbiso.NLib.EventBus
{
/// <summary>
/// Event bus interface
/// </summary>
public interface IEventPublisher
{
/// <summary>
/// Publish @event
/// </summary>
/// <param name="event"></param>
/// <param name="exchange"></param>
/// <param name="cancellationToken"></param>
Task Publish<T>(T @event, string exchange = null, CancellationToken cancellationToken = default) where T : IEvent;
}
}
@@ -0,0 +1,32 @@
using System.Threading;
using System.Threading.Tasks;

namespace Enbiso.NLib.EventBus
{
/// <summary>
/// Event bus interface
/// </summary>
public interface IEventSubscriber
{
/// <summary>
/// Initialize event bus with subscriptions
/// </summary>
void Initialize();

/// <summary>
/// Subscribe
/// </summary>
/// <param name="eventName"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task Subscribe(string eventName, CancellationToken cancellationToken = default);

/// <summary>
/// UnSubscribe
/// </summary>
/// <param name="eventName"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task UnSubscribe(string eventName, CancellationToken cancellationToken = default);
}
}

This file was deleted.

@@ -1,27 +1,27 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NATS.Client;
using Options = NATS.Client.Options;

namespace Enbiso.NLib.EventBus.Nats
{
public interface INatsPersistentConnection : IDisposable
public interface INatsConnection : IDisposable
{
bool IsConnected { get; }
IConnection GetConnection();
bool TryConnect();
}

public class NatsPersistentConnection: INatsPersistentConnection
public class NatsConnection: INatsConnection
{
private IConnection _connection;
private readonly ConnectionFactory _factory;
private readonly NatsOptions _options;
private readonly ILogger _logger;
private bool _disposed;

public NatsPersistentConnection(ConnectionFactory factory, IOptions<NatsOptions> options, ILogger<NatsPersistentConnection> logger)
public NatsConnection(ConnectionFactory factory, IOptions<NatsOptions> options, ILogger<NatsConnection> logger)
{
_logger = logger;
_options = options.Value;
@@ -46,7 +46,7 @@ public bool TryConnect()
opts.Token = _options.Token;
try
{
_connection = _factory.CreateConnection(opts);
_connection = _factory.CreateConnection(opts);
return IsConnected;
}
catch (Exception e)

0 comments on commit fd96e07

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