meteor-space / event-sourcing

CQRS and Event Sourcing Infrastructure for Meteor.
MIT License
63 stars 9 forks source link

Management of old snapshots #79

Closed rhyslbw closed 8 years ago

rhyslbw commented 8 years ago

I'd like to get opinions on the idea of purging snapshots, controlled by the ES module, work performed in the Space.JobQueue as an option.

We only need the last one for each aggregate all others are just redundant weight in the database, however a configurable capped value comes to mind to allow tuning to what makes sense based on the project + env requirements.

snapshotting: {
  enabled: ['SPACE_ES_SNAPSHOTTING_ENABLED', true, 'bool']
  frequency: ['SPACE_ES_SNAPSHOTTING_FREQUENCY', 10, 'int']
  capped: ['SPACE_ES_SNAPSHOTTING_CAPPED', true, 'bool'] 
  cappedTo: ['SPACE_ES_SNAPSHOTTING_CAPPED', 1, 'int'] 
}

Note: I can see that just a cron would also suite some scenarios too, although that's a separate concern and I can be implemented without Space, although an api could help with getting a list of all Aggregate types. (see comment below)

rhyslbw commented 8 years ago

Also we should really push the default to at least 20 IMO. 10 seems a little aggressive

rhyslbw commented 8 years ago

Ok, I misunderstood what was happening here. This is not required as there will only ever be one snapshot since we updating rather than inserting. Right on! Given this is the case, 10 seems alright