Browse Source

mongoDB fix and updates (#7882)

Co-authored-by: Roman Stingler <[email protected]>
romanstingler 2 years ago
parent
commit
68244c7434

+ 1 - 1
frameworks/Rust/axum/axum-mongo-raw.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.65-slim-buster
+FROM rust:1.67-slim-buster
 
 
 ENV AXUM_TECHEMPOWER_MONGODB_URL=mongodb://tfb-database:27017
 ENV AXUM_TECHEMPOWER_MONGODB_URL=mongodb://tfb-database:27017
 ENV AXUM_TECHEMPOWER_MAX_POOL_SIZE=28
 ENV AXUM_TECHEMPOWER_MAX_POOL_SIZE=28

+ 1 - 1
frameworks/Rust/axum/axum-mongo.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.65-slim-buster
+FROM rust:1.67-slim-buster
 
 
 ENV AXUM_TECHEMPOWER_MONGODB_URL=mongodb://tfb-database:27017
 ENV AXUM_TECHEMPOWER_MONGODB_URL=mongodb://tfb-database:27017
 ENV AXUM_TECHEMPOWER_MAX_POOL_SIZE=28
 ENV AXUM_TECHEMPOWER_MAX_POOL_SIZE=28

+ 1 - 1
frameworks/Rust/axum/axum-pg-pool.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.65-slim-buster
+FROM rust:1.67-slim-buster
 
 
 ENV AXUM_TECHEMPOWER_DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
 ENV AXUM_TECHEMPOWER_DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
 ENV AXUM_TECHEMPOWER_MAX_POOL_SIZE=28
 ENV AXUM_TECHEMPOWER_MAX_POOL_SIZE=28

+ 1 - 1
frameworks/Rust/axum/axum-pg.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.65-slim-buster
+FROM rust:1.67-slim-buster
 
 
 ENV AXUM_TECHEMPOWER_DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
 ENV AXUM_TECHEMPOWER_DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
 
 

+ 1 - 1
frameworks/Rust/axum/axum-sqlx.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.65-slim-buster
+FROM rust:1.67-slim-buster
 
 
 ENV AXUM_TECHEMPOWER_DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
 ENV AXUM_TECHEMPOWER_DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
 ENV AXUM_TECHEMPOWER_MAX_POOL_SIZE=56
 ENV AXUM_TECHEMPOWER_MAX_POOL_SIZE=56

+ 1 - 1
frameworks/Rust/axum/axum.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.65-slim-buster
+FROM rust:1.67-slim-buster
 
 
 RUN apt-get update && apt-get install -y --no-install-recommends \
 RUN apt-get update && apt-get install -y --no-install-recommends \
     pkg-config libssl-dev \
     pkg-config libssl-dev \

+ 1 - 1
frameworks/Rust/axum/src/database_mongo.rs

@@ -89,7 +89,7 @@ pub async fn fetch_fortunes(db: Database) -> Result<Vec<Fortune>, MongoError> {
     }
     }
 
 
     fortunes.push(Fortune {
     fortunes.push(Fortune {
-        id: 0.0,
+        id: 0,
         message: "Additional fortune added at request time.".to_string(),
         message: "Additional fortune added at request time.".to_string(),
     });
     });
 
 

+ 7 - 8
frameworks/Rust/axum/src/database_mongo_raw.rs

@@ -66,15 +66,14 @@ pub async fn find_world_by_id(db: Database, id: i32) -> Result<World, MongoError
             .get("id")
             .get("id")
             .expect("expected to parse world id")
             .expect("expected to parse world id")
             .expect("could not get world id")
             .expect("could not get world id")
-            .as_f64()
-            .expect("could not extract world id") as f32,
+            .as_i32()
+            .expect("could not extract world id"),
         random_number: raw
         random_number: raw
-            .get("randomNumber")
-            .expect("expected to parse world randomNumber")
-            .expect("expected to get world randomNumber")
-            .as_f64()
-            .expect("could not extract world randomNumber")
-            as f32,
+            .get("id")
+            .expect("expected to parse world id")
+            .expect("could not get world id")
+            .as_i32()
+            .expect("could not extract world id"),
     })
     })
 }
 }
 
 

+ 1 - 1
frameworks/Rust/axum/src/main_mongo.rs

@@ -88,7 +88,7 @@ async fn updates(
     for mut world in worlds {
     for mut world in worlds {
         let random_number = (rng.gen::<u32>() % 10_000 + 1) as i32;
         let random_number = (rng.gen::<u32>() % 10_000 + 1) as i32;
 
 
-        world.random_number = random_number as f32;
+        world.random_number = random_number;
         updated_worlds.push(world);
         updated_worlds.push(world);
     }
     }
 
 

+ 1 - 1
frameworks/Rust/axum/src/main_mongo_raw.rs

@@ -78,7 +78,7 @@ async fn updates(
     for mut world in worlds {
     for mut world in worlds {
         let random_number = (rng.gen::<u32>() % 10_000 + 1) as i32;
         let random_number = (rng.gen::<u32>() % 10_000 + 1) as i32;
 
 
-        world.random_number = random_number as f32;
+        world.random_number = random_number;
         updated_worlds.push(world);
         updated_worlds.push(world);
     }
     }
 
 

+ 3 - 3
frameworks/Rust/axum/src/models_mongo.rs

@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
 
 
 #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
 #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
 pub struct Fortune {
 pub struct Fortune {
-    pub id: f32,
+    pub id: i32,
     pub message: String,
     pub message: String,
 }
 }
 
 
@@ -14,7 +14,7 @@ pub struct FortuneInfo {
 
 
 #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
 #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
 pub struct World {
 pub struct World {
-    pub id: f32,
+    pub id: i32,
     #[serde(rename = "randomNumber")]
     #[serde(rename = "randomNumber")]
-    pub random_number: f32,
+    pub random_number: i32,
 }
 }