Merge pull request #297 from AppFlowy-IO/connection-lifetime
feat: added pg connection lifetime
This commit is contained in:
commit
5fe94e9c59
|
|
@ -338,6 +338,8 @@ async fn get_connection_pool(setting: &DatabaseSetting) -> Result<PgPool, Error>
|
||||||
PgPoolOptions::new()
|
PgPoolOptions::new()
|
||||||
.max_connections(setting.max_connections)
|
.max_connections(setting.max_connections)
|
||||||
.acquire_timeout(Duration::from_secs(10))
|
.acquire_timeout(Duration::from_secs(10))
|
||||||
|
.max_lifetime(Duration::from_secs(60 * 60))
|
||||||
|
.idle_timeout(Duration::from_secs(60))
|
||||||
.connect_with(setting.with_db())
|
.connect_with(setting.with_db())
|
||||||
.await
|
.await
|
||||||
.map_err(|e| anyhow::anyhow!("Failed to connect to postgres database: {}", e))
|
.map_err(|e| anyhow::anyhow!("Failed to connect to postgres database: {}", e))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue