Skip to content

Commit f093ef2

Browse files
committed
chore: ktor 3.0.0-Beta2 and refactor wasm support
1 parent 7f2bcf7 commit f093ef2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+515
-338
lines changed

CHANGELOG.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,5 @@
88
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.8.0...v0.8.1)
99

1010

11-
## [v0.8.0](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.8.0) (2023-07-29)
12-
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.8...v0.8.0)
13-
14-
15-
## [v0.7.8](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.8) (2023-07-23)
16-
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.7...v0.7.8)
17-
18-
19-
## [v0.7.7](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.7) (2023-07-21)
20-
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.6...v0.7.7)
21-
22-
23-
## [v0.7.6](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.6) (2023-07-21)
24-
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.5...v0.7.6)
25-
26-
27-
## [v0.7.5](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.5) (2023-07-11)
28-
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.1...v0.7.5)
29-
30-
31-
## [v0.7.1](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.1) (2023-07-06)
32-
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.7.0...v0.7.1)
33-
34-
35-
## [v0.7.0](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.7.0) (2023-07-03)
36-
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.6.0...v0.7.0)
37-
38-
39-
## [v0.6.0](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.6.0) (2023-07-03)
40-
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/v0.5.0...v0.6.0)
41-
42-
**Merged pull requests:**
43-
44-
- chore\(deps\): bump dependabot/fetch\-metadata from 1.5.1 to 1.6.0 [\#13](https://github.com/sureshg/kotlin-mpp-playground/pull/13) ([@dependabot[bot]](https://github.com/apps/dependabot))
45-
4611
## [v0.5.0](https://github.com/sureshg/kotlin-mpp-playground/tree/v0.5.0) (2023-06-21)
4712
[View commits](https://github.com/sureshg/kotlin-mpp-playground/compare/dfffbe4cfab7b2f2a93db885ec8a139c960a4221...v0.5.0)

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ $ ./gradlew :backend:jvm:run
5050
$ sdk u java graalvm-ce-dev
5151
$ ./gradlew :backend:jvm:nativeCompile
5252
$ backend/jvm/build/native/nativeCompile/jvm
53+
$ strings -a backend/jvm/build/native/nativeCompile/jvm | grep "cn="
5354

5455
# To generate the native image configurations
5556
$ ./gradlew :backend:jvm:run -Pagent
@@ -110,6 +111,7 @@ $ ./gradlew :backend:jvm:run
110111

111112
```bash
112113
$ ./gradlew :backend:jvm:test -PktorTest
114+
$ ./gradlew :backend:jvm:test -Pk8sTest
113115
$ ./gradlew :backend:jvm:jvmRun -DmainClass=dev.suresh.lang.SysCallKt --quiet
114116
```
115117

@@ -124,7 +126,8 @@ $ ./gradlew :backend:jvm:run
124126

125127
```bash
126128
# Kotlin JS
127-
$ ./gradlew :web:js:jsBrowserProductionRun -t
129+
$ ./gradlew :web:jsBrowserProductionRun -t
130+
$ ./gradlew :web:wasmJsBrowserProductionRun -t
128131
$ ./gradlew kotlinUpgradePackageLock
129132

130133
# Kobweb

backend/jvm/build.gradle.kts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ tasks {
131131
}
132132
}
133133

134-
// Copy webapps to resources
135134
processResources {
136135
duplicatesStrategy = DuplicatesStrategy.INCLUDE
137136
dependsOn(copyTasks)
@@ -155,6 +154,7 @@ dependencies {
155154
implementation(libs.ktor.server.content.negotiation)
156155
implementation(libs.ktor.server.metrics.micrometer)
157156
implementation(libs.ktor.server.call.logging)
157+
implementation(libs.ktor.server.call.id)
158158
implementation(libs.ktor.server.status.pages)
159159
implementation(libs.ktor.server.default.headers)
160160
implementation(libs.ktor.server.forwarded.header)
@@ -170,6 +170,7 @@ dependencies {
170170
implementation(libs.ktor.server.auth)
171171
implementation(libs.ktor.server.auth.jwt)
172172
implementation(libs.ktor.server.websockets)
173+
implementation(libs.ktor.server.sse)
173174
implementation(libs.ktor.serialization.json)
174175

175176
// Client dependencies
@@ -207,16 +208,16 @@ dependencies {
207208
implementation(libs.logback.classic)
208209

209210
// Testing
210-
testImplementation(libs.ktor.server.tests)
211+
testImplementation(libs.ktor.server.test.host)
211212
testImplementation(libs.testcontainers.junit5)
212213
testImplementation(libs.testcontainers.postgresql)
213214
testImplementation(libs.testcontainers.k3s)
214215
testImplementation(libs.kubernetes.client)
215216
testImplementation(libs.konsist)
216217

217218
// Copy js and wasm apps
218-
jsApp(project(path = projects.web.js.dependencyProject.path, configuration = "jsApp"))
219-
wasmApp(project(path = projects.web.wasm.dependencyProject.path, configuration = "wasmApp"))
219+
jsApp(project(path = projects.web.dependencyProject.path, configuration = "jsApp"))
220+
wasmApp(project(path = projects.web.dependencyProject.path, configuration = "wasmApp"))
220221

221222
// Specify the classifier using variantOf
222223
// implementation(variantOf(libs.lwjgl.opengl) { classifier("natives-linux") })

backend/jvm/src/main/kotlin/dev/suresh/plugins/Http.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import io.ktor.http.*
55
import io.ktor.server.application.*
66
import io.ktor.server.plugins.*
77
import io.ktor.server.plugins.autohead.*
8-
import io.ktor.server.plugins.callloging.*
8+
import io.ktor.server.plugins.calllogging.*
99
import io.ktor.server.plugins.compression.*
1010
import io.ktor.server.plugins.cors.routing.*
1111
import io.ktor.server.plugins.defaultheaders.*

backend/jvm/src/main/kotlin/dev/suresh/routes/Admin.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package dev.suresh.routes
22

33
import BuildConfig
4-
import io.ktor.server.application.*
54
import io.ktor.server.plugins.swagger.*
65
import io.ktor.server.response.*
76
import io.ktor.server.routing.*
87

9-
fun Route.adminRoutes() {
8+
fun Routing.adminRoutes() {
109
swaggerUI(path = "swagger", swaggerFile = "openapi/documentation.yaml") {
1110
version = BuildConfig.swaggerUi
1211
customStyle("https://unpkg.com/swagger-ui-themes@3.0.1/themes/3.x/theme-flattop.css")

backend/jvm/src/main/kotlin/dev/suresh/routes/Mgmt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ val mutex = Mutex()
2828

2929
val docRoot = Path(System.getProperty("java.io.tmpdir"))
3030

31-
fun Route.mgmtRoutes() {
31+
fun Routing.mgmtRoutes() {
3232

3333
staticFiles(remotePath = "/tmp", dir = docRoot.toFile())
3434

backend/jvm/src/main/kotlin/dev/suresh/routes/Service.kt

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,19 @@ import java.io.Writer
1414

1515
private val logger = KotlinLogging.logger {}
1616

17-
fun Route.services() {
18-
get("/ffm") {
19-
call.respondLogStream {
20-
FFM.memoryLayout()
21-
}
22-
}
17+
fun Routing.services() {
18+
get("/ffm") { call.respondLogStream { FFM.memoryLayout() } }
2319

24-
get("/vthreads") {
25-
call.respondLogStream {
26-
VThread.virtualThreads()
27-
}
28-
}
20+
get("/vthreads") { call.respondLogStream { VThread.virtualThreads() } }
2921

30-
get("/jfr") {
31-
call.respondLogStream {
32-
JFR.recordingStream()
33-
}
34-
}
22+
get("/jfr") { call.respondLogStream { JFR.recordingStream() } }
3523
}
3624

3725
suspend fun ApplicationCall.respondLogStream(
3826
contentType: ContentType = ContentType.Text.EventStream,
39-
block: suspend context(KLogger) Writer.() -> Unit
27+
block:
28+
suspend context(KLogger)
29+
Writer.() -> Unit
4030
) {
41-
respondTextWriter(contentType = contentType) {
42-
block(RespLogger(this, logger), this)
43-
}
31+
respondTextWriter(contentType = contentType) { block(RespLogger(this, logger), this) }
4432
}

backend/jvm/src/main/kotlin/dev/suresh/routes/Webapp.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import io.ktor.server.request.*
55
import io.ktor.server.response.*
66
import io.ktor.server.routing.*
77

8-
fun Route.webApp() {
8+
fun Routing.webApp() {
99
webApp("/app", "app")
1010
}
1111

12-
fun Route.webApp(remotePath: String, basePackage: String) {
12+
fun Routing.webApp(remotePath: String, basePackage: String) {
1313
staticResources(remotePath, basePackage) {
1414
exclude { it.path.endsWith(".log") }
1515
default("index.html")

backend/jvm/src/main/resources/META-INF/native-image/reachability-metadata.json

Lines changed: 28 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,13 @@
166166
"type":"io.ktor.server.application.Application"
167167
},
168168
{
169-
"type":"io.ktor.server.application.PluginBuilder$onDefaultPhaseWithMessage$1",
170-
"methods":[{"name":"invoke","parameterTypes":["io.ktor.util.pipeline.Pipeline"] }]
169+
"type":"io.ktor.server.application.PluginBuilder",
170+
"methods":[{"name":"onDefaultPhaseWithMessage","parameterTypes":["java.util.List","io.ktor.util.pipeline.PipelinePhase","java.lang.String","kotlin.jvm.functions.Function2","kotlin.jvm.functions.Function4"] }]
171171
},
172172
{
173173
"type":"io.ktor.server.application.hooks.CallFailed",
174174
"methods":[{"name":"install","parameterTypes":["io.ktor.server.application.ApplicationCallPipeline","kotlin.jvm.functions.Function3"] }]
175175
},
176-
{
177-
"type":"io.ktor.server.application.hooks.CallFailed$install$1",
178-
"fields":[{"name":"label"}]
179-
},
180-
{
181-
"type":"io.ktor.server.application.hooks.CallFailed$install$1$1",
182-
"fields":[{"name":"label"}]
183-
},
184176
{
185177
"type":"io.ktor.server.application.hooks.CallSetup",
186178
"methods":[{"name":"install","parameterTypes":["io.ktor.server.application.ApplicationCallPipeline","kotlin.jvm.functions.Function2"] }]
@@ -196,29 +188,13 @@
196188
"type":"io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1",
197189
"fields":[{"name":"label"}]
198190
},
199-
{
200-
"type":"io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1",
201-
"fields":[{"name":"label"}]
202-
},
203-
{
204-
"type":"io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1",
205-
"fields":[{"name":"label"}]
206-
},
207191
{
208192
"type":"io.ktor.server.netty.NettyApplicationCall",
209193
"fields":[{"name":"messageReleased"}]
210194
},
211195
{
212196
"type":"io.ktor.server.netty.NettyApplicationCallHandler"
213197
},
214-
{
215-
"type":"io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1",
216-
"fields":[{"name":"label"}]
217-
},
218-
{
219-
"type":"io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1$invokeSuspend$$inlined$execute$1",
220-
"fields":[{"name":"label"}]
221-
},
222198
{
223199
"type":"io.ktor.server.netty.NettyChannelInitializer"
224200
},
@@ -238,56 +214,35 @@
238214
"type":"io.ktor.server.netty.http1.NettyHttp1Handler"
239215
},
240216
{
241-
"type":"io.ktor.server.plugins.callloging.CallLoggingKt$logCallsWithMDC$1",
217+
"type":"io.ktor.server.plugins.calllogging.CallLoggingKt$logCallsWithMDC$1$invokeSuspend$$inlined$withMDC$1",
242218
"fields":[{"name":"label"}]
243219
},
244220
{
245-
"type":"io.ktor.server.plugins.callloging.CallLoggingKt$logCallsWithMDC$1$invokeSuspend$$inlined$withMDC$1",
246-
"fields":[{"name":"label"}]
247-
},
248-
{
249-
"type":"io.ktor.server.plugins.callloging.MDCHookKt$MDCHook$1",
221+
"type":"io.ktor.server.plugins.calllogging.MDCHookKt$MDCHook$1",
250222
"methods":[{"name":"install","parameterTypes":["io.ktor.server.application.ApplicationCallPipeline","kotlin.jvm.functions.Function3"] }]
251223
},
252-
{
253-
"type":"io.ktor.server.plugins.callloging.MDCHookKt$MDCHook$1$install$1",
254-
"fields":[{"name":"label"}]
255-
},
256224
{
257225
"type":"io.ktor.server.plugins.statuspages.BeforeFallback",
258226
"methods":[{"name":"install","parameterTypes":["io.ktor.server.application.ApplicationCallPipeline","kotlin.jvm.functions.Function2"] }]
259227
},
260228
{
261-
"type":"io.ktor.server.routing.Routing$Plugin",
229+
"type":"io.ktor.server.routing.RoutingRoot$Plugin",
262230
"methods":[{"name":"install","parameterTypes":["io.ktor.server.application.Application","kotlin.jvm.functions.Function1"] }]
263231
},
264232
{
265233
"type":"io.ktor.util.collections.CopyOnWriteHashMap",
266234
"fields":[{"name":"current"}]
267235
},
268236
{
269-
"type":"io.ktor.utils.io.ByteBufferChannel",
270-
"fields":[{"name":"_closed"},{"name":"_readOp"},{"name":"_state"},{"name":"_writeOp"}]
271-
},
272-
{
273-
"type":"io.ktor.utils.io.core.internal.ChunkBuffer",
274-
"fields":[{"name":"nextRef"},{"name":"refCount"}]
275-
},
276-
{
277-
"type":"io.ktor.utils.io.internal.CancellableReusableContinuation",
278-
"fields":[{"name":"jobCancellationHandler"},{"name":"state"}]
279-
},
280-
{
281-
"type":"io.ktor.utils.io.internal.RingBufferCapacity",
282-
"fields":[{"name":"_availableForRead$internal"},{"name":"_availableForWrite$internal"},{"name":"_pendingToFlush"}]
237+
"type":"io.ktor.util.internal.LockFreeLinkedListNode",
238+
"fields":[{"name":"_next"},{"name":"_prev"},{"name":"_removedRef"}]
283239
},
284240
{
285-
"type":"io.ktor.utils.io.jvm.javaio.BlockingAdapter",
286-
"fields":[{"name":"state"}]
241+
"type":"io.ktor.utils.io.ByteChannel",
242+
"fields":[{"name":"_closedCause"},{"name":"suspensionSlot"}]
287243
},
288244
{
289-
"type":"io.ktor.utils.io.jvm.javaio.PollersKt",
290-
"methods":[{"name":"isParkingAllowed","parameterTypes":[] },{"name":"prohibitParking","parameterTypes":[] }]
245+
"type":"io.ktor.utils.io.jvm.javaio.PollersKt"
291246
},
292247
{
293248
"type":"io.ktor.utils.io.pool.DefaultPool",
@@ -650,10 +605,6 @@
650605
"type":"java.util.concurrent.atomic.Striped64",
651606
"fields":[{"name":"base"},{"name":"cellsBusy"}]
652607
},
653-
{
654-
"type":"java.util.concurrent.atomic.Striped64$Cell",
655-
"fields":[{"name":"value"}]
656-
},
657608
{
658609
"type":"java.util.logging.LogManager",
659610
"methods":[{"name":"getLoggingMXBean","parameterTypes":[] }]
@@ -777,10 +728,6 @@
777728
"type":"kotlinx.coroutines.EventLoopImplBase",
778729
"fields":[{"name":"_delayed$volatile"},{"name":"_isCompleted$volatile"},{"name":"_queue$volatile"}]
779730
},
780-
{
781-
"type":"kotlinx.coroutines.InvokeOnCancelling",
782-
"fields":[{"name":"_invoked$volatile"}]
783-
},
784731
{
785732
"type":"kotlinx.coroutines.JobSupport",
786733
"fields":[{"name":"_parentHandle$volatile"},{"name":"_state$volatile"}]
@@ -794,8 +741,19 @@
794741
"fields":[{"name":"_closeCause$volatile"},{"name":"bufferEnd$volatile"},{"name":"bufferEndSegment$volatile"},{"name":"closeHandler$volatile"},{"name":"completedExpandBuffersAndPauseFlag$volatile"},{"name":"receiveSegment$volatile"},{"name":"receivers$volatile"},{"name":"sendSegment$volatile"},{"name":"sendersAndCloseStatus$volatile"}]
795742
},
796743
{
797-
"type":"kotlinx.coroutines.internal.AtomicOp",
798-
"fields":[{"name":"_consensus$volatile"}]
744+
"type":"kotlinx.coroutines.debug.internal.ByteBuddyDynamicAttach"
745+
},
746+
{
747+
"type":"kotlinx.coroutines.debug.internal.ConcurrentWeakMap",
748+
"fields":[{"name":"_size$volatile"},{"name":"core$volatile"}]
749+
},
750+
{
751+
"type":"kotlinx.coroutines.debug.internal.ConcurrentWeakMap$Core",
752+
"fields":[{"name":"load$volatile"}]
753+
},
754+
{
755+
"type":"kotlinx.coroutines.debug.internal.DebugProbesImpl$DebugProbesImpl$VolatileWrapper$atomicfu$private",
756+
"fields":[{"name":"installations$volatile"},{"name":"sequenceNumber$volatile"}]
799757
},
800758
{
801759
"type":"kotlinx.coroutines.internal.ConcurrentLinkedListNode",
@@ -1067,10 +1025,10 @@
10671025
"glob":"app\/js\/index.html"
10681026
},{
10691027
"module":"",
1070-
"glob":"app\/js\/js-app.js"
1028+
"glob":"app\/js\/logo\/kotlin-logo.svg"
10711029
},{
10721030
"module":"",
1073-
"glob":"app\/js\/logo\/kotlin-logo.svg"
1031+
"glob":"app\/js\/web.js"
10741032
},{
10751033
"module":"",
10761034
"glob":"app\/wasm\/css\/app.css"
@@ -1079,13 +1037,13 @@
10791037
"glob":"app\/wasm\/index.html"
10801038
},{
10811039
"module":"",
1082-
"glob":"app\/wasm\/logo\/kotlin-logo.svg"
1040+
"glob":"app\/wasm\/kotlin-mpp-playground-web-wasm-js.wasm"
10831041
},{
10841042
"module":"",
1085-
"glob":"app\/wasm\/wasm-app.js"
1043+
"glob":"app\/wasm\/logo\/kotlin-logo.svg"
10861044
},{
10871045
"module":"",
1088-
"glob":"app\/wasm\/wasm-app.wasm"
1046+
"glob":"app\/wasm\/web.js"
10891047
},{
10901048
"module":"",
10911049
"glob":"application.conf"

backend/jvm/src/test/kotlin/dev/suresh/AppTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import io.ktor.http.*
1313
import io.ktor.server.application.*
1414
import io.ktor.server.config.*
1515
import io.ktor.server.plugins.callid.*
16-
import io.ktor.server.plugins.callloging.*
16+
import io.ktor.server.plugins.calllogging.*
1717
import io.ktor.server.plugins.statuspages.*
1818
import io.ktor.server.request.*
1919
import io.ktor.server.response.*

0 commit comments

Comments
 (0)