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

Redis events: relaxing constraint of revision starting at 0 #132

Open
TyGuy opened this issue Jun 24, 2018 · 1 comment
Open

Redis events: relaxing constraint of revision starting at 0 #132

TyGuy opened this issue Jun 24, 2018 · 1 comment

Comments

@TyGuy
Copy link
Contributor

TyGuy commented Jun 24, 2018

Summary

I'm not sure if this is a bug or feature request (probably the latter), but here is what I want to do vs what happens.

What I want

GIVEN events with revisions "m" through "n" exist for a certain aggregate (regardless of whatever other events exist),
WHEN I query for events using getEventsByRevision(aggregateId, m, n, callback),
THEN I expect to receive events with revisions "m" through "n" in the callback response.

What happens

GIVEN events with revisions "m" through "n" exist, BUT some events with revisions "0" through "m" (i.e. if any events between "0" and "m" do not exist),
WHEN (same as above),
THEN I receive the wrong events (sometimes no events)

When would this happen?

I have a use-case where we store lots of events for lots of aggregates, and we wanted a combination of speed and cheap(er) scalability (in terms of absolute event size). In other words, we didn't want an increasing number of events to slow down the querying of events too much.

Our solution was to write to 2 event stores simultaneously (using dynamo and redis), but only keep the most recent "N" events in the redis store for fast retrieval (once we've confirmed events were written to both stores). This means we have to remove old events (with old revisions) and want to continue being able to use the redis event store for querying in the same way.

How to fix

I made this work for our use-case a little while back, but then got busy and forgot to open a PR. I will link it shortly once I open it. This relaxes the constraints that all events (starting at revision 0) exist in the store, and retrieves the correct events by revision in either case (by using filter vs slice).

@adrai hope this makes sense. Let me know if you have questions about why or how, or changes you'd like to see.

@TyGuy
Copy link
Contributor Author

TyGuy commented Jun 24, 2018

#133

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

1 participant