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-05 19:16:19 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-12-05 19:16:19 +0300
commit0e115c3f3f99e95aa6778c25381c85e4a3f7ad36 (patch)
tree8dfc661f7b36dc4bee20831a4757eba02b30fafb /internal/source/gitlab/cache/cache.go
parent07ac526ac57e71b6cfd6b810709b1255b65dd113 (diff)
Extract all configurable caching values to const.go
Diffstat (limited to 'internal/source/gitlab/cache/cache.go')
-rw-r--r--internal/source/gitlab/cache/cache.go42
1 files changed, 23 insertions, 19 deletions
diff --git a/internal/source/gitlab/cache/cache.go b/internal/source/gitlab/cache/cache.go
index c538419f..85f44e11 100644
--- a/internal/source/gitlab/cache/cache.go
+++ b/internal/source/gitlab/cache/cache.go
@@ -23,25 +23,29 @@ func NewCache(client api.Client) *Cache {
// Resolve is going to return a Lookup based on a domain name. The caching
// algorithm works as follows:
// - We first check if the cache entry exists, and if it is up-to-date. If it
-// is fresh we return the &Lookup entry from cache and it is a cache hit.
-// - If entry is not up-to-date, we schedule an asynchronous retrieval of the
-// latest configuration we are going to obtain through the API, and we
-// immediately return an old value, to avoid blocking clients. In this case
-// it is also a cache hit.
-// - If cache entry has not been populated with a Lookup information yet, we
-// block all the clients and make them wait until we retrieve the Lookup from
-// the GitLab API.
+// is fresh we return the lookup entry from cache and it is a cache hit.
+// - If entry is not up-to-date, what means that it has been created in a cache
+// more than `shortCacheExpiry` duration ago, we schedule an asynchronous
+// retrieval of the latest configuration we are going to obtain through the
+// API, and we immediately return an old value, to avoid blocking clients. In
+// this case it is also a cache hit.
+// - If cache entry has not been populated with a lookup information yet, we
+// block all the clients and make them wait until we retrieve the lookup from
+// the GitLab API. Clients should not wait for longer than
+// `retrievalTimeout`. It is a cache miss.
//
-// We are going to retrieve a Lookup from GitLab API using Retriever type. In
+// We are going to retrieve a lookup from GitLab API using a retriever type. In
// case of failures (when GitLab API client returns an error) we will retry the
-// operation a few times. In case of an erroneous response, we will cache it,
-// and it get recycled as every other cache entry.
+// operation a few times, waiting `maxRetrievalInterval` in between, total
+// amount of requests is defined as `maxRetrievalRetries`. In case of an
+// erroneous response, we will cache it, and it get recycled as every other
+// cache entry.
//
// Examples:
// 1. Everything works
// - a client opens pages
// - we create a new cache entry
-// - cache entry needs warm up
+// - cache entry needs a warm up
// - a client waits until we retrieve a lookup
// - we successfuly retrieve a lookup
// - we cache this response
@@ -49,19 +53,19 @@ func NewCache(client api.Client) *Cache {
// 2. A domain does not exist
// - a client opens pages
// - we create a new cache entry
-// - cache entry needs warm up
+// - cache entry needs a warm up
// - a client waits until we retrieve a lookup
-// - GitLab responded with a lookup that contains information about domain
-// not being found
-// - we cache this response
-// - we pass this lookup upstream to all theclient
+// - GitLab responded with a lookup and 204 HTTP status
+// - we cache this response with domain being `nil`
+// - we pass this lookup upstream to all the clients
// 3. GitLab is not responding
// - a client opens pages
// - we create a new cache entry
-// - cache entry needs warm up
+// - cache entry needs a warm up
// - a client waits until we retrieve a lookup
// - GitLab does not respond or responds with an error
-// - we retry this information a few times
+// - we retry this retrieval every `maxRetrievalInterval`
+// - we retry this retrieval `maxRetrievalRetries` in total
// - we create a lookup that contains information about an error
// - we cache this response
// - we pass this lookup upstream to all the clients