VOOZH about

URL: https://www.nuget.org/packages/Cosmos.EventSourcing.CritterStack/

⇱ NuGet Gallery | Cosmos.EventSourcing.CritterStack 1.2.3




👁 Image
Cosmos.EventSourcing.CritterStack 1.2.3

dotnet add package Cosmos.EventSourcing.CritterStack --version 1.2.3
 
 
NuGet\Install-Package Cosmos.EventSourcing.CritterStack -Version 1.2.3
 
 
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="Cosmos.EventSourcing.CritterStack" Version="1.2.3" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cosmos.EventSourcing.CritterStack" Version="1.2.3" />
 
Directory.Packages.props
<PackageReference Include="Cosmos.EventSourcing.CritterStack" />
 
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 Cosmos.EventSourcing.CritterStack --version 1.2.3
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Cosmos.EventSourcing.CritterStack, 1.2.3"
 
 
#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 Cosmos.EventSourcing.CritterStack@1.2.3
 
 
#: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=Cosmos.EventSourcing.CritterStack&version=1.2.3
 
Install as a Cake Addin
#tool nuget:?package=Cosmos.EventSourcing.CritterStack&version=1.2.3
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Cosmos.EventSourcing.CritterStack

👁 NuGet

Implementación completa de Event Sourcing y CQRS usando Wolverine y Marten (CritterStack).

Descripción

Este paquete proporciona implementaciones listas para producción de todas las abstracciones definidas en Cosmos.EventSourcing.Abstractions. Utiliza Wolverine para mensajería y mediación, y Marten como Event Store y Document Database sobre PostgreSQL.

CritterStack es el nombre de la combinación de Wolverine + Marten, dos poderosas herramientas del ecosistema .NET.

Características

Event Store

  • MartenEventStore: Implementación de IEventStore usando Marten
  • Soporte para recuperar agregados por ID, versión o timestamp
  • Soporte para verificar existencia de agregados con ExistsAsync<T>
  • Persistencia de eventos en PostgreSQL

Command Routing

  • WolverineCommandRouter: Router de comandos usando Wolverine
  • Soporte para comandos con y sin valor de retorno
  • Integración con multi-tenancy

Query Routing

  • WolverineQueryRouter: Router de consultas usando Wolverine
  • Ejecución distribuida de queries

Projection Store

  • MartenProjectionStore: Almacén de proyecciones usando Marten
  • Operaciones CRUD sobre proyecciones/vistas de lectura

Instalación

dotnet add package Cosmos.EventSourcing.CritterStack

Este paquete incluye automáticamente las dependencias de:

  • Cosmos.EventSourcing.Abstractions
  • Cosmos.MultiTenancy

Configuración

Registrar Servicios (con IHostBuilder)

using Cosmos.EventSourcing.CritterStack;

var builder = WebApplication.CreateBuilder(args);

// Configura Wolverine + Marten para comandos
builder.Host.UsarWolverineParaComandos(
 dominioAssembly: typeof(MiAgregado).Assembly,
 martenConnectionString: builder.Configuration.GetConnectionString("Postgres")!,
 databaseSchemaName: "mi_servicio",
 isDevelopment: builder.Environment.IsDevelopment()
);

// Registra el router de comandos
builder.Services.AgregarWolverineCommandRouter();

// Registra el router de consultas
builder.Services.AgregarWolverineQueryRouter();

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

Configuración Serverless (Azure Functions)

// Para entornos serverless usa AgregarWolverineParaComandosServerless
builder.Services.AgregarWolverineParaComandosServerless(
 dominioAssembly: typeof(MiAgregado).Assembly,
 martenConnectionString: connectionString,
 databaseSchemaName: "mi_servicio",
 isDevelopment: false
);

Uso

Implementar Command Handlers con Wolverine

using Cosmos.EventSourcing.Abstractions.Commands;

public record CreateOrder(string OrderId, string CustomerId);

// Los handlers son descubiertos automáticamente por Wolverine
public class CreateOrderHandler
{
 private readonly IEventStore _eventStore;

 public CreateOrderHandler(IEventStore eventStore)
 {
 _eventStore = eventStore;
 }

