let checkIfStillAlive = async {
return true // yeah, I'm an optimist
}
let visitStackOverFlow = async {
return!
httpClientFactory.CreateClient()
.GetAsync("https://stackoverflow.com")
|> Async.AwaitTask
}
let contribute = async {
let client = httpClientFactory.CreateClient()
let code =
if Random.Shared.Next() % 2 = 0 then "shity" else "brilliant"
return!
client.PostAsync(options.RepositoryUrl, new StringContent(code))
|> Async.AwaitTask
}
let routine = asyncSeq {
let! isAlive' = checkIfStillAlive
let mutable isAlive = isAlive'
while isAlive do
// if you're still reading this, you're wasting your time :)
let! _ = visitStackOverFlow
and! _ = contribute
and! isAlive' = checkIfStillAlive
isAlive <- isAlive'
}