gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] 04/07: Scheduling tasks.


From: gnunet
Subject: [libeufin] 04/07: Scheduling tasks.
Date: Mon, 03 Apr 2023 01:34:39 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

commit 19dfeb6704d5dee54a83ce3f8c16f563cd162fa7
Author: MS <ms@taler.net>
AuthorDate: Mon Apr 3 01:26:05 2023 +0200

    Scheduling tasks.
    
    Never failing on soft errors.  That avoids outages
    or frequent restarts.
---
 .../main/kotlin/tech/libeufin/nexus/Scheduling.kt  | 39 +++++++++++-----------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt
index 8d6062d1..2d3d869e 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt
@@ -32,6 +32,7 @@ import 
tech.libeufin.nexus.bankaccount.fetchBankAccountTransactions
 import tech.libeufin.nexus.bankaccount.submitAllPaymentInitiations
 import tech.libeufin.nexus.server.FetchSpecJson
 import java.lang.IllegalArgumentException
+import java.net.ConnectException
 import java.time.Duration
 import java.time.Instant
 import java.time.ZonedDateTime
@@ -53,25 +54,19 @@ private suspend fun runTask(client: HttpClient, sched: 
TaskSchedule) {
         when (sched.resourceType) {
             "bank-account" -> {
                 when (sched.type) {
-                    /**
-                     * Downloads and ingests the payment records from the bank.
-                     */
+                    // Downloads and ingests the payment records from the bank.
                     "fetch" -> {
                         @Suppress("BlockingMethodInNonBlockingContext")
                         val fetchSpec = 
jacksonObjectMapper().readValue(sched.params, FetchSpecJson::class.java)
-                        val outcome = fetchBankAccountTransactions(client, 
fetchSpec, sched.resourceId)
-                        if (outcome.errors != null && 
outcome.errors!!.isNotEmpty()) {
-                            /**
-                             * Communication with the bank had at least one 
error.  All of
-                             * them get logged when this 'outcome.errors' list 
was defined,
-                             * so not logged twice here.  Failing to bring the 
problem(s) up.
-                             */
-                            exitProcess(1)
-                        }
+                        fetchBankAccountTransactions(client, fetchSpec, 
sched.resourceId)
+                        /**
+                         * NOTE: the previous operation COULD have had 
problems but that
+                         * is tolerated because the communication with the 
backend CAN be
+                         * unreliable.  As of logging: not doing it here 
twice, since every
+                         * error should already have been logged when it 
originated.
+                         */
                     }
-                    /**
-                     * Submits the payment preparations that are found in the 
database.
-                     */
+                    // Submits the payment preparations that are found in the 
database.
                     "submit" -> {
                         submitAllPaymentInitiations(client, sched.resourceId)
                     }
@@ -82,9 +77,15 @@ private suspend fun runTask(client: HttpClient, sched: 
TaskSchedule) {
             }
             else -> logger.error("task on resource ${sched.resourceType} not 
supported")
         }
-    } catch (e: Exception) {
-        logger.error("Exception during task $sched", e)
-    } catch (so: StackOverflowError) {
+    }
+    catch (e: Exception) {
+        logger.error("Exception during task $sched: ${e.message})")
+        /**
+         *  Not exiting the process since the error can be temporary:
+         *  name resolution problem, Nexus connectivity problem, ...
+         */
+    }
+    catch (so: StackOverflowError) {
         logger.error(so.stackTraceToString())
         exitProcess(1)
     }
@@ -105,7 +106,7 @@ object NexusCron {
     }
 }
 
-// Fails whenever a unmanaged Throwable reaches the root coroutine.
+// Fails whenever an unmanaged Throwable reaches the root coroutine.
 val fallback = CoroutineExceptionHandler { _, err ->
     logger.error(err.stackTraceToString())
     exitProcess(1)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]