[jOOQ/jOOQ#9335] Add a jooq-kotlin-coroutines extensions module
This commit is contained in:
parent
e3d7d96fe0
commit
7ef55aff8c
6
jOOQ-kotlin-coroutines/.gitignore
vendored
Normal file
6
jOOQ-kotlin-coroutines/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/target
|
||||
|
||||
/.cache
|
||||
|
||||
/.idea
|
||||
/*.iml
|
||||
19
jOOQ-kotlin-coroutines/LICENSE.txt
Normal file
19
jOOQ-kotlin-coroutines/LICENSE.txt
Normal file
@ -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
|
||||
10
jOOQ-kotlin-coroutines/NOTICE.txt
Normal file
10
jOOQ-kotlin-coroutines/NOTICE.txt
Normal file
@ -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/).
|
||||
70
jOOQ-kotlin-coroutines/pom.xml
Normal file
70
jOOQ-kotlin-coroutines/pom.xml
Normal file
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-parent</artifactId>
|
||||
<version>3.17.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jooq-kotlin-coroutines</artifactId>
|
||||
<name>jOOQ Kotlin Coroutines</name>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
</plugin>
|
||||
|
||||
<!-- The jar plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>empty-javadoc-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classifier>javadoc</classifier>
|
||||
<classesDirectory>${basedir}/javadoc</classesDirectory>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Automatic-Module-Name>org.jooq.kotlin.coroutines</Automatic-Module-Name>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-kotlin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-coroutines-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-coroutines-reactor</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -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 <T> DSLContext.transactionCoroutineResult(transactional: suspend (Configuration) -> T): T {
|
||||
return transactionPublisher { c ->
|
||||
mono {
|
||||
transactional.invoke(c)
|
||||
}
|
||||
}.awaitFirst()
|
||||
}
|
||||
@ -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
|
||||
@ -0,0 +1,2 @@
|
||||
Thanks for downloading jOOQ.
|
||||
Please visit http://www.jooq.org for more information.
|
||||
13
pom.xml
13
pom.xml
@ -43,6 +43,7 @@
|
||||
|
||||
<!-- Kotlin versions -->
|
||||
<kotlin.version>1.6.10</kotlin.version>
|
||||
<kotlinx.coroutines.version>1.6.2</kotlinx.coroutines.version>
|
||||
|
||||
<!-- DefaultRecordMapper and jOOQ-meta-extensions can read JPA annotations -->
|
||||
<jakarta.persistence-api.version>3.0.0</jakarta.persistence-api.version>
|
||||
@ -240,6 +241,17 @@
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-coroutines-core</artifactId>
|
||||
<version>${kotlinx.coroutines.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-coroutines-reactor</artifactId>
|
||||
<version>${kotlinx.coroutines.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-scala_2.13</artifactId>
|
||||
@ -872,6 +884,7 @@
|
||||
|
||||
|
||||
<module>jOOQ-kotlin</module>
|
||||
<module>jOOQ-kotlin-coroutines</module>
|
||||
<module>jOOQ-scala_2.13</module>
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user