Skip to content

Commit 7effa8e

Browse files
committed
feat: toml
1 parent fdca6a2 commit 7effa8e

File tree

4 files changed

+21
-34
lines changed

4 files changed

+21
-34
lines changed

frameworks/Rust/hyperlane/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/Rust/hyperlane/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ exclude = [
2020

2121
[dependencies]
2222
futures = "0.3.31"
23-
hyperlane = "9.4.5"
23+
hyperlane = "9.5.0"
2424
hyperlane-time = "0.7.8"
2525
num_cpus = "1.17.0"
2626
once_cell = "1.21.3"

frameworks/Rust/hyperlane/src/db/fn.rs

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub fn get_db_connection() -> &'static DbPoolConnection {
77
#[cfg(feature = "dev")]
88
pub async fn create_database() {
99
let db_pool: &DbPoolConnection = get_db_connection();
10-
let _ = db_query(&format!("CREATE DATABASE {};", DATABASE_NAME))
10+
let _ = db_query(&format!("CREATE DATABASE {DATABASE_NAME};"))
1111
.execute(db_pool)
1212
.await;
1313
}
@@ -16,18 +16,16 @@ pub async fn create_database() {
1616
pub async fn create_table() {
1717
let db_pool: &DbPoolConnection = get_db_connection();
1818
let _ = db_query(&format!(
19-
"CREATE TABLE IF NOT EXISTS {} (
19+
"CREATE TABLE IF NOT EXISTS {TABLE_NAME_WORLD} (
2020
id SERIAL PRIMARY KEY, randomNumber INT NOT NULL
21-
);",
22-
TABLE_NAME_WORLD
21+
);"
2322
))
2423
.execute(db_pool)
2524
.await;
2625
let _ = db_query(&format!(
27-
"CREATE TABLE IF NOT EXISTS {} (
26+
"CREATE TABLE IF NOT EXISTS {TABLE_NAME_FORTUNE} (
2827
id SERIAL PRIMARY KEY, message VARCHAR NOT NULL
29-
);",
30-
TABLE_NAME_FORTUNE
28+
);"
3129
))
3230
.execute(db_pool)
3331
.await;
@@ -36,7 +34,7 @@ pub async fn create_table() {
3634
#[cfg(feature = "dev")]
3735
pub async fn insert_records() {
3836
let db_pool: &DbPoolConnection = get_db_connection();
39-
let row: PgRow = db_query(&format!("SELECT COUNT(*) FROM {}", TABLE_NAME_WORLD))
37+
let row: PgRow = db_query(&format!("SELECT COUNT(*) FROM {TABLE_NAME_WORLD}"))
4038
.fetch_one(db_pool)
4139
.await
4240
.unwrap();
@@ -49,22 +47,20 @@ pub async fn insert_records() {
4947
let mut values: Vec<String> = Vec::new();
5048
for _ in 0..missing_count {
5149
let random_number: i32 = get_random_id();
52-
values.push(format!("(DEFAULT, {})", random_number));
50+
values.push(format!("(DEFAULT, {random_number})"));
5351
}
5452
let sql: String = format!(
55-
"INSERT INTO {} (id, randomNumber) VALUES {}",
56-
TABLE_NAME_WORLD,
53+
"INSERT INTO {TABLE_NAME_WORLD} (id, randomNumber) VALUES {}",
5754
values.join(",")
5855
);
5956
let _ = db_query(&sql).execute(db_pool).await;
6057
let mut values: Vec<String> = Vec::new();
6158
for _ in 0..missing_count {
6259
let random_number: i32 = get_random_id();
63-
values.push(format!("(DEFAULT, {})", random_number));
60+
values.push(format!("(DEFAULT, {random_number})"));
6461
}
6562
let sql: String = format!(
66-
"INSERT INTO {} (id, message) VALUES {}",
67-
TABLE_NAME_FORTUNE,
63+
"INSERT INTO {TABLE_NAME_FORTUNE} (id, message) VALUES {}",
6864
values.join(",")
6965
);
7066
let _ = db_query(&sql).execute(db_pool).await;
@@ -73,10 +69,7 @@ pub async fn insert_records() {
7369
pub async fn init_cache() -> Vec<QueryRow> {
7470
let mut res: Vec<QueryRow> = Vec::with_capacity(RANDOM_MAX as usize);
7571
let db_pool: &DbPoolConnection = get_db_connection();
76-
let sql: String = format!(
77-
"SELECT id, randomNumber FROM {} LIMIT {}",
78-
TABLE_NAME_WORLD, RANDOM_MAX
79-
);
72+
let sql: String = format!("SELECT id, randomNumber FROM {TABLE_NAME_WORLD} LIMIT {RANDOM_MAX}");
8073
if let Ok(rows) = db_query(&sql).fetch_all(db_pool).await {
8174
for row in rows {
8275
let id: i32 = row.get(KEY_ID);
@@ -91,13 +84,7 @@ pub async fn connection_db() -> DbPoolConnection {
9184
let db_url: &str = match option_env!("POSTGRES_URL") {
9285
Some(it) => it,
9386
_ => &format!(
94-
"{}://{}:{}@{}:{}/{}",
95-
DATABASE_TYPE,
96-
DATABASE_USER_NAME,
97-
DATABASE_USER_PASSWORD,
98-
DATABASE_HOST,
99-
DATABASE_PORT,
100-
DATABASE_NAME
87+
"{DATABASE_TYPE}://{DATABASE_USER_NAME}:{DATABASE_USER_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_NAME}"
10188
),
10289
};
10390
let pool_size: u32 = (get_thread_count() as u32).min(DB_MAX_CONNECTIONS);
@@ -174,7 +161,7 @@ pub async fn update_world_rows(limit: Queries) -> Vec<QueryRow> {
174161

175162
pub async fn all_world_row() -> Vec<PgRow> {
176163
let db_pool: &DbPoolConnection = get_db_connection();
177-
let sql: String = format!("SELECT id, message FROM {}", TABLE_NAME_FORTUNE);
164+
let sql: String = format!("SELECT id, message FROM {TABLE_NAME_FORTUNE}");
178165
let res: Vec<PgRow> = db_query(&sql).fetch_all(db_pool).await.unwrap_or_default();
179166
return res;
180167
}

frameworks/Rust/hyperlane/src/server/impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl fmt::Display for FortunesTemplate {
3434
tem.id,
3535
escape_html(&tem.message)
3636
);
37-
let _ = write!(f, "{}", row);
37+
let _ = write!(f, "{row}");
3838
}
3939
let _ = write!(f, "</table></body></html>");
4040
Ok(())

0 commit comments

Comments
 (0)