Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal example? #116

Open
d4h0 opened this issue Oct 4, 2020 · 3 comments
Open

Minimal example? #116

d4h0 opened this issue Oct 4, 2020 · 3 comments

Comments

@d4h0
Copy link

d4h0 commented Oct 4, 2020

Hi,

I just discovered eventually via the Reddit post today, and because I have never seen event sourcing in action I looked for an example. There is the example app, however, I think a more minimal one-file example would be useful for people who are interested in a quick overview.

Would that be possible, or is event sourcing too complex for a simple example like that?

@AngelicosPhosphoros
Copy link

AngelicosPhosphoros commented Oct 5, 2020

++
Also how this library can be used with some database backend, for example, if I want to store all my events in PostgreSQL?
In the current example, repository is in memory.

UPD:
I think, a tutorial how to develop such app would be useful.

@ar3s3ru
Copy link
Collaborator

ar3s3ru commented Oct 5, 2020

Hi @d4h0 and @AngelicosPhosphoros 👋

Thank you for posting the issue!

@d4h0: it might be possible to put everything in a single file, however that file might be a tad long 😅 I'll try to make an easier example to follow. However, let me guide you through the current one.

As a good starting point, you can follow the aggregate module documentation, where you can see a minimal example of how to set up an Aggregate.

This is the main part of Event Sourcing from a user perspective, frankly.

Everything else is just wiring up the EventStore to the Repository and write the handlers that call the Repository and emits commands.

In eventually-app-example:

  1. This is where you'll find the domain implementation, namely the OrderAggregate
  2. This is where you call the Repository to get an AggregateRoot to submit commands (just an example of one single HTTP handler, there are more, one per each command)
  3. This is how you initialize EventStore and Repository in the run, then you can pass these objects to the State of your App (if you're using Tide) so that they are accessible in the HTTP handlers (point 2.)

@AngelicosPhosphoros: indeed, the current example uses an inmemory EventStore.

I thought I included an example for setting up the Postgres' EventStore, but I'm afraid I forgot it.

You can find it in the crate documentation for eventually_postgres

I will include the documentation in the next patch release 👍

@wyhinton
Copy link

Links are stale for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants