0

I have a simple method which add data into Cassandra database:

 def addData(data: SomeData): Task[Either[Exception, Unit]]

I use it to add same data to two tables at the same type:

for {
 persistOneTable <- repo.addData(data).mapError(SomeError(_))
 persistSecondTable <- repo2.addData(data).mapError(SomeError(_))
} yield ()

My question is, how should I change this code to retry inserting to table if it failed at first time? I do not want to have inconsistent data in tables, so if it failed after insert to first table I want to retry it and then insert to second table and also retry there until it is added to have exactly same data in both tables

Anonymous Asked question May 13, 2021