Event-sourced sample for the Opine framework
First, clone the Opine Framework and build it.
git clone https://github.com/cpersona/Opine
cd Opine
dotnet build
Then clone the sample and build it. It should sit as a sibling to Opine.
git clone https://github.com/cpersona/Opine.Sample.Plugin
cd Opine.Sample.Plugin
dotnet build
In VSCode, debug the Opine framework using the "Go Opine.Job" launch task. (Press F5). This will run through commands in the message store and dispatch them. Change launch.json and replace "commands" with "events" to run through events and call projections.
In an actual test or production environment, you would have separate instances running, one for commands and one for events.
The CustomerAggregate is responsible for ensuring consistency within the Customer root. You can create a customer, add a subscription, or end the current subscription. The following events are raised:
- Created
- SubscriptionAdded
- SubscriptionRemoved
The CustomerCommandler class handles commands sent to a Customer. The following commands are handled:
- Create
- AddSubscription
- RemoveSubscription
The CustomerProjection and CustomerSubscriptionProjections handle events and would be used to project data into respective tables in a database. These classes are called when processing the "events" stream (-s option in launch.json).
The SampleMessageStore is a simple in-memory message store used to simulate a store such as EventStore. It is pre-loaded with events and commands to allow for testing command handling and event handling.
The SampleUnitOfWork is a no-op class. In a real scenario, data would be persisted to EventStore after commands have been processed or to a database after events have been processed and projections have run.
The SampleSnapshotStore is a no-op class. In a real scenario, snapshots would be saved to and loaded from EventStore or relational database depending on requirements.