81 bug stream mode stops blocking (#82)

*  fix isHealthy issue at startup

* 🍱 not added in first commit ?

* 🍱 remove unused import

* 🍱 fix lint

* fix: lint
This commit is contained in:
maxlerebourg
2023-01-30 14:03:10 +01:00
committed by GitHub
parent 80726df450
commit 976cbb7d1f
2 changed files with 17 additions and 9 deletions
+7 -1
View File
@@ -16,6 +16,9 @@ const (
cacheNoBannedValue = "f"
)
// CacheMiss error string when cache is miss.
const CacheMiss = "cache:miss"
//nolint:gochecknoglobals
var (
redis simpleredis.SimpleRedis
@@ -30,7 +33,7 @@ func (localCache) getDecision(clientIP string) (bool, error) {
if isCached && isValid && len(bannedString) > 0 {
return bannedString == cacheBannedValue, nil
}
return false, fmt.Errorf("cache:miss")
return false, fmt.Errorf(CacheMiss)
}
func (localCache) setDecision(clientIP string, value string, duration int64) {
@@ -49,6 +52,9 @@ func (redisCache) getDecision(clientIP string) (bool, error) {
if err == nil && len(bannedString) > 0 {
return bannedString == cacheBannedValue, nil
}
if err.Error() == simpleredis.RedisMiss {
return false, fmt.Errorf(CacheMiss)
}
return false, err
}