MaskingTechnology / comify

Comic based social network built with Jitar
GNU Affero General Public License v3.0
3 stars 1 forks source link

Prepare for carbage collection #245

Closed petermasking closed 3 months ago

petermasking commented 3 months ago

Currently, we've built SAGAs for features that create or update multiple data entities. While this works great, there a few downsides:

  1. Added complexity to the code (try / catch construction)
  2. Extended number of test-cases (test undo scenario's)
  3. Slowed failures (awaiting undo actions)

After analyzing a few features, we've noticed that most of them only use a SAGA for cleaning up data on failure. Besides keeping the database clean, the undo actions have no function. It doesn't provide any value to the end-user. So, if we're willing to accept unreferenced data in the database, we'll be able to cleanup and simplify.

Example case At the creation of a comic, an image gets created first so it can be referenced by the comic. The current implementation will undo the image creation when the creation of the comic fails. Does the world end when don't remove the image directly? (the answer is no: at least, we think, we haven't tried yet...)

Alternative solution The alternative we have in mind is utilizing a (decentralized) garbage collector that periodically removes all unreferenced data. Although we won't add this directly we want to already start cleaning up and simplifying the code.

DoD All SAGAs are removed form features that create related data only referenced by the feature data.

basmasking commented 3 months ago

A few SAGA patterns remain:

In all cases we update some meta data on the creator, post or reaction. By the time we have events to update the meta data separately, we can reconsider the remaining SAGAs.