ServcoX.EventSauce
4.0.1
See the version list below for details.
dotnet add package ServcoX.EventSauce --version 4.0.1
NuGet\Install-Package ServcoX.EventSauce -Version 4.0.1
<PackageReference Include="ServcoX.EventSauce" Version="4.0.1" />
paket add ServcoX.EventSauce --version 4.0.1
#r "nuget: ServcoX.EventSauce, 4.0.1"
// Install ServcoX.EventSauce as a Cake Addin #addin nuget:?package=ServcoX.EventSauce&version=4.0.1 // Install ServcoX.EventSauce as a Cake Tool #tool nuget:?package=ServcoX.EventSauce&version=4.0.1
ServcoX.EventSauce
So you want to do event sourcing in your project? Great, does your project meet the following requirements?
- Low load (less than <50 writes/sec)
- .NET 7 or newer
- Using Azure cloud
Yes? Then Event Sauce is for you. It's a simple event sourcing library that uses Azure Blob Storage as it's backend. It's super cheap to run and doesn't require any storage servers or messaging infrastructure. It's the tool to use when Kafka is overkill for your project.
Installation
Grab it from NuGet using dotnet add package ServcoX.EventSauce
.
Basic usage
Define your events like this:
public readonly record struct CakeBaked : IEvent;
public readonly record struct CakeIced(String Color) : IEvent;
public readonly record struct CakeCut(Int32 Slices) : IEvent;
Connect to your event store like this:
const String connectionString = "UseDevelopmentStorage=true;";
const String containerName = "sample-container";
using var store = new EventStore(connectionString, containerName);
Write events like this:
await store.Write(new CakeBaked());
await store.Write(new CakeIced("BLUE"));
await store.Write(new CakeCut(3));
Read back events like this:
foreach (var evt in await store.Read())
Console.WriteLine($"{evt.Type}: {evt.Event}");
If you want to only read events from a certain date use something like:
var events = store.Read(new DateOnly(2000, 1, 1))
Projections
Once you have events being stored, you can then go a step further and create projections based on them.
Create a projection like this:
using var store = new EventStore(connectionString, containerName, builder => builder
.PollEvery(TimeSpan.FromMinutes(1)) // <== Check for events created by other writers automatically
.OnEvent<CakeIced>((evt, metadata) => Console.WriteLine($"Cake iced '{evt.Color}' at {metadata.At}"))
.OnEvent<CakeCut>((evt, metadata) => Console.WriteLine($"Cake cut into {evt.Slices} slices at {metadata.At}"))
.OnOtherEvent((evt, metadata) => Console.WriteLine($"Something else (${metadata.Type}) occured at {metadata.At}"))
);
Automatically your code is called whenever an event is raised in your application, or any others writing to the same target. You can use those events to populate your projection in a database like LiteDB or SQLite.
Note that you can change the poll interval to control your consistency.
You can also trigger a manual poll to immediately trigger the callbacks for any events that hadn't yet been received:
await store.PollNow();
Version 4
This is a significant rewrite from version 3. Version 3's client has been moved to the ServcoX.EventSauce.V3
namespace
and is useful for migrations. Version 4's persisted data is incompatible with version 3 and a migration is required
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net7.0
- Azure.Data.Tables (>= 12.8.2)
- Azure.Storage.Blobs (>= 12.19.1)
- ServcoX.Rfc7515C (>= 1.2.0)
-
net8.0
- Azure.Data.Tables (>= 12.8.2)
- Azure.Storage.Blobs (>= 12.19.1)
- ServcoX.Rfc7515C (>= 1.2.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ServcoX.EventSauce:
Package | Downloads |
---|---|
ServcoX.EventSauce.DependencyInjection
Dependency injection wrapper for Event sauce |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.0.4 | 1,769 | 3/14/2024 |
4.0.3 | 192 | 3/14/2024 |
4.0.2 | 254 | 3/13/2024 |
4.0.1 | 152 | 3/12/2024 |
4.0.0 | 165 | 3/12/2024 |
3.2.1 | 245 | 3/7/2024 |
3.2.0 | 532 | 2/16/2024 |
3.1.7 | 1,125 | 1/12/2024 |
3.1.6 | 312 | 1/12/2024 |
3.1.5 | 301 | 1/12/2024 |
3.1.4 | 386 | 1/12/2024 |
3.1.3 | 334 | 1/12/2024 |
3.1.2 | 338 | 1/11/2024 |
3.1.1 | 328 | 1/11/2024 |
3.1.0 | 305 | 1/11/2024 |
3.0.1 | 339 | 1/11/2024 |
3.0.0 | 425 | 1/10/2024 |
2.4.10 | 410 | 1/10/2024 |
2.4.9 | 347 | 1/10/2024 |
2.4.8 | 372 | 1/10/2024 |
2.4.7 | 422 | 1/9/2024 |
2.4.6 | 563 | 1/2/2024 |
2.4.5 | 536 | 1/2/2024 |
2.4.4 | 411 | 1/2/2024 |
2.4.3 | 409 | 1/2/2024 |
2.4.2 | 465 | 12/28/2023 |
2.4.1 | 427 | 12/28/2023 |
2.4.0 | 384 | 12/28/2023 |
2.3.0 | 399 | 12/27/2023 |
2.2.0 | 394 | 12/27/2023 |
2.1.0 | 416 | 12/27/2023 |
2.0.0 | 383 | 12/27/2023 |
1.1.0 | 398 | 12/25/2023 |
1.0.0 | 379 | 12/22/2023 |