Commit ba9f6cc1 authored by Aljaž Srebrnič's avatar Aljaž Srebrnič

Add some options to r2d2 pool

parent 6cc75a88
Pipeline #556 passed with stages
in 8 minutes and 3 seconds
...@@ -46,7 +46,14 @@ fn main() { ...@@ -46,7 +46,14 @@ fn main() {
let redis_connstring = var("REDIS_CONNSTRING").unwrap_or_else(|_| String::from("redis://localhost")); let redis_connstring = var("REDIS_CONNSTRING").unwrap_or_else(|_| String::from("redis://localhost"));
let manager = r2d2_redis::RedisConnectionManager::new(&*redis_connstring).unwrap(); let manager = r2d2_redis::RedisConnectionManager::new(&*redis_connstring).unwrap();
let pool = r2d2::Pool::builder() let pool = r2d2::Pool::builder()
// At least 1 connection must be active
.min_idle(Some(2))
// Try to get a connection for max 1 second
.connection_timeout(Duration::from_secs(1)) .connection_timeout(Duration::from_secs(1))
// Don't log errors directly.
// They can get quite verbose, and we're already catching and
// logging the corresponding results anyways.
.error_handler(Box::new(r2d2::NopErrorHandler))
.build(manager) .build(manager)
.unwrap(); .unwrap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment