Switch to ktor's CIO backend

It seems to deal with backpressure better than the Netty backend.

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 3 years ago
parent 36e16a8687
commit a52955fe4b
  1. 1
      archive/build.gradle.kts
  2. 4
      archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt
  3. 5
      gradle/libs.versions.toml

@ -34,6 +34,7 @@ dependencies {
implementation(libs.jquery) implementation(libs.jquery)
implementation(libs.jsoup) implementation(libs.jsoup)
implementation(libs.kotlin.coroutines.core) implementation(libs.kotlin.coroutines.core)
implementation(libs.netty.handler)
implementation(libs.postgres) implementation(libs.postgres)
} }

@ -14,8 +14,8 @@ import io.ktor.response.respond
import io.ktor.response.respondRedirect import io.ktor.response.respondRedirect
import io.ktor.routing.get import io.ktor.routing.get
import io.ktor.routing.routing import io.ktor.routing.routing
import io.ktor.server.cio.CIO
import io.ktor.server.engine.embeddedServer import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import io.ktor.thymeleaf.Thymeleaf import io.ktor.thymeleaf.Thymeleaf
import io.ktor.thymeleaf.ThymeleafContent import io.ktor.thymeleaf.ThymeleafContent
import io.ktor.webjars.Webjars import io.ktor.webjars.Webjars
@ -33,7 +33,7 @@ public class WebServer @Inject constructor(
@Json private val mapper: ObjectMapper @Json private val mapper: ObjectMapper
) { ) {
public fun start(address: String, port: Int) { public fun start(address: String, port: Int) {
embeddedServer(Netty, host = address, port = port) { embeddedServer(CIO, host = address, port = port) {
install(ContentNegotiation) { install(ContentNegotiation) {
register(ContentType.Application.Json, JacksonConverter(mapper)) register(ContentType.Application.Json, JacksonConverter(mapper))
} }

@ -46,13 +46,14 @@ kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-co
kotlin-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinCoroutines" } kotlin-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinCoroutines" }
kotlinPoet = { module = "com.squareup:kotlinpoet", version = "1.9.0" } kotlinPoet = { module = "com.squareup:kotlinpoet", version = "1.9.0" }
ktor-jackson = { module = "io.ktor:ktor-jackson", version.ref = "ktor" } ktor-jackson = { module = "io.ktor:ktor-jackson", version.ref = "ktor" }
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" } ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" }
ktor-thymeleaf = { module = "io.ktor:ktor-thymeleaf", version.ref = "ktor" } ktor-thymeleaf = { module = "io.ktor:ktor-thymeleaf", version.ref = "ktor" }
ktor-webjars = { module = "io.ktor:ktor-webjars", version.ref = "ktor" } ktor-webjars = { module = "io.ktor:ktor-webjars", version.ref = "ktor" }
logback = { module = "ch.qos.logback:logback-classic", version = "1.2.5" } logback = { module = "ch.qos.logback:logback-classic", version = "1.2.5" }
netty-buffer = { module = "io.netty:netty-buffer", version.ref = "netty" } netty-buffer = { module = "io.netty:netty-buffer", version.ref = "netty" }
netty-codec-core = { module = "io.netty:netty-codec", version.ref = "netty" } netty-codec-core = { module = "io.netty:netty-codec", version.ref = "netty" }
netty-codec-http = { module = "io.netty:netty-codec-http", version.ref = "netty" } netty-codec-http = { module = "io.netty:netty-codec-http", version.ref = "netty" }
netty-handler = { module = "io.netty:netty-handler", version.ref = "netty" }
netty-transport = { module = "io.netty:netty-transport", version.ref = "netty" } netty-transport = { module = "io.netty:netty-transport", version.ref = "netty" }
openrs2-natives = { module = "org.openrs2:openrs2-natives-all", version = "3.2.0" } openrs2-natives = { module = "org.openrs2:openrs2-natives-all", version = "3.2.0" }
postgres = { module = "org.postgresql:postgresql", version = "42.2.23" } postgres = { module = "org.postgresql:postgresql", version = "42.2.23" }
@ -63,5 +64,5 @@ xz = { module = "org.tukaani:xz", version = "1.9" }
[bundles] [bundles]
asm = ["asm-core", "asm-commons", "asm-tree", "asm-util"] asm = ["asm-core", "asm-commons", "asm-tree", "asm-util"]
bouncyCastle = ["bouncyCastle-pkix", "bouncyCastle-provider"] bouncyCastle = ["bouncyCastle-pkix", "bouncyCastle-provider"]
ktor = ["ktor-jackson", "ktor-server-netty", "ktor-thymeleaf", "ktor-webjars"] ktor = ["ktor-jackson", "ktor-server-cio", "ktor-thymeleaf", "ktor-webjars"]
thymeleaf = ["thymeleaf-core", "thymeleaf-java8time"] thymeleaf = ["thymeleaf-core", "thymeleaf-java8time"]

Loading…
Cancel
Save