mirror of
https://github.com/TaKO8Ki/gobang.git
synced 2021-09-19 22:32:56 +03:00
use pool options (#86)
This commit is contained in:
@@ -3,17 +3,21 @@ use async_trait::async_trait;
|
||||
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
|
||||
use database_tree::{Child, Database, Table};
|
||||
use futures::TryStreamExt;
|
||||
use sqlx::mysql::{MySqlColumn, MySqlPool as MPool, MySqlRow};
|
||||
use sqlx::mysql::{MySqlColumn, MySqlPoolOptions, MySqlRow};
|
||||
use sqlx::{Column as _, Row as _, TypeInfo as _};
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct MySqlPool {
|
||||
pool: MPool,
|
||||
pool: sqlx::mysql::MySqlPool,
|
||||
}
|
||||
|
||||
impl MySqlPool {
|
||||
pub async fn new(database_url: &str) -> anyhow::Result<Self> {
|
||||
Ok(Self {
|
||||
pool: MPool::connect(database_url).await?,
|
||||
pool: MySqlPoolOptions::new()
|
||||
.connect_timeout(Duration::from_millis(500))
|
||||
.connect(database_url)
|
||||
.await?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@ use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
|
||||
use database_tree::{Child, Database, Schema, Table};
|
||||
use futures::TryStreamExt;
|
||||
use itertools::Itertools;
|
||||
use sqlx::postgres::{PgColumn, PgPool, PgRow};
|
||||
use sqlx::postgres::{PgColumn, PgPool, PgPoolOptions, PgRow};
|
||||
use sqlx::{Column as _, Row as _, TypeInfo as _};
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct PostgresPool {
|
||||
pool: PgPool,
|
||||
@@ -14,7 +15,10 @@ pub struct PostgresPool {
|
||||
impl PostgresPool {
|
||||
pub async fn new(database_url: &str) -> anyhow::Result<Self> {
|
||||
Ok(Self {
|
||||
pool: PgPool::connect(database_url).await?,
|
||||
pool: PgPoolOptions::new()
|
||||
.connect_timeout(Duration::from_millis(500))
|
||||
.connect(database_url)
|
||||
.await?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,21 @@ use async_trait::async_trait;
|
||||
use chrono::NaiveDateTime;
|
||||
use database_tree::{Child, Database, Table};
|
||||
use futures::TryStreamExt;
|
||||
use sqlx::sqlite::{SqliteColumn, SqlitePool as SPool, SqliteRow};
|
||||
use sqlx::sqlite::{SqliteColumn, SqlitePoolOptions, SqliteRow};
|
||||
use sqlx::{Column as _, Row as _, TypeInfo as _};
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct SqlitePool {
|
||||
pool: SPool,
|
||||
pool: sqlx::sqlite::SqlitePool,
|
||||
}
|
||||
|
||||
impl SqlitePool {
|
||||
pub async fn new(database_url: &str) -> anyhow::Result<Self> {
|
||||
Ok(Self {
|
||||
pool: SPool::connect(database_url).await?,
|
||||
pool: SqlitePoolOptions::new()
|
||||
.connect_timeout(Duration::from_millis(500))
|
||||
.connect(database_url)
|
||||
.await?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user