I have issues understanding the async nature of the AppendToStreamAsync method.
Here is a link to the sample program I am setting up.
I am using this method to make async call synchronous:
let awaitTask (t:Task) = t.ContinueWith (fun t -> ()) |> Async.AwaitTask |> ignore
an I use it this way :
conn.AppendToStreamAsync(n,expectedVersion,events) |> awaitTask
I then try to fetch them using :
let! slice = conn.ReadStreamEventsForwardAsync(n,0,99,false) |> Async.AwaitTask
I am currently trying to store a few events and retrieve thme immediately :
do! handleMyDomainCmdAsync (idAggregate ,0 , MyDomain.Cmd2)
do! handleMyDomainCmdAsync (idAggregate ,1 , MyDomain.Cmd1)
printfn “waiting for ges to handle the writting of the event ??”
printfn “hydrating fake Agg from events produced by previous command”
let! myDomainAggState = hydrateAggAsync<MyDomain.Evt> MyDomain.streamName MyDomain.applyEvt MyDomain.State.Initial conn idAggregate
The thing is that if I do not make a Thread.Sleep(500) , fetching events from the ges will not render any, whereas allowing some time will render the three exepected events.
My question is :
Waiting for the conn.AppendToStreamAsync(n,expectedVersion,events) to end his task means that events are written in the datasource and available for fetching, right? Or is there still some asynchrony inside the ges as well ?
Thanks for your help,