mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2026-07-21 11:38:59 +02:00
✨ Add variable to not block if redis is unreachable (#214)
* ✨ Add variable to not block if redis is unreachable * 🚨 fix lint * 📝 Update README.md
This commit is contained in:
Vendored
+7
-1
@@ -23,6 +23,8 @@ const (
|
||||
CaptchaDoneValue = "d"
|
||||
// CacheMiss error string when cache is miss.
|
||||
CacheMiss = "cache:miss"
|
||||
// CacheUnreachable error string when cache is unreachable.
|
||||
CacheUnreachable = "cache:unreachable"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
@@ -60,9 +62,13 @@ func (redisCache) get(key string) (string, error) {
|
||||
if err == nil && len(valueString) > 0 {
|
||||
return valueString, nil
|
||||
}
|
||||
if err.Error() == simpleredis.RedisMiss {
|
||||
errRedisMessage := err.Error()
|
||||
if errRedisMessage == simpleredis.RedisMiss {
|
||||
return "", errors.New(CacheMiss)
|
||||
}
|
||||
if errRedisMessage == simpleredis.RedisUnreachable {
|
||||
return "", errors.New(CacheUnreachable)
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user