Skip to content

Commit fb90555

Browse files
feat: upgraded deps, rust version and edition
1 parent 53b8cb4 commit fb90555

File tree

12 files changed

+389
-229
lines changed

12 files changed

+389
-229
lines changed

frameworks/Rust/axum/Cargo.lock

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

frameworks/Rust/axum/Cargo.toml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "axum-techempower"
33
version = "0.2.1"
44
authors = ["Dragos Varovici <[email protected]>"]
5-
edition = "2021"
5+
edition = "2024"
66

77
[[bin]]
88
name = "axum"
@@ -39,49 +39,49 @@ simd-json = [
3939
]
4040

4141
[dependencies]
42-
axum = { version = "0.7.9", default-features = false, features = [
42+
axum = { version = "0.8.3", default-features = false, features = [
4343
"json",
4444
"query",
4545
"http1",
4646
"tokio",
4747
] }
48-
deadpool = { version = "0.12.1", features = ["rt_tokio_1", "serde", "managed"] }
48+
deadpool = { version = "0.12.2", features = ["rt_tokio_1", "serde", "managed"] }
4949
deadpool-postgres = { version = "0.14.1", features = ["rt_tokio_1", "serde"] }
5050
dotenv = "0.15.0"
5151
futures = "0.3.31"
5252
futures-util = "0.3.31"
53-
mongodb = { version = "3.1.1", features = [
53+
mongodb = { version = "3.2.3", features = [
5454
"zstd-compression",
5555
"snappy-compression",
5656
"zlib-compression",
5757
] }
5858
num_cpus = "1.16.0"
59-
rand = { version = "0.8.5", features = ["small_rng"] }
60-
serde = { version = "1.0.216", features = ["derive"] }
61-
serde_json = "1.0.134"
62-
sqlx = { version = "0.8.2", features = [
59+
rand = { version = "0.9.0", features = ["small_rng"] }
60+
serde = { version = "1.0.219", features = ["derive"] }
61+
serde_json = "1.0.140"
62+
sqlx = { version = "0.8.3", features = [
6363
"postgres",
6464
"macros",
6565
"runtime-tokio",
6666
"tls-rustls",
6767
] }
68-
tokio = { version = "1.42.0", features = ["full"] }
68+
tokio = { version = "1.44.2", features = ["full"] }
6969
tokio-pg-mapper = { version = "0.2.0" }
7070
tokio-pg-mapper-derive = { version = "0.2.0" }
71-
tokio-postgres = { version = "0.7.12" }
71+
tokio-postgres = { version = "0.7.13" }
7272
tower = { version = "0.5.2", features = ["util"] }
7373
tower-http = { version = "0.6.2", features = ["set-header"] }
7474
yarte = "0.15.7"
75-
simd-json = { version = "0.14.3", optional = true }
76-
axum-core = { version = "0.4.5", optional = true }
75+
simd-json = { version = "0.15.0", optional = true }
76+
axum-core = { version = "0.5.2", optional = true }
7777
mime = { version = "0.3.17", optional = true }
78-
bytes = { version = "1.9.0", optional = true }
79-
serde_path_to_error = { version = "0.1.16", optional = true }
80-
socket2 = "0.5.8"
81-
hyper = { version = "1.5", features = ["server", "http1"] }
78+
bytes = { version = "1.10.1", optional = true }
79+
serde_path_to_error = { version = "0.1.17", optional = true }
80+
socket2 = "0.5.9"
81+
hyper = { version = "1.6", features = ["server", "http1"] }
8282
hyper-util = { version = "0.1", features = ["tokio", "server-auto", "http1"] }
83-
quick_cache = "0.6.9"
84-
mimalloc = "0.1.43"
83+
quick_cache = "0.6.12"
84+
mimalloc = "0.1.45"
8585

8686

8787
[profile.release]

frameworks/Rust/axum/src/common/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{env, str::FromStr};
22

33
use core::fmt::Debug;
4-
use rand::{distributions::Uniform, rngs::SmallRng, Rng};
4+
use rand::{distr::Uniform, rngs::SmallRng, Rng};
55
pub mod models;
66
pub mod utils;
77

@@ -37,13 +37,13 @@ where
3737
#[allow(dead_code)]
3838
#[inline(always)]
3939
pub fn random_id(rng: &mut SmallRng) -> i32 {
40-
rng.gen_range(1..10_001)
40+
rng.random_range(1..=10_000)
4141
}
4242

4343
/// Generate an iterator of integers in the range 1 to 10,000 (inclusive)
4444
#[allow(dead_code)]
4545
#[inline(always)]
4646
pub fn random_ids(rng: &mut SmallRng, count: usize) -> impl Iterator<Item = i32> + use<'_> {
47-
rng.sample_iter(Uniform::new(1, 10_001))
47+
rng.sample_iter(Uniform::new_inclusive(1, 10_000).unwrap())
4848
.take(count)
4949
}

frameworks/Rust/axum/src/main_mongo.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use mongodb::{
2121
options::{ClientOptions, Compressor},
2222
Client,
2323
};
24-
use rand::{rngs::SmallRng, thread_rng, Rng, SeedableRng};
24+
use rand::{rngs::SmallRng, rng, Rng, SeedableRng};
2525
use yarte::Template;
2626
use mimalloc::MiMalloc;
2727

@@ -43,9 +43,9 @@ pub struct FortunesTemplate<'a> {
4343
}
4444

4545
async fn db(DatabaseConnection(db): DatabaseConnection) -> impl IntoResponse {
46-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
46+
let mut rng = SmallRng::from_rng(&mut rng());
4747

48-
let random_id = (rng.gen::<u32>() % 10_000 + 1) as i32;
48+
let random_id = rng.random_range(1..=10_000) as i32;
4949

5050
let world = find_world_by_id(db, random_id)
5151
.await
@@ -60,7 +60,7 @@ async fn queries(
6060
) -> impl IntoResponse {
6161
let q = parse_params(params);
6262

63-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
63+
let mut rng = SmallRng::from_rng(&mut rng());
6464
let worlds = find_worlds(db, &mut rng, q).await;
6565
let results = worlds.expect("worlds could not be retrieved");
6666

@@ -73,7 +73,7 @@ async fn updates(
7373
) -> impl IntoResponse {
7474
let q = parse_params(params);
7575

76-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
76+
let mut rng = SmallRng::from_rng(&mut rng());
7777

7878
let worlds = find_worlds(db.clone(), &mut rng, q)
7979
.await

frameworks/Rust/axum/src/main_mongo_raw.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ use mongodb::{
3232
options::{ClientOptions, Compressor},
3333
Client,
3434
};
35-
use rand::{rngs::SmallRng, thread_rng, SeedableRng};
35+
use rand::{rngs::SmallRng, rng, SeedableRng};
3636

3737
async fn db(DatabaseConnection(db): DatabaseConnection) -> impl IntoResponse {
38-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
38+
let mut rng = SmallRng::from_rng(&mut rng());
3939

4040
let random_id = random_id(&mut rng);
4141

@@ -52,7 +52,7 @@ async fn queries(
5252
) -> impl IntoResponse {
5353
let q = parse_params(params);
5454

55-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
55+
let mut rng = SmallRng::from_rng(&mut rng());
5656
let worlds = find_worlds(db, &mut rng, q).await;
5757
let results = worlds.expect("worlds could not be retrieved");
5858

@@ -65,7 +65,7 @@ async fn updates(
6565
) -> impl IntoResponse {
6666
let q = parse_params(params);
6767

68-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
68+
let mut rng = SmallRng::from_rng(&mut rng());
6969

7070
let worlds = find_worlds(db.clone(), &mut rng, q)
7171
.await

frameworks/Rust/axum/src/main_pg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use axum::{
55
extract::Query, http::StatusCode, response::IntoResponse, routing::get, Router,
66
};
77
use dotenv::dotenv;
8-
use rand::{rngs::SmallRng, thread_rng, SeedableRng};
8+
use rand::{rngs::SmallRng, rng, SeedableRng};
99
use yarte::Template;
1010
use mimalloc::MiMalloc;
1111

@@ -33,7 +33,7 @@ pub struct FortunesTemplate<'a> {
3333
}
3434

3535
async fn db(DatabaseConnection(conn): DatabaseConnection) -> impl IntoResponse {
36-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
36+
let mut rng = SmallRng::from_rng(&mut rng());
3737

3838
let world = conn
3939
.fetch_world_by_id(random_id(&mut rng))

frameworks/Rust/axum/src/main_pg_pool.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use common::simd_json::Json;
1313
use common::{random_ids, SELECT_ALL_FORTUNES, SELECT_WORLD_BY_ID, UPDATE_WORLDS};
1414
use dotenv::dotenv;
1515
use futures_util::{stream::FuturesUnordered, TryStreamExt};
16-
use rand::{rngs::SmallRng, thread_rng, SeedableRng};
16+
use rand::{rngs::SmallRng, rng, SeedableRng};
1717
use yarte::Template;
1818
use mimalloc::MiMalloc;
1919

@@ -38,7 +38,7 @@ pub struct FortunesTemplate<'a> {
3838
}
3939

4040
async fn db(DatabaseClient(client): DatabaseClient) -> impl IntoResponse {
41-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
41+
let mut rng = SmallRng::from_rng(&mut rng());
4242
let random_id = random_id(&mut rng);
4343

4444
let select = &client.prepare_cached(SELECT_WORLD_BY_ID).await.unwrap();
@@ -55,7 +55,7 @@ async fn queries(
5555
) -> impl IntoResponse {
5656
let q = parse_params(params);
5757

58-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
58+
let mut rng = SmallRng::from_rng(&mut rng());
5959
let select = &client.prepare_cached(SELECT_WORLD_BY_ID).await.unwrap();
6060
let future_worlds = FuturesUnordered::new();
6161

@@ -98,7 +98,7 @@ async fn updates(
9898
) -> impl IntoResponse {
9999
let q = parse_params(params);
100100

101-
let mut rng = SmallRng::from_entropy();
101+
let mut rng = SmallRng::from_rng(&mut rng());
102102
let select = &client.prepare_cached(SELECT_WORLD_BY_ID).await.unwrap();
103103
let update = &client.prepare_cached(UPDATE_WORLDS).await.unwrap();
104104

frameworks/Rust/axum/src/main_sqlx.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use axum::{
1313
};
1414
use dotenv::dotenv;
1515
use quick_cache::sync::Cache;
16-
use rand::{rngs::SmallRng, thread_rng, SeedableRng};
16+
use rand::{rngs::SmallRng, rng, SeedableRng};
1717
use sqlx::models::World;
1818
use yarte::Template;
1919
use mimalloc::MiMalloc;
@@ -42,7 +42,7 @@ pub struct FortunesTemplate<'a> {
4242
}
4343

4444
async fn db(State(AppState { db, .. }): State<AppState>) -> impl IntoResponse {
45-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
45+
let mut rng = SmallRng::from_rng(&mut rng());
4646

4747
let world: World = ::sqlx::query_as(common::SELECT_WORLD_BY_ID)
4848
.bind(random_id(&mut rng))
@@ -57,7 +57,7 @@ async fn queries(
5757
State(AppState { db, .. }): State<AppState>,
5858
Query(params): Query<Params>,
5959
) -> impl IntoResponse {
60-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
60+
let mut rng = SmallRng::from_rng(&mut rng());
6161
let count = parse_params(params);
6262
let mut worlds: Vec<World> = Vec::with_capacity(count);
6363

@@ -100,7 +100,7 @@ async fn cache(
100100
Query(params): Query<Params>,
101101
) -> impl IntoResponse {
102102
let count = parse_params(params);
103-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
103+
let mut rng = SmallRng::from_rng(&mut rng());
104104
let mut worlds: Vec<Option<World>> = Vec::with_capacity(count);
105105

106106
for id in random_ids(&mut rng, count) {

frameworks/Rust/axum/src/mongo/database.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{convert::Infallible, io};
22

3-
use axum::{async_trait, extract::FromRequestParts, http::request::Parts};
3+
use axum::{extract::FromRequestParts, http::request::Parts};
44
use futures_util::{stream::FuturesUnordered, StreamExt, TryStreamExt};
55
use mongodb::{bson::doc, Database};
66
use rand::rngs::SmallRng;
@@ -9,7 +9,6 @@ use crate::common::{models::{Fortune, World}, random_ids};
99

1010
pub struct DatabaseConnection(pub Database);
1111

12-
#[async_trait]
1312
impl FromRequestParts<Database> for DatabaseConnection {
1413
type Rejection = Infallible;
1514

frameworks/Rust/axum/src/mongo_raw/database.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{convert::Infallible, io};
22

3-
use axum::{async_trait, extract::FromRequestParts, http::request::Parts};
3+
use axum::{extract::FromRequestParts, http::request::Parts};
44
use futures_util::{stream::FuturesUnordered, TryStreamExt};
55
use mongodb::{
66
bson::{doc, RawDocumentBuf},
@@ -12,7 +12,6 @@ use crate::common::{models::World, random_ids};
1212

1313
pub struct DatabaseConnection(pub Database);
1414

15-
#[async_trait]
1615
impl FromRequestParts<Database> for DatabaseConnection {
1716
type Rejection = Infallible;
1817

0 commit comments

Comments
 (0)