An aggregate root designed for a streaming environment, addressing the dual write problem by decoupling the domain model from the event stream.
- Easy integration
To install the package, use the following command in your .NET Core project:
dotnet add package StreamWave
Alternatively, you can add it manually to your .csproj
file:
<PackageReference Include="StreamWave" Version="0.1.0" />
Here are some basic examples of how to use the library:
Create your domain objects
// domain.cs
public class TestState
{
public required Guid Id { get; set; }
public string? Test { get; set; }
}
Add the aggregate to the service collection
// program.cs
using StreamWave;
using StreamWave.EntityFramework;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAggregate<TestState, Guid>((id) => new TestState() { Id = id })
.WithEntityFramework<TestContext, TestState, Guid>()
.WithApplier<TestEvent>((s, e) =>
{
s.Test = e.Field;
return s;
});
public async Task HandleAsync(IAggregateManager<TestState, Guid> manager, Guid id)
{
var aggregate = manager.LoadAsync(id);
aggregate.Apply(new TestEvent("Update"));
await manager.SaveAsync(aggregate);
}
[TODO]
Contributions are welcome! Please feel free to submit a pull request or open an issue if you encounter any bugs or have feature requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.