hi Guys, I’m attempting to get my head around coro...
# coroutines
d
hi Guys, I’m attempting to get my head around coroutines and could do with a bit of help / advice (it probably doesn’t help that I’m new to Kotlin too)
Copy code
fun health(mongo: MongoClient): (RoutingContext) -> Unit =  {
    val result = pingMongo(mongo)

    if (result.succeeded()) {
        it.response().endWithJson(result.result())
    } else {
        it.response().end()
    }
}

private suspend fun pingMongo(mongoClient: MongoClient): AsyncResult<JsonObject> = suspendCoroutine {
    cont -> mongoClient.runCommand(
        "ping",
        json { obj({ "ping" to 1 }) },
        { cont.resume(it) }
) }
Simple question, how do I call
pingMongo
from the
health
function - I’ve played around with a few different things from the docs but I’ve not quite got my head around it enough yet for things to make sense to me 😞