EventFlux 1.1.9

dotnet add package EventFlux --version 1.1.9
                    
NuGet\Install-Package EventFlux -Version 1.1.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EventFlux" Version="1.1.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EventFlux" Version="1.1.9" />
                    
Directory.Packages.props
<PackageReference Include="EventFlux" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EventFlux --version 1.1.9
                    
#r "nuget: EventFlux, 1.1.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EventFlux@1.1.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EventFlux&version=1.1.9
                    
Install as a Cake Addin
#tool nuget:?package=EventFlux&version=1.1.9
                    
Install as a Cake Tool

NuGet Package Information

NuGet   Downloads   License

EventFlux

EventFlux is a lightweight and performance-focused event processing library for .NET. It makes it easy to trigger a request and process it with multiple handlers, add pipeline behaviors, and perform deferred batch triggering.

Key Features

  • Event-driven architecture
  • Automatic event handler discovery and logging
  • Support for deferred/batch event triggering
  • Support for multiple handlers
  • Add pipeline behaviors (e.g., validation, logging, cache)
  • Dynamic dispatch
  • Handler prerequisite query: Pre-evaluation with the CanHandle method

Quick Start

  1. Install a package from NuGet (package name provided as an example):
dotnet add package EventFlux
  1. Add services in Program.cs / Startup.cs:
var builder = WebApplication.CreateBuilder(args);

// Basic plugins
builder.Services
.AddEventBus(AssemblyReference.Assemblies) // or any assembly list you want
.AddEventLogging() // optional
.AddEventTimeout(); // optional

builder.Services.AddEventDispatcher();

// Example: Adding custom pipeline behavior
builder.Services.AddTransient(typeof(IEventCustomPipeline<,>), typeof(ValidationBehavior<,>));

var app = builder.Build();
app.Run();

Usage examples

  • EventBus (usage awaiting an event → a response):
public class ExampleController(IEventBus _eventBus) : ControllerBase
{ 
    [HttpPost("create-user")] 
    public async Task<IActionResult> CreateUser([FromBody] CreateUserCommandRequest command) 
    { 
        CreateUserCommandResponse response = await _eventBus.SendAsync(command); 
        return Ok(response); 
    }
}
  • EventDispatcher (for more dynamic/multiple redirect scenarios):
public class ExampleController(IEventDispatcher _eventDispatcher) : ControllerBase
{ 
    [HttpPost("update-user")] 
    public async Task<IActionResult> UpdateUser([FromBody] UpdateUserCommandRequest command) 
    { 
        UpdateUserCommandResponse response = await _eventDispatcher.SendAsync(command); 
        return Ok(response); 
    }
}

Example custom pipeline

public class ValidationBehavior<TRequest, TResponse> : IEventCustomPipeline<TRequest, TResponse>
where TRequest : IEventRequest<TResponse>
where TResponse : IEventResponse
{
    public async Task<TResponse> Handle(
    TRequest request,
    EventHandlerDelegate<TResponse> next,
    CancellationToken cancellationToken)
    {
        Console.WriteLine($"Validating {typeof(TRequest).Name}");

        return await next();
    }
}

CanHandle example

You can use CanHandle to perform a precondition check before calling the handler:

public class ExampleEventHandler : IEventHandler<ExampleEventRequest, ExampleEventResponse>
{
    public bool CanHandle(ExampleEventRequest @event)
        => @event.Num > 1000;

    public async Task<ExampleEventResponse> Handle(ExampleEventRequest @event)
    {
        return new() { Res = @event.Num.ToString() };
    }
}

Tests

  • The project includes unit tests for EventBus and EventDispatcher. The tests verify the following:
  • Correct operation of the SendAsync and PublishAsync methods
  • Whether handlers are triggered according to the CanHandle method
  • Correct execution of the pipeline (e.g., TimeoutBehavior, TriggerBehavior) and handler chain
  • Appropriate handling of cancellation token and timeout conditions
  • Correct catching or throwing of exceptions
cd .\test\EventFlux.Test\
dotnet test

Configuration and Tips

  • AddEventLogging: Adds logging to monitor or debug the event flow.
  • AddEventTimeout: Provides a timeout policy for long-running handlers.
  • AddEventBus / AddEventDispatcher: Specify which assemblies to scan explicitly for handlers.
    • EventBus: Basic event sending and publishing.
    • EventDispatcher: Extends EventBus by allowing pipeline behaviors (IEventCustomPipeline<,>, IEventCustomPipeline<>) to be added between the request and handlers.
  • Pipeline Behaviors: Inject custom logic such as validation, logging, caching, or other pre/post-processing for handlers.
  • CanHandle: Implement preconditions in handlers to control whether a handler should execute.
  • Error Handling: Catch exceptions within handlers to log or generate appropriate responses; unhandled exceptions may propagate depending on your implementation.
  • Unit Tests: Use mocks or isolated pipeline behaviors to test handler execution, timeouts, and cancellation tokens.
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on EventFlux:

Package Downloads
EventFlux.RabbitFlow

It is a library combined with rabbitmq and ventflux libraries. The library functions as a distributed event handler.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.9 126 9/9/2025
1.1.8 160 5/18/2025
1.1.7 150 5/11/2025
1.1.6 139 5/11/2025
1.1.5 181 3/23/2025
1.1.4 160 3/16/2025
1.1.3 141 3/16/2025
1.1.2 145 3/16/2025
1.1.1 188 3/10/2025
1.1.0 181 3/10/2025

Initial release with event-based CQRS support.