obsidiansystems / rhyolite

BSD 3-Clause "New" or "Revised" License
26 stars 17 forks source link

change taskWorker to not require a hasRun field #197

Closed danbornside closed 2 years ago

danbornside commented 2 years ago

a compatibility helper taskWorker1 retains the old behavior where it's useful.

In many typical uses of taskWorker, an app will want to use a task update a remote machine to have a particular, target state. The natural way to express this is a pair of columns which encode the last state the app pushed to the remote machine and the current state it "should be". the task would then run whenever these two are different.

this is quite awkward to directly express with the hasRun feature baked into rhyolite task workers; since a separate system would need to reset the task to run again after discovering that they have diverged. this is especially vexing because the state can change while a task is already running; and there's no way to interrupt the task, or otherwise reschedule it while it's still running. the task will be marked hasRun unconditionally and not be a candidate to rerun.

the hasRun feature is not useless, though; but can be easily implemented in terms of a task that doesn't have that built in; by leveraging the existing extensibility in task filtering and updates; so this PR provides "both".