Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for execution filters #55

Open
Kralizek opened this issue Jan 26, 2019 · 1 comment
Open

Support for execution filters #55

Kralizek opened this issue Jan 26, 2019 · 1 comment
Milestone

Comments

@Kralizek
Copy link
Member

Adding support for execution filters will help minimizing the risk of cross-cutting concerns polluting the handlers.

A filter could be implementing an IExecutionFilter interface like the following.

public interface IExecutionFilter
{
    Task ExecuteAsync<TCommand>(ICommandContext<TCommand> context, CommandFilterDelegate<TCommand> next) where TCommand : class, ICommand;

    Task ExecuteAsync<TEvent>(IEventContext<TEvent> context, EventFilterDelegate<TEvent> next) where TEvent : class, IEvent;
}

public delegate Task CommandFilterDelegate<T>(ICommandContext<T> context) where T : class, ICommand;

public delegate Task EventFilterDelegate<T>(IEventContext<T> context) where T : class, IEvent;

Here is a sample of a filter

public class SampleExecutionFilter : IExecutionFilter
{
    async Task IExecutionFilter.ExecuteAsync<TCommand> (ICommandContext<TCommand> context, CommandFilterDelegate<TCommand> next)
    {
        // do something before

        await next(context);

        // do something after
    }

    async Task IExecutionFilter.ExecuteAsync<TEvent> (IEventContext<TEvent> context, EventFilterDelegate<TEvent> next)
    {
        // do something before

        await next(context);

        // do something after
    }
}
@Kralizek Kralizek added this to the v1.1 milestone Jan 26, 2019
@Kralizek
Copy link
Member Author

The IExecutionFilter should also intercept the message before it gets pushed to the IBusEngine

@Kralizek Kralizek modified the milestones: v1.1, v1.2 Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant