gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: splitting baground tasks in more/less


From: gnunet
Subject: [libeufin] branch master updated: splitting baground tasks in more/less frequent
Date: Tue, 09 Jun 2020 14:45:39 +0200

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 a23c19d  splitting baground tasks in more/less frequent
a23c19d is described below

commit a23c19d93abb9a3a97c7b6b30778cecd422e6ae7
Author: MS <ms@taler.net>
AuthorDate: Tue Jun 9 14:45:14 2020 +0200

    splitting baground tasks in more/less frequent
---
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 37 ++++++++++++++++++-----
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 1f5e59b..756a9e3 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -260,27 +260,44 @@ fun ApplicationRequest.hasBody(): Boolean {
     return false
 }
 
-fun schedulePeriodicWork() {
+fun moreFrequentBackgroundTasks() {
     GlobalScope.launch {
         while (true) {
-            logger.debug("Outer background job")
+            logger.debug("More frequent background job")
+            ingestTalerTransactions()
+            submitPreparedPaymentsViaEbics()
             try {
-                downloadTalerFacadesTransactions()
-                ingestTalerTransactions()
-                submitPreparedPaymentsViaEbics()
+                downloadTalerFacadesTransactions("C52")
             } catch (e: Exception) {
                 val sw = StringWriter()
                 val pw = PrintWriter(sw)
                 e.printStackTrace(pw)
-                logger.info("==== Background job exception ====\n${sw}======")
+                logger.info("==== Frequent background task exception 
====\n${sw}======")
             }
             delay(Duration.ofSeconds(1))
         }
     }
 }
 
+fun lessFrequentBackgroundTasks() {
+    GlobalScope.launch {
+        while (true) {
+            logger.debug("Less frequent background job")
+            try {
+                downloadTalerFacadesTransactions("C53")
+            } catch (e: Exception) {
+                val sw = StringWriter()
+                val pw = PrintWriter(sw)
+                e.printStackTrace(pw)
+                logger.info("==== Less frequent background task exception 
====\n${sw}======")
+            }
+            delay(Duration.ofSeconds(10))
+        }
+    }
+}
+
 /** Crawls all the facades, and requests history for each of its creators. */
-suspend fun downloadTalerFacadesTransactions() {
+suspend fun downloadTalerFacadesTransactions(type: String) {
     val httpClient = HttpClient()
     val work = mutableListOf<Pair<String, String>>()
     transaction {
@@ -292,6 +309,7 @@ suspend fun downloadTalerFacadesTransactions() {
     work.forEach {
         fetchTransactionsInternal(
             client = httpClient,
+            type = type,
             userId = it.first,
             accountid = it.second,
             ct = CollectedTransaction(null, null, null)
@@ -313,6 +331,7 @@ fun ApplicationCall.expectUrlParameter(name: String): 
String {
 
 suspend fun fetchTransactionsInternal(
     client: HttpClient,
+    type: String, // C53 or C52
     userId: String,
     accountid: String,
     ct: CollectedTransaction
@@ -430,7 +449,8 @@ fun serverMain(dbName: String) {
             return@intercept
         }
 
-        schedulePeriodicWork()
+        lessFrequentBackgroundTasks()
+        moreFrequentBackgroundTasks()
         routing {
             /**
              * Shows information about the requesting user.
@@ -662,6 +682,7 @@ fun serverMain(dbName: String) {
                 }
                 fetchTransactionsInternal(
                     client,
+                    "C53",
                     user.id.value,
                     accountid,
                     ct

-- 
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]