Browse Source

rust rocket upgrade to 0.5.0rc2 (#7346)

Dragos Varovici 3 years ago
parent
commit
6b9bf4d883

+ 24 - 18
frameworks/Rust/rocket/Cargo.toml

@@ -1,26 +1,32 @@
 [package]
 name = "rocket_techempower"
-version = "0.2.0"
+version = "0.3.0"
 authors = ["Marcelo Barbosa <[email protected]>", "Brendan Hansknecht <[email protected]>", "Dragos Varovici <[email protected]>"]
-edition = "2018"
+edition = "2021"
+
+[[bin]]
+name = "rocket"
+path = "src/main.rs"
 
 [dependencies]
-num_cpus = { version = "^1.13" }
-rand = { version = "^0.8" }
-yarte = { version = "^0.15" }
-lazy_static = { version = "^1.4" }
-async-stream = { version = "^0.3" }
-async-trait = { version = "0.1" }
-futures = { version = "^0.3" }
-futures-util = { version = "^0.3" }
-rocket = { git = "https://github.com/SergioBenitez/Rocket", features = [
+num_cpus = "1.13.1"
+rand = "0.8.5"
+yarte = "0.15.6"
+lazy_static = "1.4.0"
+async-stream = "0.3.3"
+async-trait = "0.1.53"
+futures = "0.3.21"
+futures-util = "0.3.21"
+rocket = { version = "0.5.0-rc.2", features = [
     "json",
 ] }
-sqlx = { version = "^0.5", features = [ "postgres", "macros", "migrate", "sqlite" ] }
-rocket_db_pools = { git = "https://github.com/SergioBenitez/Rocket", features = [ "sqlx_postgres" ] }
-figment = { version = "^0.10" }
-dotenv = { version = "^0.15" }
+rocket_db_pools = { version = "0.1.0-rc.2", features = [
+    "sqlx_postgres",
+] }
+sqlx = { version = "0.5.13", features = [ "postgres", "macros" ] }
+figment = "0.10.6"
+dotenv = "0.15.0"
 
-serde = { version = "^1" }
-serde_json = { version = "^1" }
-serde_derive = { version = "^1" }
+serde = "1.0.137"
+serde_json = "1.0.81"
+serde_derive = "1.0.137"

+ 0 - 10
frameworks/Rust/rocket/db/migrations/20211027024424_create-world-table.sql

@@ -1,10 +0,0 @@
-CREATE TABLE World (
-    id INTEGER PRIMARY KEY,
-    randomnumber INTEGER NOT NULL
-);
-
-INSERT INTO World (id, randomnumber) VALUES (1, 101);
-INSERT INTO World (id, randomnumber) VALUES (2, 102);
-INSERT INTO World (id, randomnumber) VALUES (3, 103);
-INSERT INTO World (id, randomnumber) VALUES (4, 104);
-INSERT INTO World (id, randomnumber) VALUES (5, 105);

+ 0 - 17
frameworks/Rust/rocket/db/migrations/20211028024424_create-fortune-table.sql

@@ -1,17 +0,0 @@
-CREATE TABLE Fortune (
-    id INTEGER PRIMARY KEY,
-    message VARCHAR NOT NULL
-);
-
-INSERT INTO Fortune (id, message) VALUES (1, 'fortune: No such file or directory');
-INSERT INTO Fortune (id, message) VALUES (2, 'A computer scientist is someone who fixes things that aren''t broken.');
-INSERT INTO Fortune (id, message) VALUES (3, 'After enough decimal places, nobody gives a damn.');
-INSERT INTO Fortune (id, message) VALUES (4, 'A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
-INSERT INTO Fortune (id, message) VALUES (5, 'A computer program does what you tell it to do, not what you want it to do.');
-INSERT INTO Fortune (id, message) VALUES (6, 'Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen');
-INSERT INTO Fortune (id, message) VALUES (7, 'Any program that runs right is obsolete.');
-INSERT INTO Fortune (id, message) VALUES (8, 'A list is only as strong as its weakest link. — Donald Knuth');
-INSERT INTO Fortune (id, message) VALUES (9, 'Feature: A bug with seniority.');
-INSERT INTO Fortune (id, message) VALUES (10, 'Computers make very fast, very accurate mistakes.');
-INSERT INTO Fortune (id, message) VALUES (11, '<script>alert("This should not be displayed in a browser alert box.");</script>');
-INSERT INTO Fortune (id, message) VALUES (12, 'フレームワークのベンチマーク');

+ 3 - 2
frameworks/Rust/rocket/rocket.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.59-slim-buster
+FROM rust:1.60-slim
 
 ENV ROCKET_BENCHMARK_DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
 
@@ -10,7 +10,8 @@ ADD ./ /rocket
 WORKDIR /rocket
 
 RUN RUSTFLAGS="-C target-cpu=native" cargo build --release
+RUN cp ./target/release/rocket ./target/release/rocket-techempower
 
 EXPOSE 8000
 
-CMD ./target/release/rocket_techempower
+CMD ./target/release/rocket-techempower

+ 2 - 1
frameworks/Rust/rocket/src/main.rs

@@ -12,6 +12,7 @@ mod database;
 use dotenv::dotenv;
 use std::net::{IpAddr, Ipv4Addr};
 use std::env;
+use std::thread::available_parallelism;
 use rocket::{Rocket, Build};
 use rocket::serde::json::Json;
 use rocket::response::content::RawHtml;
@@ -156,7 +157,7 @@ pub fn launch() -> Rocket<Build> {
         port: 8000,
         keep_alive: 0,
         log_level: LogLevel::Off,
-        workers: num_cpus::get() * 16,
+        workers: available_parallelism().expect("could not get parallelism").get() * 16,
         ..Default::default()
     };