Skip to content

Commit bb28a9f

Browse files
authored
Update Pellet to 0.0.16 (#8817)
1 parent eb39f06 commit bb28a9f

File tree

6 files changed

+39
-36
lines changed

6 files changed

+39
-36
lines changed

frameworks/Kotlin/pellet/pellet.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM gradle:jdk18 as gradle
1+
FROM gradle:jdk21 as gradle
22
WORKDIR /sample
33
COPY sample/build.gradle.kts build.gradle.kts
44
COPY sample/src src
55
RUN gradle clean shadowJar --no-daemon
66

7-
FROM openjdk:18-jdk-buster
7+
FROM openjdk:21-jdk-buster
88
WORKDIR /sample
99
COPY --from=gradle /sample/build/libs/sample-1.0.0-all.jar app.jar
1010

frameworks/Kotlin/pellet/sample/build.gradle.kts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
22
application
33
id("com.github.johnrengelman.shadow") version "7.1.0"
4-
kotlin("jvm") version "1.7.10"
5-
kotlin("plugin.serialization") version "1.7.10"
4+
kotlin("jvm") version "1.9.23"
5+
kotlin("plugin.serialization") version "1.9.23"
66
id("nu.studer.rocker") version "3.0.4"
77
}
88

@@ -25,31 +25,27 @@ rocker {
2525
}
2626

2727
dependencies {
28-
implementation(platform("dev.pellet:pellet-bom:0.0.15"))
28+
implementation(platform("dev.pellet:pellet-bom:0.0.16"))
2929
implementation("dev.pellet:pellet-server")
3030
implementation("dev.pellet:pellet-logging")
3131
implementation("org.slf4j:slf4j-api:1.7.36")
32-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0-RC")
32+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
3333
implementation(platform(kotlin("bom")))
3434
implementation(kotlin("stdlib-jdk8"))
35-
implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4"))
36-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
37-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8")
38-
implementation("io.vertx:vertx-pg-client:4.3.2")
35+
implementation("io.vertx:vertx-pg-client:4.5.5")
36+
implementation("io.vertx:vertx-lang-kotlin:4.5.5")
3937
implementation("com.ongres.scram:client:2.1")
40-
implementation("io.vertx:vertx-lang-kotlin:4.3.2")
41-
implementation("io.vertx:vertx-lang-kotlin-coroutines:4.3.2")
4238
}
4339

4440
java {
4541
toolchain {
46-
sourceCompatibility = JavaVersion.VERSION_18
47-
targetCompatibility = JavaVersion.VERSION_18
42+
sourceCompatibility = JavaVersion.VERSION_21
43+
targetCompatibility = JavaVersion.VERSION_21
4844
}
4945
}
5046

5147
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
52-
kotlinOptions.jvmTarget = "18"
48+
kotlinOptions.jvmTarget = "21"
5349
}
5450

