Skip to content

Orleans Event Sourcing #5

@egil

Description

@egil

I need the following capabilities for an event sourcing implementation on top of for dotnet 9 Orleans.

  1. A grain receives an event (can be multiple distinct types) via streams or RPC call that it adds to its event stream.
  2. There can be multiple different streams, typically split by type.
  3. It should be possible to specify per event stream how deduping and stream clean up should happen. E.g., in some cases, we just want the latest event of a type based on an ID, in other cases we want to keep the latest events based on a predicate, e.g., all events that are less than 10 days old.

When a grain receives an event via stream (OnNextAsync) or RPC call, it persists the event if it matches the predicate for the stream and then return to the caller.

Then, asynchronously, it should apply the latest event to its projection, the projection is just an IPersistentState<T> that the grain can pick as it pleases, and add any new events created by the grain based on the received event, to an outbox, which is then emptied. If persisting projection or emptying outbox fails, the operation must be retried.

Finally, the received event should be marked as handled on the stream it belongs to, e.g., to avoid derived events getting recreated and published via the outbox unnecessarily.

In the case where the projection doesn't exist, fails to deserialize from its storage, the event streams that belong to the grain must be used to recreate the projection, without new derived events being created.

If a grain has multiple event streams, events from each stream must be replayed in the order they were received in globally.

Storage of events streams should be configurable, but initially it will make sense to leverage Azure Table Storage. It's cheap and fast and should be an excellent fint.

Is there an existing open-source library that can be configured to support all these scenarios, and if yes, lets prototype an EventGrain base type for such a grain.

If there is not, lets prototype an EventGrain base type that uses TableClient directly.

Research Orleans to ensure that EventGrain follows best practices for base grain types and support things such as migration of a live grain from one silo to another without loss of data.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions