[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taldir] branch master updated: make validation cleanup expiration
From: |
gnunet |
Subject: |
[taler-taldir] branch master updated: make validation cleanup expiration peridically |
Date: |
Tue, 12 Jul 2022 15:14:01 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository taldir.
The following commit(s) were added to refs/heads/master by this push:
new d7e7e23 make validation cleanup expiration peridically
d7e7e23 is described below
commit d7e7e2311769a49e675fd9d98fde27141aafec06
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Jul 12 15:13:58 2022 +0200
make validation cleanup expiration peridically
---
cmd/taldir-server/testdata/taldir-test.conf | 2 +-
pkg/rest/taldir.go | 18 ++++++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/cmd/taldir-server/testdata/taldir-test.conf
b/cmd/taldir-server/testdata/taldir-test.conf
index 75a399c..92f96e8 100644
--- a/cmd/taldir-server/testdata/taldir-test.conf
+++ b/cmd/taldir-server/testdata/taldir-test.conf
@@ -17,7 +17,7 @@ validation_timeframe = 10m
solution_attempt_timeframe = 1h
merchant_baseurl_private = http://merchant.taldir/instances/myInstance
merchant_token = superSecretToken
-validation_expiration = 24h
+validation_expiration = 5m
[taldir-test]
challenge_fee = KUDOS:0
diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go
index 41a6528..ba78876 100644
--- a/pkg/rest/taldir.go
+++ b/pkg/rest/taldir.go
@@ -770,6 +770,13 @@ func (t *Taldir) handleRequests() {
log.Fatal(http.ListenAndServe(t.Cfg.Section("taldir").Key("bind_to").MustString("localhost:11000"),
t.Router))
}
+func validationDbMaintenance(t *Taldir) {
+ for true {
+ fmt.Println("Hello !!")
+ time.Sleep(1 * time.Second)
+ }
+}
+
func (t *Taldir) Initialize(cfgfile string) {
_cfg, err := ini.Load(cfgfile)
if err != nil {
@@ -832,10 +839,13 @@ func (t *Taldir) Initialize(cfgfile string) {
if err != nil {
log.Fatal(err)
}
-
- tx := t.Db.Where("created_at < ?",
time.Now().Add(-validationExp)).Delete(&Validation{})
- //tx := t.Db.Where("created_at < ?", time.Now().AddDate(0, 0,
-1)).Delete(&Validation{})
- log.Printf("Cleaned up %d stale validations.\n", tx.RowsAffected)
+ go func() {
+ for true {
+ tx := t.Db.Where("created_at < ?",
time.Now().Add(-validationExp)).Delete(&Validation{})
+ log.Printf("Cleaned up %d stale validations.\n", tx.RowsAffected)
+ time.Sleep(validationExp)
+ }
+ }()
validationLandingTplFile :=
t.Cfg.Section("taldir").Key("validation_landing").MustString("templates/validation_landing.html")
t.ValidationTpl, err = template.ParseFiles(validationLandingTplFile)
if err != nil {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-taldir] branch master updated: make validation cleanup expiration peridically,
gnunet <=