[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Database operations.
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Database operations. |
Date: |
Fri, 11 Dec 2020 11:30:30 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new acfac24 Database operations.
acfac24 is described below
commit acfac24086c6963814e500e4a429c8ed5b729c84
Author: MS <ms@taler.net>
AuthorDate: Fri Dec 11 11:29:26 2020 +0100
Database operations.
Handle bad connection string, and show defaults
for the command: reset-table --help.
---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 2 +-
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 14 +++++++++--
.../tech/libeufin/nexus/server/NexusServer.kt | 7 +++++-
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 28 +++++++++++++++++++---
4 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 81d69c0..2ca386e 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -384,7 +384,7 @@ class NexusScheduledTaskEntity(id: EntityID<Int>) :
IntEntity(id) {
}
fun dbDropTables(dbConnectionString: String) {
- Database.connect("$dbConnectionString")
+ Database.connect(dbConnectionString)
transaction {
SchemaUtils.drop(
NexusUsersTable,
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 749e143..bc4a7c3 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -73,10 +73,20 @@ class ParseCamt : CliktCommand("Parse a camt file") {
}
class ResetTables : CliktCommand("Drop all the tables from the database") {
+ init {
+ context {
+ helpFormatter = CliktHelpFormatter(showDefaultValues = true)
+ }
+ }
private val dbConnString by option().default(DEFAULT_DB_CONNECTION)
override fun run() {
- dbDropTables(dbConnString)
- dbCreateTables(dbConnString)
+ try {
+ dbDropTables(dbConnString)
+ dbCreateTables(dbConnString)
+ } catch (e: Exception) {
+ println("Database ($dbConnString) action was unsuccessful")
+ return
+ }
}
}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index 5719472..8daab12 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -209,7 +209,12 @@ fun requireBankConnection(call: ApplicationCall,
parameterKey: String): NexusBan
}
fun serverMain(dbName: String, host: String) {
- dbCreateTables(dbName)
+ try {
+ dbCreateTables(dbName)
+ } catch (e: Exception) {
+ tech.libeufin.util.logger.error("Could not create tables at database:
$dbName")
+ return
+ }
val client = HttpClient {
expectSuccess = false // this way, it does not throw exceptions on !=
200 responses.
}
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index cdc869d..cad95dd 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -56,7 +56,9 @@ import io.ktor.http.toHttpDateString
import org.jetbrains.exposed.sql.statements.api.ExposedBlob
import java.time.Instant
import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.core.context
import com.github.ajalt.clikt.core.subcommands
+import com.github.ajalt.clikt.output.CliktHelpFormatter
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.option
import io.ktor.request.*
@@ -91,14 +93,29 @@ class SandboxCommand : CliktCommand() {
}
class ResetTables : CliktCommand("Drop all the tables from the database") {
+ init {
+ context {
+ helpFormatter = CliktHelpFormatter(showDefaultValues = true)
+ }
+ }
private val dbConnString by option().default(DEFAULT_DB_CONNECTION)
override fun run() {
- dbDropTables(dbConnString)
- dbCreateTables(dbConnString)
+ try {
+ dbDropTables(dbConnString)
+ dbCreateTables(dbConnString)
+ } catch (e: Exception) {
+ println("Database ($dbConnString) action was unsuccessful")
+ return
+ }
}
}
class Serve : CliktCommand("Run sandbox HTTP server") {
+ init {
+ context {
+ helpFormatter = CliktHelpFormatter(showDefaultValues = true)
+ }
+ }
private val dbConnString by option().default(DEFAULT_DB_CONNECTION)
private val logLevel by option()
override fun run() {
@@ -159,7 +176,12 @@ fun main(args: Array<String>) {
}
fun serverMain(dbName: String) {
- dbCreateTables(dbName)
+ try {
+ dbCreateTables(dbName)
+ } catch (e: Exception) {
+ logger.error("Could not create tables at database: $dbName")
+ return
+ }
val server = embeddedServer(Netty, port = 5000) {
install(CallLogging) {
this.level = Level.DEBUG
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Database operations.,
gnunet <=