我使用脚本循环请求时sqlx报错
“等待打开连接时池超时”
这个池在下面
Pool { size: 5, num_idle: 5, is_closed: false, options: PoolOptions { max_connections: 5, min_connections: 0, connect_timeout: 30s, max_lifetime: Some(1800s), idle_timeout: Some(600s), test_before_acquire: true } }
Run Code Online (Sandbox Code Playgroud)
这是我的代码
#[derive(Serialize)]
struct JsonResp {
id: i32
}
#[derive(Clone)]
struct AppState {
pub pool: MySqlPool
}
#[async_std::main]
async fn main() -> tide::Result<()> {
let pool = MySqlPoolOptions::new()
.max_connections(5)
.connect("mysql://root:123456@localhost:3306/blog").await?;
println!("{:?}", pool);
let app_state = AppState { pool: pool };
let mut app = tide::with_state(app_state);
app.at("/test").get(test);
app.listen("127.0.0.1:8080").await?;
Ok(())
}
async fn …Run Code Online (Sandbox Code Playgroud)