samedi 22 septembre 2018

Is there a name for a design pattern where collections are updated in sequence and the last is considered the source of truth?

Let's say I'm trying to transform SQL storage to no-SQL storage (e.g. SQL Server to Cosmos DB). I have three related tables A, B, C which I want to convert to document collections X, Y, Z. But I don't have the advantage of being able to update all the documents transactionally like I would in SQL. So how I design the update to the documents in my workflow is a sequential update like

1. Update X
2. Update Y
3. Update Z

Such that any of the following scenarios

1 -> FAIL
2 -> FAIL
3 -> FAIL


1 -> SUCCEED
2 -> FAIL
3 -> FAIL


1 -> SUCCEED
2 -> SUCCEED
3 -> FAIL


1 -> SUCCEED
2 -> SUCCEED
3 -> SUCCEED

may leave the data in an "inconsistent state," but I use the repository pattern to query the data with a query like

Get data from Z
Get matching data from Y
Get matching data from X

so that all the update scenarios are covered.

Is there a name for this pattern [or did I invent something new :) ]?

Is this a pattern or an anti-pattern?

Is there a better way?

Aucun commentaire:

Enregistrer un commentaire