summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-05-20 01:41:36 +0300
committerPaul Buetow <paul@buetow.org>2023-05-20 01:41:36 +0300
commit16019def84f61d4adc9e25e4bd2d0a6c8bf36c40 (patch)
treeba5af844ccbe6a84947aaee6cb8bab633333c6c4
parent7e33bdc70eb397882fbe989fee1fa00385335917 (diff)
run expiry after expiryTime automatically
-rw-r--r--internal/quorum.go1
-rw-r--r--internal/run.go3
2 files changed, 3 insertions, 1 deletions
diff --git a/internal/quorum.go b/internal/quorum.go
index b506bfb..179efb1 100644
--- a/internal/quorum.go
+++ b/internal/quorum.go
@@ -27,7 +27,6 @@ func (q quorumMap) winner(config config) (string, error) {
}
func (q quorumMap) score(config config) (scores []score) {
- q.cleanExpired()
scoreMap := make(map[string]int)
for _, vote := range q {
diff --git a/internal/run.go b/internal/run.go
index 8f73b19..50a5b6f 100644
--- a/internal/run.go
+++ b/internal/run.go
@@ -3,6 +3,7 @@ package internal
import (
"context"
"log"
+ "time"
)
func Run(ctx context.Context, configFile string) {
@@ -25,6 +26,8 @@ func Run(ctx context.Context, configFile string) {
continue
}
log.Printf("The current leader node is %s", winner)
+ case <-time.After(voteExpiry):
+ quorum.cleanExpired()
case <-ctx.Done():
return
}