Files
mixtape/zero.Core/Messages/IMessageHandler.cs
T
2020-10-06 16:00:27 +02:00

31 lines
999 B
C#

using System.Collections.Generic;
using System.Threading.Tasks;
namespace zero.Core.Messages
{
/// <summary>
/// Indicates a handler that can perform an action when a message of
/// a certain type is received. (could be an interface rather than concrete type)
/// </summary>
public interface IMessageHandler<TMessage> where TMessage : IMessage
{
/// <summary>
/// Method to invoke when a message of type TMessage is published
/// </summary>
Task Handle(TMessage message);
}
/// <summary>
/// Indicates a handler that can perform an action when a message of
/// a certain type is received. (could be an interface rather than concrete type)
/// </summary>
public interface IBatchMessageHandler<TMessage> : IMessageHandler<TMessage> where TMessage : IMessage
{
/// <summary>
/// Method to invoke when a batch of messages of type TMessage are published
/// </summary>
Task HandleBatchAsync(IReadOnlyCollection<TMessage> message);
}
}