EventSaucing 2.0.3
See the version list below for details.
dotnet add package EventSaucing --version 2.0.3
NuGet\Install-Package EventSaucing -Version 2.0.3
<PackageReference Include="EventSaucing" Version="2.0.3" />
paket add EventSaucing --version 2.0.3
#r "nuget: EventSaucing, 2.0.3"
// Install EventSaucing as a Cake Addin #addin nuget:?package=EventSaucing&version=2.0.3 // Install EventSaucing as a Cake Tool #tool nuget:?package=EventSaucing&version=2.0.3
EventSaucing
Add a little EventSauce to your project 😉
This library brings together different stacks to create an Event Sourcing solution.
Reading list before using the project:
Installing
The latest release of EventSaucing is available on NuGet.
Usage
Once referenced in your project you need to configure it in your Startup inside ConfigureServices
.
var builder = new ContainerBuilder();
builder.RegisterEventSaucingModules(new EventSaucingConfiguration {
ConnectionString = // Set your connection string
});
builder.Populate(services); // Populate your services.
var container = builder.Build();
container.StartEventSaucing(); // Start EventSaucing
You can then construct your Aggregates by inheriting from the Aggregate
class and including Apply()
methods to handle the raised events on the aggregate.
public class FooAggregate : Aggregate {
public FooAggregate(Guid id) {
base.Id = id;
}
public int Bar { get; set; }
public void Create(int bar) {
RaiseEvent(new FooCreated(bar));
}
void Apply(FooCreated @event) {
Bar = @event.Bar;
}
}
// A POCO for the event state
public class FooCreated {
public FooCreated(int bar) {
Bar = bar;
}
public int Bar { get; }
}
You can then create Projectors by inheriting from ProjectorBase
and setting up which events to handle. You must also give each projector a unique number. In this example Dapper is used to interact with the persistence store.
[Projector(1)] // The unique projector id.
public class FooProjector: ProjectorBase {
readonly ConventionBasedCommitProjecter _conventionProjector;
public FooProjector(IDbService dbService, IPersistStreams persistStreams):base(persistStreams, dbService) {
var conventionalDispatcher = new ConventionBasedEventDispatcher(c => Checkpoint = c.ToSome())
.FirstProject<FooCreated>(OnFooCreated)
.ThenProject<SomeEvent>(OnSomeEventHandler);
_conventionProjector = new ConventionBasedCommitProjecter(this, dbService, conventionalDispatcher);
}
public override void Project(ICommit commit) {
_conventionProjector.Project(commit);
}
private void OnFooCreated(IDbTransaction tx, ICommit commit, FooCreated @event) {
var sqlParams = new {
Id = commit.AggregateId(),
Bar = FooCreated.Bar
};
const string sql = @"
INSERT INTO [dbo].[FooProjector.Foo]
([Id]
,[Bar])
SELECT
@Id
,@Bar
WHERE NOT EXISTS(SELECT * FROM [dbo].[FooProjector.Foo] WHERE Id = @Id);";
tx.Connection.Execute(sql, (object)sqlParams, tx);
}
Dependencies
- Dapper - Used to interact with the sql persistence store.
- NEventStore - Used for storage of the event stream.
- Serilog - Used for logging.
- Akka.NET - Used to deliver deliver events to aggregates & projectors.
- Autofac - Used for dependency injection.
- Scalesque - Used to add functional programming in c#.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 was computed. 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 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Akka.Cluster.Sharding (>= 1.5.14)
- Akka.Cluster.Tools (>= 1.5.14)
- Akka.DependencyInjection (>= 1.5.14)
- Akka.Logger.Serilog (>= 1.5.12.1)
- Akka.Persistence (>= 1.5.14)
- Akka.Persistence.SqlServer (>= 1.5.13)
- Autofac.Extensions.DependencyInjection (>= 8.0.0)
- Dapper (>= 2.1.21)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- NEventStore.Domain (>= 9.1.1)
- NEventStore.Persistence.Sql (>= 9.1.2)
- NEventStore.Serialization.Json (>= 9.1.1)
- Scalesque (>= 1.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.
Version | Downloads | Last updated |
---|---|---|
2.0.7 | 452 | 10/31/2024 |
2.0.6 | 360 | 6/11/2024 |
2.0.5 | 116 | 6/10/2024 |
2.0.4 | 177 | 5/30/2024 |
2.0.3 | 451 | 4/8/2024 |
2.0.2 | 200 | 3/25/2024 |
2.0.1 | 245 | 11/16/2023 |
2.0.0 | 121 | 11/16/2023 |
1.0.30 | 121 | 3/22/2024 |
1.0.29 | 451 | 8/27/2021 |
1.0.28 | 373 | 7/27/2021 |
1.0.27 | 433 | 6/24/2021 |
1.0.6 | 715 | 3/29/2019 |
1.0.5 | 798 | 10/29/2018 |
1.0.4 | 1,044 | 3/6/2018 |
1.0.3 | 987 | 9/20/2017 |
1.0.2 | 996 | 9/7/2017 |
1.0.1 | 1,115 | 8/1/2017 |
Bug fix release:
if an exception occurred in a SP, it would restart but stop catching up until user activity occurred, but since in re-hydration there is no user activity until rehydration completes, they just sat there. SP now catch up on re-start after a crash automatically.
fixed bug where SPs were registered with Akka with random numbers instead of their names which made debugging harder
fixed bug where during catch up, SPs would spam themselves with commit messages that they couldnt project because they were too far ahead of their checkpoint which meant pointless CPU activity and memory leak
fixed bug where if lots of SPs caught up at the same time (eg rehydration) it generated so many Akka messages that dependent SPs effectively came under a denial of service attack! (think 100,000s messages per second)
fixed bug where dependent SPs stopped catching up with proceeding SPs until user acitivity occurred
fixed bug where a lot of Akka dead letter messages were produced on app start up