ServcoX.EventSauce 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ServcoX.EventSauce --version 1.0.0                
NuGet\Install-Package ServcoX.EventSauce -Version 1.0.0                
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="ServcoX.EventSauce" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ServcoX.EventSauce --version 1.0.0                
#r "nuget: ServcoX.EventSauce, 1.0.0"                
#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.
// Install ServcoX.EventSauce as a Cake Addin
#addin nuget:?package=ServcoX.EventSauce&version=1.0.0

// Install ServcoX.EventSauce as a Cake Tool
#tool nuget:?package=ServcoX.EventSauce&version=1.0.0                

ServcoX.EventSauce

Event Sauce is a super light-weight event sourcing library we use internally to store our events in Azure Table Storage. Its for when you want to use event sourcing but your needs aren't demanding or your budget is modest. We use it for internal projects with a few hundred user and it works a treat. It's not Kafka, and it's not trying to be.

Because it backs onto Azure Table Storage, it's cost is tiny compared to other options. It's also simple to allow you to build on it in your own way.

TLDR;

Define your events like this:

public readonly record struct BakedCake : IEventBody;
public readonly record struct IcedCake(String Color) : IEventBody;
public readonly record struct CutCake(Int32 Slices) : IEventBody;

Connect to your event store like this:

const String connectionString = "UseDevelopmentStorage=true;"; // Your Azure Storage connection string goes here
var eventStore = new EventStore(connectionString);

Create a stream and write events like this:

const String streamType = "CAKE";
var streamId = Guid.NewGuid().ToString();
var userId = Guid.NewGuid().ToString();
await eventStore.CreateStream(streamId, streamType, CancellationToken.None);
await eventStore.WriteStream(streamId, new BakedCake(), userId, CancellationToken.None);
await eventStore.WriteStream(streamId, new IcedCake("BLUE"), userId, CancellationToken.None);
await eventStore.WriteStream(streamId, new CutCake(3), userId, CancellationToken.None);

Get a list of streams you've already created like so:

foreach (var stream in eventStore.ListStreams(streamType))
{
    Console.WriteLine(stream.Id);
}

And finally, read events back like here:

foreach (var evt in eventStore.ReadStream(streamId, 0)) // <== Can pick a greater version to only read new events
{
    Console.WriteLine(evt.Version + ": " + evt.Body);
}

Simples!

Product Compatible and additional computed target framework versions.
.NET 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. 
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 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