about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2021-08-06 07:52:50 +0300
committerVika <vika@fireburn.ru>2021-08-06 08:10:13 +0300
commit29fe8dce1ef6bac807717a9416282f6170010436 (patch)
tree4a58737bdae9c688f00f35eec5ab53eb4dcafe66 /src
parentb027a1992e6707cec32e5ba85bfab7789321df7d (diff)
downloadkittybox-29fe8dce1ef6bac807717a9416282f6170010436.tar.zst
Shortened a connection timeout and installed a lifetime limit for connection
Diffstat (limited to 'src')
-rw-r--r--src/database/redis/mod.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/database/redis/mod.rs b/src/database/redis/mod.rs
index 00932de..3a0d5fc 100644
--- a/src/database/redis/mod.rs
+++ b/src/database/redis/mod.rs
@@ -10,6 +10,7 @@ use mobc_redis::redis;
 use mobc_redis::redis::AsyncCommands;
 use mobc_redis::RedisConnectionManager;
 use serde_json::json;
+use std::time::Duration;
 
 use crate::database::{ErrorKind, MicropubChannel, Result, Storage, StorageError};
 use crate::indieauth::User;
@@ -292,7 +293,7 @@ impl Storage for RedisStorage {
                                     // Happens because of a broken link (result of an improper deletion?)
                                     None => Ok(None),
                                 },
-                                Err(err) => Err(StorageError::from(err))
+                                Err(err) => Err(StorageError::with_source(ErrorKind::Backend, "Error executing a Redis command", Box::new(err)))
                             }
                         }
                         Err(err) => Err(StorageError::with_source(ErrorKind::Backend, "Error getting a connection from the pool", Box::new(err)))
@@ -360,6 +361,8 @@ impl RedisStorage {
                 redis: Pool::builder()
                     .max_open(20)
                     .max_idle(5)
+                    .get_timeout(Some(Duration::from_secs(3)))
+                    .max_lifetime(Some(Duration::from_secs(120)))
                     .build(RedisConnectionManager::new(client)),
             }),
             Err(e) => Err(e.into()),