Skip to content

Commit deebdf3

Browse files
Merge pull request #6877 from dragosv/rocket-async-sqlx
Rocket async
2 parents d352d9b + 2c92b44 commit deebdf3

12 files changed

+211
-203
lines changed

frameworks/Rust/rocket/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

frameworks/Rust/rocket/Cargo.toml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
[package]
2-
name = "rocket"
3-
version = "0.1.0"
4-
authors = ["Marcelo Barbosa <[email protected]>", "Brendan Hansknecht <[email protected]>"]
2+
name = "rocket_techempower"
3+
version = "0.2.0"
4+
authors = ["Marcelo Barbosa <[email protected]>", "Brendan Hansknecht <[email protected]>", "Dragos Varovici <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
diesel = { version = "1.4.5", features = ["postgres", "r2d2"] }
9-
num_cpus = "1.13.0"
10-
rand = "0.7.3"
11-
rocket = "0.4.5"
12-
serde = "1.0.115"
13-
serde_json = "1.0.57"
14-
serde_derive = "1.0.115"
15-
yarte = "0.12.2"
16-
lazy_static = "1.4.0"
8+
num_cpus = { version = "^1.13" }
9+
rand = { version = "^0.8" }
10+
yarte = { version = "^0.15" }
11+
lazy_static = { version = "^1.4" }
12+
async-stream = { version = "^0.3" }
13+
async-trait = { version = "0.1" }
14+
futures = { version = "^0.3" }
15+
futures-util = { version = "^0.3" }
16+
rocket = { git = "https://github.com/SergioBenitez/Rocket", features = [
17+
"json",
18+
] }
19+
sqlx = { version = "^0.5", features = [ "postgres", "macros", "migrate", "sqlite" ] }
20+
rocket_db_pools = { git = "https://github.com/SergioBenitez/Rocket", features = [ "sqlx_postgres" ] }
21+
figment = { version = "^0.10" }
22+
dotenv = { version = "^0.15" }
1723

18-
[dependencies.rocket_contrib]
19-
version = "*"
20-
default-features = false
21-
features = ["json"]
22-
23-
[profile.release]
24-
lto = true
25-
opt-level = 3
26-
codegen-units = 1
24+
serde = { version = "^1" }
25+
serde_json = { version = "^1" }
26+
serde_derive = { version = "^1" }

frameworks/Rust/rocket/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ classification = "Fullstack"
1313
database = "Postgres"
1414
database_os = "Linux"
1515
os = "Linux"
16-
orm = "Full"
16+
orm = "Raw"
1717
platform = "Rust"
1818
webserver = "Hyper"
1919
versus = "None"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TABLE World (
2+
id INTEGER PRIMARY KEY,
3+
randomnumber INTEGER NOT NULL
4+
);
5+
6+
INSERT INTO World (id, randomnumber) VALUES (1, 101);
7+
INSERT INTO World (id, randomnumber) VALUES (2, 102);
8+
INSERT INTO World (id, randomnumber) VALUES (3, 103);
9+
INSERT INTO World (id, randomnumber) VALUES (4, 104);
10+
INSERT INTO World (id, randomnumber) VALUES (5, 105);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CREATE TABLE Fortune (
2+
id INTEGER PRIMARY KEY,
3+
message VARCHAR NOT NULL
4+
);
5+
6+
INSERT INTO Fortune (id, message) VALUES (1, 'fortune: No such file or directory');
7+
INSERT INTO Fortune (id, message) VALUES (2, 'A computer scientist is someone who fixes things that aren''t broken.');
8+
INSERT INTO Fortune (id, message) VALUES (3, 'After enough decimal places, nobody gives a damn.');
9+
INSERT INTO Fortune (id, message) VALUES (4, 'A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
10+
INSERT INTO Fortune (id, message) VALUES (5, 'A computer program does what you tell it to do, not what you want it to do.');
11+
INSERT INTO Fortune (id, message) VALUES (6, 'Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen');
12+
INSERT INTO Fortune (id, message) VALUES (7, 'Any program that runs right is obsolete.');
13+
INSERT INTO Fortune (id, message) VALUES (8, 'A list is only as strong as its weakest link. — Donald Knuth');
14+
INSERT INTO Fortune (id, message) VALUES (9, 'Feature: A bug with seniority.');
15+
INSERT INTO Fortune (id, message) VALUES (10, 'Computers make very fast, very accurate mistakes.');
16+
INSERT INTO Fortune (id, message) VALUES (11, '<script>alert("This should not be displayed in a browser alert box.");</script>');
17+
INSERT INTO Fortune (id, message) VALUES (12, 'フレームワークのベンチマーク');
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
FROM rust:1.46.0-slim-buster
1+
FROM rust:1.55-slim-buster
22

3-
ENV DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
3+
ENV ROCKET_BENCHMARK_DATABASE_URL=postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world
44

55
RUN apt-get update && apt-get install -y --no-install-recommends \
66
libpq-dev \
77
&& rm -rf /var/lib/apt/lists/*
88

9-
RUN rustup toolchain install nightly-2020-08-29 -t x86_64-unknown-linux-gnu --no-self-update --profile minimal
10-
119
ADD ./ /rocket
1210
WORKDIR /rocket
1311

14-
RUN RUSTFLAGS="-C target-cpu=native" cargo +nightly-2020-08-29 build --release
12+
RUN RUSTFLAGS="-C target-cpu=native" cargo build --release
1513

1614
EXPOSE 8000
1715

18-
CMD ./target/release/rocket
16+
CMD ./target/release/rocket_techempower
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use rocket_db_pools::{sqlx, Database};
2+
3+
#[derive(Database)]
4+
#[database("hello_world")]
5+
pub struct HelloWorld(sqlx::PgPool);

frameworks/Rust/rocket/src/db.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)