Vuresoft.Events
0.1.2
dotnet add package Vuresoft.Events --version 0.1.2
NuGet\Install-Package Vuresoft.Events -Version 0.1.2
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="Vuresoft.Events" Version="0.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Vuresoft.Events" Version="0.1.2" />
<PackageReference Include="Vuresoft.Events" />
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 Vuresoft.Events --version 0.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Vuresoft.Events, 0.1.2"
#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 Vuresoft.Events@0.1.2
#: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=Vuresoft.Events&version=0.1.2
#tool nuget:?package=Vuresoft.Events&version=0.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Vuresoft.Events
A lightweight, channel-based event processing library for .NET 9+ applications. Provides reliable event publishing, handling, and persistence with correlation tracking.
Features
- Channel-based Processing: Uses unbounded channels for async event processing
- Event Persistence: Automatic event storage with JSON serialization and correlation IDs
- Type Safety: Strongly-typed event handlers with compile-time validation
- Correlation Tracking: Correlation ID support for distributed tracing
- Pluggable Persistence: Support for custom persistence providers
Installation
dotnet add package Vuresoft.Events
Quick Start
1. Define Your Events
public record PatientRegisteredEvent(string PatientId, string CorrelationId) : EventBase(CorrelationId);
public record AppointmentScheduledEvent(string AppointmentId, DateTime ScheduledDate, string CorrelationId) : EventBase(CorrelationId);
2. Configure Services in Startup
For Testing (In-Memory)
public void ConfigureServices(IServiceCollection services)
{
// Add event manager with in-memory persistence
services.AddEventsManagerInMemoryOnly();
}
For Production (Custom Persistence)
public void ConfigureServices(IServiceCollection services)
{
// Add event manager with custom persistence (e.g., Entity Framework)
// registered manually
services.AddSingleton<SaveEventDelegate>(provider => async (eventData, cancellationToken) =>
{
var scopeFactory = provider.GetRequiredService<IServiceScopeFactory>();
using var scope = scopeFactory.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
var eventStore = new EventStore(eventData);
dbContext.EventStore.Add(eventStore);
await dbContext.SaveChangesAsync(cancellationToken);
});
services.AddEventsManager();
// Or use Fluent method on eventsManager.
services.AddEventsManager()
.WithSaveDelegate(provider => async (eventData, cancellationToken) =>
{
var scopeFactory = provider.GetRequiredService<IServiceScopeFactory>();
using var scope = scopeFactory.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
var eventStore = new EventStore(eventData);
dbContext.EventStore.Add(eventStore);
await dbContext.SaveChangesAsync(cancellationToken);
});
}
3. Register Event Handlers
Create a mapping class for setting handlesr for each event
public class EventMappings(
IOptions<SystemConfig> systemConfig,
EventManager eventManager,
IServiceScopeFactory serviceScopeFactory)
{
public void SetEventHandlers()
{
eventManager.On<OrderCreatedOrUpdated>(async data =>
{
await using var scope = serviceScopeFactory.CreateAsyncScope();
var orderProcessor =
scope.ServiceProvider.GetRequiredService<OrderProcessor>();
await orderProcessor
.AddOrder(data.OrderId, CancellationToken.None).ConfigureAwait(false);
});
4. Publish Events
[ApiController]
public class OrderController : ControllerBase
{
private readonly EventManager _eventManager;
public OrderController(EventManager eventManager)
{
_eventManager = eventManager;
}
[HttpPost]
public async Task<IActionResult> CreateOrder(RegisterOrderRequest request)
{
var correlationId = HttpContext.TraceIdentifier;
// Create Order
// Publish event - will be processed asynchronously
_eventManager.PublishEvent(new OrderCreatedOrUpdated(order.OrderId, correlationId));
return Ok;
}
}
Performance Considerations
- Events are processed asynchronously without blocking the publisher
- Failed events are logged but don't retry automatically
- Event persistence happens before handler execution for reliability
- Unbounded channels can grow large under high load - monitor memory usage
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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.
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.3)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.