Rollback sleep timer

This commit is contained in:
Sik Yoon 2024-01-13 17:11:08 +09:00
parent 8b86a49fc4
commit f548c0b63c

View File

@ -15,7 +15,7 @@ pub async fn exists_table(table_name: &String) -> bool {
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -46,7 +46,7 @@ pub async fn exists_record(table_name: &String, condition: &Option<String>) -> b
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -55,7 +55,7 @@ pub async fn exists_record(table_name: &String, condition: &Option<String>) -> b
.await;
while exists_record.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
exists_record = sqlx::query_as::<_, Success>(&query_base)
.fetch_one(&mut conn)
.await;
@ -124,14 +124,14 @@ pub async fn new_table(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
let mut query_result = sqlx::query(&query).execute(&mut conn).await;
while let Err(e) = query_result {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
query_result = sqlx::query(&query).execute(&mut conn).await;
}
Ok(())
@ -146,7 +146,7 @@ pub async fn drop_table(table_name: &String) -> Result<MySqlQueryResult, Error>
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -171,7 +171,7 @@ pub async fn copy_table_data(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -180,7 +180,7 @@ pub async fn copy_table_data(
while let Err(e) = query_result {
query_result = sqlx::query(&query).execute(&mut conn).await;
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
}
Ok(())
}
@ -224,7 +224,7 @@ pub async fn insert_one_record(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -262,7 +262,7 @@ pub async fn copy_record(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -316,7 +316,7 @@ pub async fn insert_records(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -325,7 +325,7 @@ pub async fn insert_records(
while let Err(e) = query_result {
query_result = sqlx::query(&query).execute(&mut conn).await;
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
}
Ok(())
}
@ -373,7 +373,7 @@ pub async fn update_record(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -426,7 +426,7 @@ pub async fn update_record2(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -477,7 +477,7 @@ pub async fn update_record3(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -571,7 +571,7 @@ pub async fn update_records(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -597,7 +597,7 @@ pub async fn delete_record(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -622,7 +622,7 @@ pub async fn count_rows(table_name: &String) -> Result<i32, Error> {
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -650,7 +650,7 @@ pub async fn delete_all_rows(
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -659,7 +659,7 @@ pub async fn delete_all_rows(
while let Err(e) = query_result {
query_result = sqlx::query(&query).execute(&mut conn).await;
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
}
Ok(())
}
@ -692,7 +692,7 @@ where
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();
@ -708,12 +708,12 @@ where
query_result_vec = T;
break;
} else {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
query_result = sqlx::query_as::<_, T>(&query).fetch_all(&mut conn).await;
}
}
Err(e) => {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
query_result = sqlx::query_as::<_, T>(&query).fetch_all(&mut conn).await;
}
}
@ -748,7 +748,7 @@ where
let mut conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
//retry connection until it will be done.
while conn_result.is_err() {
sleep(Duration::from_millis(333)).await;
sleep(Duration::from_millis(200)).await;
conn_result = sqlx::mysql::MySqlConnection::connect(DB_URL).await;
}
let mut conn = conn_result.unwrap();