Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a13ca2d954 | |||
| 36ed678c5a |
@@ -4,11 +4,11 @@ plugins {
|
|||||||
jacoco
|
jacoco
|
||||||
|
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("org.jetbrains.kotlin.jvm") version "1.3.50"
|
kotlin("jvm") version "1.4.30"
|
||||||
|
|
||||||
id("org.jlleitschuh.gradle.ktlint") version "8.2.0"
|
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
|
||||||
id("org.owasp.dependencycheck") version "5.1.0"
|
id("org.owasp.dependencycheck") version "6.1.1"
|
||||||
id("fr.coppernic.versioning") version "3.1.2"
|
id("fr.coppernic.versioning") version "3.2.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.github.flecomte"
|
group = "com.github.flecomte"
|
||||||
@@ -29,17 +29,17 @@ tasks.withType<KotlinCompile> {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.3.31")
|
implementation("org.jetbrains.kotlin:kotlin-reflect:1.4.31")
|
||||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.9")
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1")
|
||||||
implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.9")
|
implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.1")
|
||||||
implementation("com.github.jasync-sql:jasync-postgresql:1.0.7")
|
implementation("com.github.jasync-sql:jasync-postgresql:1.1.7")
|
||||||
implementation("org.slf4j:slf4j-api:1.7.26")
|
implementation("org.slf4j:slf4j-api:1.7.30")
|
||||||
|
|
||||||
testImplementation("ch.qos.logback:logback-classic:1.2.3")
|
testImplementation("ch.qos.logback:logback-classic:1.2.3")
|
||||||
testImplementation("ch.qos.logback:logback-core:1.2.3")
|
testImplementation("ch.qos.logback:logback-core:1.2.3")
|
||||||
testImplementation("io.mockk:mockk:1.9")
|
testImplementation("io.mockk:mockk:1.10.6")
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2")
|
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
|
||||||
testImplementation("org.amshove.kluent:kluent:1.47")
|
testImplementation("org.amshove.kluent:kluent:1.65")
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourcesJar by tasks.creating(Jar::class) {
|
val sourcesJar by tasks.creating(Jar::class) {
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,4 +1,4 @@
|
|||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -25,17 +25,26 @@ class Connection(
|
|||||||
private val host: String = "localhost",
|
private val host: String = "localhost",
|
||||||
private val port: Int = 5432
|
private val port: Int = 5432
|
||||||
) : Executable {
|
) : Executable {
|
||||||
private lateinit var connection: ConnectionPool<PostgreSQLConnection>
|
private var connection: ConnectionPool<PostgreSQLConnection>? = null
|
||||||
private val serializer = Serializer()
|
private val serializer = Serializer()
|
||||||
private val logger: Logger? by LoggerDelegate()
|
private val logger: Logger? by LoggerDelegate()
|
||||||
|
|
||||||
internal fun connect(): ConnectionPool<PostgreSQLConnection> {
|
internal fun connect(): ConnectionPool<PostgreSQLConnection> {
|
||||||
if (!::connection.isInitialized || !connection.isConnected()) {
|
return connection.let { connectionPool ->
|
||||||
connection = PostgreSQLConnectionBuilder.createConnectionPool(
|
if (connectionPool == null || !connectionPool.isConnected()) {
|
||||||
"jdbc:postgresql://$host:$port/$database?user=$username&password=$password"
|
PostgreSQLConnectionBuilder.createConnectionPool(
|
||||||
)
|
"jdbc:postgresql://$host:$port/$database?user=$username&password=$password"
|
||||||
|
).also {
|
||||||
|
connection = it
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
connectionPool
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return connection
|
}
|
||||||
|
|
||||||
|
fun disconnect() {
|
||||||
|
connection?.run { disconnect() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <A> inTransaction(f: (Connection) -> CompletableFuture<A>) = connect().inTransaction(f)
|
fun <A> inTransaction(f: (Connection) -> CompletableFuture<A>) = connect().inTransaction(f)
|
||||||
|
|||||||
Reference in New Issue
Block a user