Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 
avatar of Viacheslav

Viacheslav

Viacheslav has asked 0 questions and find answers to 1 problems.

Stats

13
EtPoint
2
Vote count
0
questions
1
answers

About

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'
}