node-cqrs-eventdenormalizer icon indicating copy to clipboard operation
node-cqrs-eventdenormalizer copied to clipboard

getLastEventOfEachAggregate, onBeforeSet middleware

Open robinfehr opened this issue 4 years ago • 5 comments

  • set data to rev guard store via onBeforeSet middleware
  • new cocatenatedId format with delimiters to better parse the value
  • get data from rev guard store via exposed getLastEventsOfEachAggregate fn

robinfehr avatar Jun 11 '20 23:06 robinfehr

  1. Maybe clarify with some comments, what is the difference between: prefix (https://github.com/adrai/node-cqrs-eventdenormalizer/pull/90/files?file-filters%5B%5D=.js&file-filters%5B%5D=.md#diff-04c6e90faac2675aa89e2176d2eec7d8R100) and prefix (https://github.com/adrai/node-cqrs-eventdenormalizer/pull/90/files#diff-0745fa2041110cff3082322255437920R499)

  2. can there be a possibility to optionally omit the prefix and keep the old api? https://github.com/adrai/node-cqrs-eventdenormalizer/pull/90/files#diff-ab712d0ee8b0b73d36fe730eeefa8bebR452 btw. Maybe changing the signature is not needed at all, because the prefix is in the options?

  3. add some info to the readme or changelog regarding v2 breaking changes (also for those directly using the store functionality...)

  4. docs for getLastEventOfEachAggregate in the readme

adrai avatar Jun 12 '20 05:06 adrai

can you explain the purpose of the PR a bit? Sorry but, by glance, it seems as you are trying to solve a problem in the wrong domain :/

nanov avatar Jun 13 '20 16:06 nanov

can you explain the purpose of the PR a bit? Sorry but, by glance, it seems as you are trying to solve a problem in the wrong domain :/

we use the even'ts occuredAt date to fetch events that we missed. Our implementation of the queue / bus to our denormalizers are not persistent and therefore it can happen that we miss some events. We then fetch them using a replayer service - common pattern - to which we send a request to retrieve the missed events beginning a certain from date to the last saved event in the store. We have to find the oldest / smallest occuredAt date for all our aggregates in the denormalizer. To do so, having only the revision wihtin the revision guard per aggregate, we'd have to make a query to the eventstore (in our case via the replayer service) for each aggregate and it's revision to retrieve the from date. Putting that traffic onto the denormalizers db is better since it won't affect the evenstore and therefore the rest of the ecosystem. To achieve that the middleware got added, so that we can save the occuredAt or any other data to the denormalizers db and off-load the traffic from the eventstore. The last_seen_event can't be used since the handle fn is per aggregate and therefore an other aggregate can be behind the last_seen_event's time or any other meta data that would be stored there.

robinfehr avatar Jun 14 '20 22:06 robinfehr

  1. Maybe clarify with some comments, what is the difference between: prefix (https://github.com/adrai/node-cqrs-eventdenormalizer/pull/90/files?file-filters%5B%5D=.js&file-filters%5B%5D=.md#diff-04c6e90faac2675aa89e2176d2eec7d8R100) and prefix (https://github.com/adrai/node-cqrs-eventdenormalizer/pull/90/files#diff-0745fa2041110cff3082322255437920R499)
  2. can there be a possibility to optionally omit the prefix and keep the old api? https://github.com/adrai/node-cqrs-eventdenormalizer/pull/90/files#diff-ab712d0ee8b0b73d36fe730eeefa8bebR452 btw. Maybe changing the signature is not needed at all, because the prefix is in the options?
  3. add some info to the readme or changelog regarding v2 breaking changes (also for those directly using the store functionality...)
  4. docs for getLastEventOfEachAggregate in the readme
  1. it is the same. the prefix can still be specified within the revisiongard's options. api-wise nothing changed. just the default prefix is now different.

  2. the old api is still intact. the prefix can be omitted. the signature of the stores got changed so that they're agnostic towards the denormalizer's options and threfore can be unit tested properly.

  3. will do :)

  4. will do :)

robinfehr avatar Jun 17 '20 23:06 robinfehr

  1. I mean the store signature... Why not keep the old signature and use this.options.prefix within the function?

adrai avatar Jun 18 '20 04:06 adrai