EventSaucing 2.0.7
dotnet add package EventSaucing --version 2.0.7
NuGet\Install-Package EventSaucing -Version 2.0.7
<PackageReference Include="EventSaucing" Version="2.0.7" />
paket add EventSaucing --version 2.0.7
#r "nuget: EventSaucing, 2.0.7"
// Install EventSaucing as a Cake Addin #addin nuget:?package=EventSaucing&version=2.0.7 // Install EventSaucing as a Cake Tool #tool nuget:?package=EventSaucing&version=2.0.7
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. |
.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 (>= 1.5.30)
- Akka.Cluster.Sharding (>= 1.5.30)
- Akka.Cluster.Tools (>= 1.5.30)
- Akka.DependencyInjection (>= 1.5.30)
- Akka.Logger.Serilog (>= 1.5.25)
- Akka.Persistence (>= 1.5.30)
- Akka.Persistence.SqlServer (>= 1.5.30)
- Autofac.Extensions.DependencyInjection (>= 8.0.0)
- Dapper (>= 2.1.35)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging (>= 8.0.1)
- 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 | 82 | 10/31/2024 |
2.0.6 | 347 | 6/11/2024 |
2.0.5 | 103 | 6/10/2024 |
2.0.4 | 163 | 5/30/2024 |
2.0.3 | 442 | 4/8/2024 |
2.0.2 | 190 | 3/25/2024 |
2.0.1 | 237 | 11/16/2023 |
2.0.0 | 112 | 11/16/2023 |
1.0.30 | 113 | 3/22/2024 |
1.0.29 | 441 | 8/27/2021 |
1.0.28 | 362 | 7/27/2021 |
1.0.27 | 422 | 6/24/2021 |
1.0.6 | 704 | 3/29/2019 |
1.0.5 | 784 | 10/29/2018 |
1.0.4 | 1,030 | 3/6/2018 |
1.0.3 | 973 | 9/20/2017 |
1.0.2 | 981 | 9/7/2017 |
1.0.1 | 1,101 | 8/1/2017 |
Upgraded Akka version to fix critical bug + minor versions of other dependencies