Dan
11/13/2017, 10:15 AMfun 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 😞