 public async Task Handle(CreateOrder command, CancellationToken ct)
 {
 var order = new Order(command.OrderId, command.CustomerId);

 _eventStore.Save(order);
 await _eventStore.SaveChangesAsync();
 }
}

Ejecutar Comandos con el Router

public class OrderController : ControllerBase
{
 private readonly ICommandRouter _commandRouter;

 public OrderController(ICommandRouter commandRouter)
 {
 _commandRouter = commandRouter;
 }

 [HttpPost]
 public async Task<IActionResult> CreateOrder(CreateOrderRequest request)
 {
 var command = new CreateOrder(Guid.NewGuid().ToString(), request.CustomerId);

 await _commandRouter.InvokeAsync(command, HttpContext.RequestAborted);

 return Ok(new { OrderId = command.OrderId });
 }
}

Implementar Query Handlers

public record GetOrderById(string OrderId);

public class GetOrderByIdHandler
{
 private readonly IProjectionStore _projectionStore;

 public GetOrderByIdHandler(IProjectionStore projectionStore)
 {
 _projectionStore = projectionStore;
 }

 public async Task<OrderDto?> Handle(GetOrderById query, CancellationToken ct)
 {
 return await _projectionStore.GetByIdAsync<OrderDto>(query.OrderId, ct);
 }
}

Trabajar con Proyecciones

using Cosmos.EventSourcing.Linq.Extensions;

public class OrderQueryService
{
 private readonly IQuerySession _querySession;

 public OrderQueryService(IQuerySession querySession)
 {
 _querySession = querySession;
 }

 public async Task<IReadOnlyList<OrderDto>> GetCustomerOrdersAsync(
 string customerId,
 CancellationToken ct)
 {
 var orders = await _querySession
 .Query<OrderDto>()
 .Where(o => o.CustomerId == customerId)
 .OrderByDescending(o => o.CreatedAt)
 .ToListAsync(ct);

 return orders;
 }
}

Multi-Tenancy

Los routers de comandos y queries inyectan ITenantResolver (de Cosmos.MultiTenancy) y ejecutan operaciones en el contexto del tenant resuelto:

// El WolverineCommandRouter usa el TenantId del ITenantResolver registrado
await _commandRouter.InvokeAsync(command, ct);
// Internamente: messageBus.InvokeForTenantAsync(tenantResolver.TenantId, command, ct)

AgregarWolverineCommandRouter y AgregarWolverineQueryRouter no registran un ITenantResolver por defecto. El consumidor debe registrar una implementación (por ejemplo AgregarTenantResolverConHeadersConfiables() de Cosmos.MultiTenancy.AspNetCore para servicios ASP.NET Core); sin eso, los routers fallarán al resolver la dependencia en runtime.

Requisitos

  • .NET 10.0 o superior
  • PostgreSQL 12+ (para Marten)

Dependencias

  • Marten (v8.23.0) - Event Store y Document DB
  • WolverineFx.Marten (v5.18.0) - Integración Wolverine-Marten
  • Cosmos.EventSourcing.Abstractions
  • Cosmos.MultiTenancy

Recursos

Licencia

Copyright © Cosmos. Todos los derechos reservados.

Product Versions Compatible and additional computed target framework versions.
.NET net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows 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 Cosmos.EventSourcing.CritterStack:

Package Downloads
Cosmos.CrossCuttingConcerns.Preferences.Flagsmith

Implementación Flagsmith para Cosmos.CrossCuttingConcerns.Preferences.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.3 0 6/18/2026
1.2.2 183 6/12/2026
1.2.1 89 6/12/2026
1.2.0 100 6/11/2026
1.1.0 274 6/3/2026
1.0.0 163 6/2/2026
0.5.3 272 5/28/2026
0.5.2 115 5/28/2026
0.5.1 126 5/28/2026
0.5.0 118 5/28/2026
0.4.0 210 5/26/2026
0.3.0 393 5/21/2026
0.2.0 112 5/21/2026
0.1.12 104 5/20/2026
0.1.11 462 4/7/2026
0.1.10 134 4/7/2026 0.1.10 is deprecated because it has critical bugs.
0.1.9 645 3/18/2026
0.1.8 460 3/16/2026
0.1.7 164 3/12/2026
0.1.6 121 3/12/2026
Loading failed