Browse Source

#33 Created IDistributedEventBus

pull/594/head
Halil ibrahim Kalkan 8 years ago
parent
commit
1016a1662d
  1. 30
      framework/src/Volo.Abp.EventBus.Distributed.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqDistributedEventBus.cs
  2. 52
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/IDistributedEventBus.cs
  3. 13
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/IDistributedEventHandler.cs
  4. 30
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus.cs

30
framework/src/Volo.Abp.EventBus.Distributed.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqDistributedEventBus.cs

@ -6,6 +6,36 @@ namespace Volo.Abp.EventBus.Distributed.RabbitMq
{
public class RabbitMqDistributedEventBus : IDistributedEventBus, ITransientDependency
{
public IDisposable Subscribe<TEvent>(Func<TEvent, Task> action) where TEvent : class
{
throw new NotImplementedException();
}
public IDisposable Subscribe<TEvent>(IEventHandler<TEvent> handler) where TEvent : class
{
throw new NotImplementedException();
}
public IDisposable Subscribe<TEvent, THandler>() where TEvent : class where THandler : IEventHandler, new()
{
throw new NotImplementedException();
}
public IDisposable Subscribe(Type eventType, IEventHandler handler)
{
throw new NotImplementedException();
}
public IDisposable Subscribe<TEvent>(IEventHandlerFactory factory) where TEvent : class
{
throw new NotImplementedException();
}
public IDisposable Subscribe(Type eventType, IEventHandlerFactory factory)
{
throw new NotImplementedException();
}
public Task PublishAsync<TEvent>(TEvent eventData)
where TEvent : class
{

52
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/IDistributedEventBus.cs

@ -5,6 +5,58 @@ namespace Volo.Abp.EventBus.Distributed
{
public interface IDistributedEventBus
{
/// <summary>
/// Subscribes to an event.
/// Given action is called for all event occurrences.
/// </summary>
/// <param name="action">Action to handle events</param>
/// <typeparam name="TEvent">Event type</typeparam>
IDisposable Subscribe<TEvent>(Func<TEvent, Task> action)
where TEvent : class;
/// <summary>
/// Subscribes to an event.
/// Same (given) instance of the handler is used for all event occurrences.
/// </summary>
/// <typeparam name="TEvent">Event type</typeparam>
/// <param name="handler">Object to handle the event</param>
IDisposable Subscribe<TEvent>(IEventHandler<TEvent> handler)
where TEvent : class;
/// <summary>
/// Subscribes to an event.
/// A new instance of <see cref="THandler"/> object is created for every event occurrence.
/// </summary>
/// <typeparam name="TEvent">Event type</typeparam>
/// <typeparam name="THandler">Type of the event handler</typeparam>
IDisposable Subscribe<TEvent, THandler>()
where TEvent : class
where THandler : IEventHandler, new();
/// <summary>
/// Subscribes to an event.
/// Same (given) instance of the handler is used for all event occurrences.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="handler">Object to handle the event</param>
IDisposable Subscribe(Type eventType, IEventHandler handler);
/// <summary>
/// Subscribes to an event.
/// Given factory is used to create/release handlers
/// </summary>
/// <typeparam name="TEvent">Event type</typeparam>
/// <param name="factory">A factory to create/release handlers</param>
IDisposable Subscribe<TEvent>(IEventHandlerFactory factory)
where TEvent : class;
/// <summary>
/// Subscribes to an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="factory">A factory to create/release handlers</param>
IDisposable Subscribe(Type eventType, IEventHandlerFactory factory);
Task PublishAsync<TEvent>(TEvent eventData)
where TEvent : class;

13
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/IDistributedEventHandler.cs

@ -0,0 +1,13 @@
using System.Threading.Tasks;
namespace Volo.Abp.EventBus.Distributed
{
public interface IDistributedEventHandler<in TEvent> : IEventHandler
{
/// <summary>
/// Handler handles the event by implementing this method.
/// </summary>
/// <param name="eventData">Event data</param>
Task HandleEventAsync(TEvent eventData);
}
}

30
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus.cs

@ -13,6 +13,36 @@ namespace Volo.Abp.EventBus.Distributed
_eventBus = eventBus;
}
public IDisposable Subscribe<TEvent>(Func<TEvent, Task> action) where TEvent : class
{
return _eventBus.Register(action);
}
public IDisposable Subscribe<TEvent>(IEventHandler<TEvent> handler) where TEvent : class
{
return _eventBus.Register(handler);
}
public IDisposable Subscribe<TEvent, THandler>() where TEvent : class where THandler : IEventHandler, new()
{
return _eventBus.Register<TEvent, THandler>();
}
public IDisposable Subscribe(Type eventType, IEventHandler handler)
{
return _eventBus.Register(eventType, handler);
}
public IDisposable Subscribe<TEvent>(IEventHandlerFactory factory) where TEvent : class
{
return _eventBus.Register<TEvent>(factory);
}
public IDisposable Subscribe(Type eventType, IEventHandlerFactory factory)
{
return _eventBus.Register(eventType, factory);
}
public Task PublishAsync<TEvent>(TEvent eventData)
where TEvent : class
{

Loading…
Cancel
Save