I get some list of data from a HTTP
call. I then know what values to get for another HTTP
call. I would like to have everything be asynchronous. But I need to use this data with Expecto
's testCaseAsync : string -> Async<unit> -> Test
. So, my goal is to get a signature like so Async<Item>[]
So, I would like to get a list of testCaseAsync
.
So, I basically have something like this:
// Async<Async<Item>[]>
let getAsyncCalls =
async {
let! table = API.getTable ()
// Async<Item>[]
let items =
table.root
|> Array.map (fun x -> API.getItem x.id)
return item
}
If I run them in parallel I get:
// Async<Item[]>
let getAsyncCalls =
async {
let! table = API.getTable ()
// Item[]
let! items =
table.root
|> Array.map (fun x -> API.getItem x.id)
return item
}
So, that doesn't get me to Async<Item>[]
. I'm not sure if this is possible. I would like to avoid Async.RunSynchronously
for the API.getTable
call since that can lead to deadlocks, right? It will most likely be called from a cached value (memoized
) so I'm not sure that will make a difference.
I guess I'll keep working on it unless someone else is more clever than me :-) Thanks in advance!