If this function returns false, we will queue the operation for later. Some logic in the processing code can be simplified as the result of this change.
Depends on D12936
Differential D12948
[lib] Add a function to DM operations spec checking if an operation can be applied tomek on Jul 30 2024, 9:15 AM. Authored by Tags None Referenced Files
Subscribers
Details If this function returns false, we will queue the operation for later. Some logic in the processing code can be simplified as the result of this change. Depends on D12936 Tested this for one case - creating change_thread_settings update for a thread that isn't present in the store. Also tested that if the thread is in the store, the ops are being processed.
Diff Detail
Event TimelineComment Actions I had previously suggested implemented a solution to this based on a tcomb validator. We'll need to specify IDs that have to be checked for collision again certain SQLite tables, and I was planning on using a tcomb validator approach for that. It seems like checking IDs for existence in certain SQLite tables is a very similar problem, and ought to be solved in a similar way. Comment Actions Not sure if @ashoat's comment demands changes to this diff, please make sure to address it Comment Actions I'm not sure. It sounds similar, but there are important differences:
It feels to me that validation and checking if an operation can be processed are two distinct things and using validators instead of canBeProcessed will be more complicated. But I'm open to giving it a try. If we decide to do that I would rather land this diff and modify the logic later, to make sure we unblock other things (in this case the whole queueing logic). Comment Actions Discussed this with @tomek in our 1:1 and we agreed to proceed with this approach for now. I think that using validators for the most common cases makes sense, but I agree there are exceptions where we'll need to do something more complicated. For those complicated cases, I think having this canBeProcessed function on the spec makes sense
Comment Actions
I don't agree that this is a "different approach". I try to consistently use this approach, except in cases where the returned value really should not be modified. |