evanchooly
05/01/2017, 1:41 AMjkwatson
05/01/2017, 2:25 AMenighma
05/01/2017, 5:29 AMenighma
05/01/2017, 6:29 AMsdeleuze
05/01/2017, 7:11 AMorangy
kenkyee
05/01/2017, 4:41 PMmiha-x64
05/01/2017, 4:51 PMdanneu
05/01/2017, 9:59 PMvonox7
05/02/2017, 10:36 PMoluwasayo
05/03/2017, 5:23 PMenighma
05/03/2017, 5:29 PMenighma
05/03/2017, 5:31 PMmiha-x64
05/03/2017, 5:44 PMenighma
05/03/2017, 6:30 PMorangy
get("/path") { call.respond("Hello") }
is all you need for a simple HTTP request, and if/when you need more and more complex tasks you can gradually increase your knowledge of some under-the-hood mechanics and go deeperenighma
05/03/2017, 6:44 PMorangy
janvladimirmostert
05/03/2017, 6:47 PMval vertx = Vertx.vertx()
val router = Router.router(vertx)
router.enableCookies()
router.enableCORS(allowedMethods = listOf(HttpMethod.GET, <http://HttpMethod.POST|HttpMethod.POST>, HttpMethod.OPTIONS))
router.blockingPost("/login", AccountController::login)
router.blockingPost("/logout", AccountController::logout)
router.blockingPost("/account/list", AccountController::list)
Seems like a similar idea to ktor, keeping it simpleorangy
janvladimirmostert
05/03/2017, 6:49 PMorangy
orangy
janvladimirmostert
05/03/2017, 6:50 PMjanvladimirmostert
05/03/2017, 6:51 PMfun Router.blockingPost(url: String, handler: KFunction1<@ParameterName(name = "request") RestRequest, RestResponse>) {
<http://this.post|this.post>(url).handler { rtx ->
// extract cookies
val cookies = mutableMapOf<String, String>()
rtx.cookies().forEach { cookie ->
cookies.put(key = cookie.name, value = cookie.value)
}
// extract body
rtx.request().bodyHandler { btx ->
rtx.vertx().executeBlocking<RestResponse>({
val response = handler.invoke(RestRequest(
cookies = cookies,
routingContext = rtx,
json = String(btx.bytes)))
it.complete(response)
}, {
val response = it.result()
if (it.succeeded()) {
if (response.json.isNotBlank()) {
rtx.response().setStatusCode(200).end(response.json)
}
} else {
RestEasy.log.error(it.cause().message, it.cause())
rtx.response().setStatusCode(500).end(it.cause().message)
}
})
}
}
}
orangy
For example, systems with a mix of long running transactions and very short transactions are generally the most difficult to tune with any connection pool. In those cases, creating two pool instances can work well (eg. one for long-running jobs, another for “realtime” queries).The problem here is that often you cannot really know upfront if the transaction will be long running or not. It can depend on specific data being requested, query parameters, etc. Without the help from the application developer I don’t think framework can have a chance to automatically balance it.
orangy
andrewoma
05/04/2017, 8:18 PMandrewoma
05/04/2017, 8:21 PMandrewoma
05/04/2017, 8:36 PM