5551
application {

frameworks/Kotlin/pellet/sample/src/main/kotlin/benchmark/Benchmark.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import dev.pellet.server.PelletConnector
1010
import dev.pellet.server.codec.mime.MediaType
1111
import dev.pellet.server.responder.http.PelletHTTPRouteContext
1212
import dev.pellet.server.routing.http.HTTPRouteResponse
13-
import kotlinx.coroutines.runBlocking
1413
import kotlinx.serialization.json.Json
1514
import java.time.Instant
1615
import java.time.ZoneId
@@ -25,7 +24,7 @@ val jsonEncoder = Json {
2524
prettyPrint = false
2625
}
2726

28-
fun main() = runBlocking {
27+
fun main() {
2928
val sharedRouter = httpRouter {
3029
get("/plaintext", ::handlePlain)
3130
get("/json", ::handleJson)
@@ -44,14 +43,14 @@ fun main() = runBlocking {
4443
router = sharedRouter
4544
}
4645
}
47-
pellet.start().join()
46+
pellet.start()
4847
}
4948

5049
val dateFormatter = DateTimeFormatter
5150
.ofPattern("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH)
5251
.withZone(ZoneId.of("GMT"))
5352

54-
private suspend fun handlePlain(
53+
private fun handlePlain(
5554
context: PelletHTTPRouteContext
5655
): HTTPRouteResponse {
5756
return HTTPRouteResponse.Builder()
@@ -67,7 +66,7 @@ data class ResponseBody(
6766
val message: String
6867
)
6968

70-
private suspend fun handleJson(
69+
private fun handleJson(
7170
context: PelletHTTPRouteContext
7271
): HTTPRouteResponse {
7372
val responseBody = ResponseBody(message = "Hello, World!")
@@ -81,7 +80,7 @@ private suspend fun handleJson(
8180

8281
private val repository = TFBRepository()
8382

84-
private suspend fun handleDb(
83+
private fun handleDb(
8584
context: PelletHTTPRouteContext
8685
): HTTPRouteResponse {
8786
val result = repository.fetchWorld()
@@ -93,7 +92,7 @@ private suspend fun handleDb(
9392
.build()
9493
}
9594

96-
private suspend fun handleQuery(
95+
private fun handleQuery(
9796
context: PelletHTTPRouteContext
9897
): HTTPRouteResponse {
9998
val rawQueries = context.firstQueryParameter("queries").getOrNull()
@@ -110,7 +109,7 @@ private suspend fun handleQuery(
110109
.build()
111110
}
112111

113-
private suspend fun handleUpdates(
112+
private fun handleUpdates(
114113
context: PelletHTTPRouteContext
115114
): HTTPRouteResponse {
116115
val rawQueries = context.firstQueryParameter("queries").getOrNull()
@@ -133,7 +132,7 @@ private suspend fun handleUpdates(
133132
.build()
134133
}
135134

136-
private suspend fun handleFortunes(
135+
private fun handleFortunes(
137136
context: PelletHTTPRouteContext
138137
): HTTPRouteResponse {
139138
val newFortune = Fortune(0, "Additional fortune added at request time.")

frameworks/Kotlin/pellet/sample/src/main/kotlin/benchmark/data/FortuneDAO.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package benchmark.data
22

33
interface FortuneDAO {
44

5-
suspend fun fetchFortunes(): List<Fortune>
5+
fun fetchFortunes(): List<Fortune>
66
}

frameworks/Kotlin/pellet/sample/src/main/kotlin/benchmark/data/TFBRepository.kt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package benchmark.data
22

3-
import io.vertx.kotlin.coroutines.await
3+
import io.vertx.pgclient.PgBuilder
44
import io.vertx.pgclient.PgConnectOptions
5-
import io.vertx.pgclient.PgPool
65
import io.vertx.sqlclient.PoolOptions
76
import io.vertx.sqlclient.Tuple
87
import java.util.concurrent.ThreadLocalRandom
@@ -20,35 +19,44 @@ class TFBRepository: WorldDAO, FortuneDAO {
2019
}
2120

2221
private val poolOptions = PoolOptions()
23-
private val client = PgPool.client(connectOptions, poolOptions)
22+
private val client = PgBuilder.client()
23+
.with(poolOptions)
24+
.connectingTo(connectOptions)
25+
.build()
2426

25-
override suspend fun fetchWorld(): WorldDTO {
27+
override fun fetchWorld(): WorldDTO {
2628
val worldId = ThreadLocalRandom.current().nextInt(1, 10001)
2729
val result = client
2830
.preparedQuery("select id, randomNumber from world where id = $1")
2931
.execute(Tuple.of(worldId))
30-
.await()
32+
.toCompletionStage()
33+
.toCompletableFuture()
34+
.get()
3135
val row = result.first()
3236
return WorldDTO(
3337
row.getInteger(0),
3438
row.getInteger(1)
3539
)
3640
}
3741

38-
override suspend fun updateWorlds(worlds: List<WorldDTO>) {
42+
override fun updateWorlds(worlds: List<WorldDTO>) {
3943
val batch = worlds.map {
4044
Tuple.of(it.id, it.randomNumber)
4145
}
4246
client
4347
.preparedQuery("update world set randomNumber = $1 where id = $2")
4448
.executeBatch(batch)
45-
.await()
49+
.toCompletionStage()
50+
.toCompletableFuture()
51+
.get()
4652
}
4753

48-
override suspend fun fetchFortunes(): List<Fortune> {
54+
override fun fetchFortunes(): List<Fortune> {
4955
val results = client.preparedQuery("select id, message from fortune")
5056
.execute()
51-
.await()
57+
.toCompletionStage()
58+
.toCompletableFuture()
59+
.get()
5260
return results.map {
5361
Fortune(
5462
it.getInteger(0),

frameworks/Kotlin/pellet/sample/src/main/kotlin/benchmark/data/WorldDAO.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ package benchmark.data
22

33
interface WorldDAO {
44

5-
suspend fun fetchWorld(): WorldDTO
6-
suspend fun updateWorlds(worlds: List<WorldDTO>)
5+
fun fetchWorld(): WorldDTO
6+
fun updateWorlds(worlds: List<WorldDTO>)
77
}

0 commit comments

Comments
 (0)