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

Add inline projections to In Memory event store #179

Open
2 tasks done
oskardudycz opened this issue Jan 22, 2025 · 1 comment
Open
2 tasks done

Add inline projections to In Memory event store #179

oskardudycz opened this issue Jan 22, 2025 · 1 comment

Comments

@oskardudycz
Copy link
Collaborator

oskardudycz commented Jan 22, 2025

Here's the recommended outline:

1. Add inline projection setup to InMemoryEventStore options

That can be done in a similar way as in the PostgreSQL event store options.

Something like:

export type InMemoryReadEventMetadata = ReadEventMetadataWithGlobalPosition;

export type InMemoryProjectionHandlerContext = {
  eventStore: InMemoryEventStore
};

export type InMemoryEventStoreOptions = DefaultEventStoreOptions<InMemoryEventStore> & {
  projections?: ProjectionRegistration<
    'inline',
    InMemoryReadEventMetadata,
    InMemoryProjectionHandlerContext
  >[];
};

Then, cache them in a similar fashion as Postgres projections.

2. Add InMemoryDatabase

You can clone this one for now: https://github.com/oskardudycz/EventSourcing.NodeJS/blob/main/workshops/introduction_to_event_sourcing/src/11_projections_single_stream/tools/database.ts.

Replace JSON.parse and JSON.stringify with Emmett JSONParser

3. Port handle method to InMemoryDatabase based on Pongo one

It's placed here, should be copy/paste with small adjustments: https://github.com/event-driven-io/Pongo/blob/1a7e6f56454de6f25fa1e58aacf66b3044a434d0/src/packages/pongo/src/core/collection/pongoCollection.ts#L338.

4. Add similar projections like in Pongo

See them: https://github.com/event-driven-io/emmett/blob/52a3ba72359c4ae2de1a041c7dac3d74f77f0a63/src/packages/emmett-postgresql/src/eventStore/projections/pongo/projections.ts

And writeup about them: https://event-driven.io/en/emmett_projections_testing/

Notes

Each can be a dedicated PR.

@oskardudycz
Copy link
Collaborator Author

@stepaniukm, how does that sound to you?

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

No branches or pull requests

1 participant