Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
v0.2.2 release
  • Loading branch information
ShreckYe committed Aug 9, 2022
2 parents a415d92 + 624a5fa commit cfba401
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/VersionsAndDependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import com.huanshankeji.CommonDependencies
import com.huanshankeji.CommonVersions
import com.huanshankeji.CommonGradleClasspathDependencies

val projectVersion = "0.2.1"
val projectVersion = "0.2.2"

val commonVersions = CommonVersions()
val commonDependencies = CommonDependencies(commonVersions)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.huanshankeji.collections

fun List<*>.areElementsDistinct() =
// There is a more efficient implementation.
distinct().size == size
1 change: 1 addition & 0 deletions vertx/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
//testImplementation("io.vertx", "vertx-web", classifier = "tests") // This does not work well.
testImplementation(moduleWithoutVersion("web-client"))
}
testImplementation(project(":net"))
}

kotlin.sourceSets["test"].languageSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ fun <T> CoroutineScope.coroutineToFuture(
}
return promise.future()
}

suspend fun <T> List<Future<T>>.awaitAll() =
map { it.await() }
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.huanshankeji.vertx.kotlin.coroutines.ext.web

import com.huanshankeji.vertx.ext.web.checkedRun
import io.vertx.ext.web.Route
import io.vertx.ext.web.RoutingContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

// workaround for context receivers
fun coroutineHandler(
coroutineScope: CoroutineScope, route: Route,
requestHandler: suspend (RoutingContext) -> Unit
): Route =
route.handler { coroutineScope.launch { requestHandler(it) } }

// workaround for context receivers
fun checkedCoroutineHandler(
coroutineScope: CoroutineScope, route: Route,
requestHandler: suspend (RoutingContext) -> Unit
): Route =
coroutineHandler(coroutineScope, route) { ctx -> ctx.checkedRun { requestHandler(ctx) } }
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.huanshankeji.vertx.ext.web

import com.huanshankeji.kotlin.use
import com.huanshankeji.net.LOCALHOST
import com.huanshankeji.vertx.VertxBaseTest
import io.vertx.ext.web.Router
import io.vertx.ext.web.RoutingContext
Expand Down Expand Up @@ -37,7 +38,7 @@ abstract class RoutingContextBaseTest : VertxBaseTest() {
httpServer.use({
val port = httpServer.actualPort()
WebClient.create(vertx).use({
assertEquals(500, it.get(port, null, "").send().await().statusCode())
assertEquals(500, it.get(port, LOCALHOST, "").send().await().statusCode())
}, { close() })
}, { close().await() })
}
Expand Down

0 comments on commit cfba401

Please sign in to comment.