I have an IObservable provided by a library, which listens to events from an external service:
let startObservable () : IObservable<'a> = failwith "Given"
For each received event I want to execute an action which returns Async:
let action (item: 'a) : Async<unit> = failwith "Given"
I'm trying to implement a processor in lines of
let processor () : Async<unit> =
startObservable()
|> Observable.mapAsync action
|> Async.AwaitObservable
I've made up mapAsync and AwaitObservable: ideally they would be provided by some library, which I'm failing to find so far.
Extra requirements:
Actions should be executed sequentially, so subsequent events get buffered while a previous event is handled.
If an action throws an error, I want my processor to complete. Otherwise, it never completes.
Cancellation token passed via
Async.Startshould be respected.
Any hints about the library that I should be using?