Lets say i have a method updateRecord()
, and this method performs some async requests inside of it, and some of this requests are more important than others since they impact hardware, and some are, although necessary, only affecting a record in a db. All this info combined represents one action for the business model.
What should be the order of this requests, regarding fiability of data? Should i do all the non important first (that will probably not fail) and then the hardware one (can fail to update since it requires internet conection, but the value saved here is the only important value at the end of the day)? If the important one fails, should i delete the records created before?
The other way around?
Or some other way?
Some pseudocode to represent my dilemma:
async updateRecord(){
a = await setLogOfCurrentData()
if (a) { do something }
b = await updateARecordInDB()
if (a) { do something }
c = await updateImportantInfoInHardware()
if (!c) {
???
}
}
Thank you!
Ps: dont know how to properly tag this question, if you have some ideas let me know!