Change async workflow builder to count steps?
My understanding is that what a workflow builder does is that it first
"builds" the expression, and then subsequently executes it. So given that
it first builds the expression, it should be able to count the number of
let! statements before actually executing, right? And then it should be
able to inject some logging that monitors progress? So is it possible to
rework the async builder to automatically report progress and kill the
printfn redundancy below?
async {
let! a = doSomething1 ()
printfn "%d/%d" 1 4
let! b = doSomething2 a
printfn "%d/%d" 2 4
let! c = doSomething3 b
printfn "%d/%d" 3 4
let! d = doSomething4 c
printfn "%d/%d" 4 4
return d
}
For loops, I guess just assume that the whole loop is a single step. Only
top-level expressions count as steps here.
(Note if there's a way to do this without making a whole new workflow
builder I guess that's fine too).
Note I've already gone through the path of a) making a "Task" iterator
that just iterates tasks (but then you lose e.g. use handling, so it ended
up being inadequate), and b) making a task counter, but that always had to
be seeded and iterated manually so I'm hoping for something better.
No comments:
Post a Comment