/
IPipelineBehavior.cs
32 lines (30 loc) · 1.24 KB
/
IPipelineBehavior.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
namespace Marty.Net.Contracts;
using Internal;
using System;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// A Pipeline is to be executed before and after <see cref="IEventHandler{T}" />
/// </summary>
/// <typeparam name="T"></typeparam>
[PipelineBehavior]
public interface IPipelineBehavior<in T>
where T : IEvent
{
/// <summary>
/// Implement this to execute actions after <see cref="IEventHandler{T}" />.
/// Returns an <see cref="OperationResult" /> specifying what the event store subscription should do with the event
/// after being processed.
/// </summary>
/// <param name="event">The event that appeared on the persistent subscription.</param>
/// <param name="context">The context of the event <see cref="IConsumerContext" />.</param>
/// <param name="next">The next action to be executed.</param>
/// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken" />.</param>
/// <returns>The task with an <see cref="OperationResult" /> to be awaited.</returns>
Task<OperationResult> Execute(
T @event,
IConsumerContext context,
Func<Task<OperationResult>> next,
CancellationToken cancellationToken = default
);
}