diff --git a/jOOQ-kotlin-coroutines/.gitignore b/jOOQ-kotlin-coroutines/.gitignore new file mode 100644 index 0000000000..41b88d42d8 --- /dev/null +++ b/jOOQ-kotlin-coroutines/.gitignore @@ -0,0 +1,6 @@ +/target + +/.cache + +/.idea +/*.iml \ No newline at end of file diff --git a/jOOQ-kotlin-coroutines/LICENSE.txt b/jOOQ-kotlin-coroutines/LICENSE.txt new file mode 100644 index 0000000000..d090694f44 --- /dev/null +++ b/jOOQ-kotlin-coroutines/LICENSE.txt @@ -0,0 +1,19 @@ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Other licenses: +----------------------------------------------------------------------------- +Commercial licenses for this work are available. These replace the above +ASL 2.0 and offer limited warranties, support, maintenance, and commercial +database integrations. + +For more information, please visit: http://www.jooq.org/licenses \ No newline at end of file diff --git a/jOOQ-kotlin-coroutines/NOTICE.txt b/jOOQ-kotlin-coroutines/NOTICE.txt new file mode 100644 index 0000000000..698edf47ee --- /dev/null +++ b/jOOQ-kotlin-coroutines/NOTICE.txt @@ -0,0 +1,10 @@ +Third party NOTICE.txt contents +=============================== + +Contents of https://github.com/apache/commons-lang/blob/master/NOTICE.txt +------------------------------------------------------------------------- +Apache Commons Lang +Copyright 2001-2019 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/jOOQ-kotlin-coroutines/pom.xml b/jOOQ-kotlin-coroutines/pom.xml new file mode 100644 index 0000000000..f82db684d4 --- /dev/null +++ b/jOOQ-kotlin-coroutines/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + + org.jooq + jooq-parent + 3.17.0-SNAPSHOT + + + jooq-kotlin-coroutines + jOOQ Kotlin Coroutines + + + src/main/kotlin + + + + kotlin-maven-plugin + org.jetbrains.kotlin + + + + + org.apache.maven.plugins + maven-jar-plugin + + + empty-javadoc-jar + package + + jar + + + javadoc + ${basedir}/javadoc + + + org.jooq.kotlin.coroutines + + + + + + + + + + + + org.jooq + jooq + + + org.jooq + jooq-kotlin + + + + org.jetbrains.kotlinx + kotlinx-coroutines-core + + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + + + \ No newline at end of file diff --git a/jOOQ-kotlin-coroutines/src/main/kotlin/org/jooq/kotlin/coroutines/CoroutineExtensions.kt b/jOOQ-kotlin-coroutines/src/main/kotlin/org/jooq/kotlin/coroutines/CoroutineExtensions.kt new file mode 100644 index 0000000000..6086231b08 --- /dev/null +++ b/jOOQ-kotlin-coroutines/src/main/kotlin/org/jooq/kotlin/coroutines/CoroutineExtensions.kt @@ -0,0 +1,28 @@ +package org.jooq.kotlin.coroutines + +import kotlinx.coroutines.reactive.awaitFirst +import kotlinx.coroutines.reactive.awaitFirstOrNull +import kotlinx.coroutines.reactor.mono +import org.jooq.* +import org.jooq.impl.DSL.* +import java.util.stream.Collector + +// ---------------------------------------------------------------------------- +// Extensions to bridge between the reactive-streams and the coroutine world +// ---------------------------------------------------------------------------- + +suspend fun DSLContext.transactionCoroutine(transactional: suspend (Configuration) -> Unit) { + transactionPublisher { c -> + mono { + transactional.invoke(c) + } + }.awaitFirst() +} + +suspend fun DSLContext.transactionCoroutineResult(transactional: suspend (Configuration) -> T): T { + return transactionPublisher { c -> + mono { + transactional.invoke(c) + } + }.awaitFirst() +} \ No newline at end of file diff --git a/jOOQ-kotlin-coroutines/src/main/resources/META-INF/LICENSE.txt b/jOOQ-kotlin-coroutines/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..d090694f44 --- /dev/null +++ b/jOOQ-kotlin-coroutines/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,19 @@ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Other licenses: +----------------------------------------------------------------------------- +Commercial licenses for this work are available. These replace the above +ASL 2.0 and offer limited warranties, support, maintenance, and commercial +database integrations. + +For more information, please visit: http://www.jooq.org/licenses \ No newline at end of file diff --git a/jOOQ-kotlin-coroutines/src/main/resources/META-INF/README.txt b/jOOQ-kotlin-coroutines/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..3e6e227e05 --- /dev/null +++ b/jOOQ-kotlin-coroutines/src/main/resources/META-INF/README.txt @@ -0,0 +1,2 @@ +Thanks for downloading jOOQ. +Please visit http://www.jooq.org for more information. \ No newline at end of file diff --git a/pom.xml b/pom.xml index 94040bda4e..0ed3258a04 100644 --- a/pom.xml +++ b/pom.xml @@ -43,6 +43,7 @@ 1.6.10 + 1.6.2 3.0.0 @@ -240,6 +241,17 @@ ${kotlin.version} + + org.jetbrains.kotlinx + kotlinx-coroutines-core + ${kotlinx.coroutines.version} + + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + ${kotlinx.coroutines.version} + + org.jooq jooq-scala_2.13 @@ -872,6 +884,7 @@ jOOQ-kotlin + jOOQ-kotlin-coroutines jOOQ-scala_2.13