Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-12-02 15:04:13 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-12-02 15:04:13 +0300
commit521ec3721f67a7b59dac651163120e2aa93dd9fa (patch)
treecaaec6dbbaf083661c78b74629f66fccbb67465d
parent1a648a5093175bee5907bfc5f23e466a5349d1b5 (diff)
Make gitlab cache code a little more readable
-rw-r--r--internal/source/gitlab/cache/entry.go2
-rw-r--r--internal/source/gitlab/cache/retriever.go3
2 files changed, 3 insertions, 2 deletions
diff --git a/internal/source/gitlab/cache/entry.go b/internal/source/gitlab/cache/entry.go
index 15356fee..bbd88e9c 100644
--- a/internal/source/gitlab/cache/entry.go
+++ b/internal/source/gitlab/cache/entry.go
@@ -109,7 +109,7 @@ func (e *Entry) setResponse(lookup api.Lookup) {
}
func (e *Entry) isExpired() bool {
- return e.created.Add(shortCacheExpiry).Before(time.Now())
+ return time.Since(e.created) > shortCacheExpiry
}
func (e *Entry) isResolved() bool {
diff --git a/internal/source/gitlab/cache/retriever.go b/internal/source/gitlab/cache/retriever.go
index 4666fcee..e0d04255 100644
--- a/internal/source/gitlab/cache/retriever.go
+++ b/internal/source/gitlab/cache/retriever.go
@@ -10,6 +10,7 @@ import (
)
var maxRetrievalInterval = time.Second
+var maxRetrievalRetries = 3
// Retriever is an utility type that performs an HTTP request with backoff in
// case of errors
@@ -43,7 +44,7 @@ func (r *Retriever) resolveWithBackoff(ctx context.Context, domain string) <-cha
go func() {
var lookup api.Lookup
- for i := 1; i <= 3; i++ {
+ for i := 1; i <= maxRetrievalRetries; i++ {
lookup = r.client.GetLookup(ctx, domain)
if lookup.Error != nil {