Преглед изворни кода

update actix-web to beta.1 (#4688)

Nikolay Kim пре 6 година
родитељ
комит
f8b5e55e96

+ 4 - 4
frameworks/Rust/actix/Cargo.toml

@@ -20,9 +20,9 @@ name = "actix-pg"
 path = "src/main_pg.rs"
 
 [dependencies]
-actix = { version="0.8.0", features=["http"] }
-actix-web = { version="1.0.0-alpha.6", default-features = false }
-actix-http = { version="0.1.0", default-features = false }
+actix = { version="0.8.1", features=["http"] }
+actix-web = { version="1.0.0-beta.1", default-features = false }
+actix-http = { version="0.1.1", default-features = false }
 actix-rt = "0.2.2"
 actix-server = "0.4.2"
 actix-service = "0.3.6"
@@ -52,4 +52,4 @@ opt-level = 3
 codegen-units = 1
 
 [patch.crates-io]
-tokio-reactor = { git="https://github.com/fafhrd91/tokio.git" }
+tokio-reactor = { git="https://github.com/fafhrd91/tokio.git" }

+ 2 - 2
frameworks/Rust/actix/src/db_pg_direct.rs

@@ -8,7 +8,7 @@ use rand::{thread_rng, Rng, ThreadRng};
 use tokio_postgres::{connect, Client, NoTls, Statement};
 
 use crate::models::{Fortune, World};
-use crate::utils::{Writer, SIZE};
+use crate::utils::Writer;
 
 /// Postgres interface
 pub struct PgConnection {
@@ -57,7 +57,7 @@ impl PgConnection {
             })
             .map(|(row, _)| {
                 let row = row.unwrap();
-                let mut body = BytesMut::with_capacity(SIZE);
+                let mut body = BytesMut::with_capacity(33);
                 serde_json::to_writer(
                     Writer(&mut body),
                     &World {

+ 2 - 2
frameworks/Rust/actix/src/main_diesel.rs

@@ -27,7 +27,7 @@ fn world_row(
         .from_err()
         .and_then(move |res| match res {
             Ok(row) => {
-                let mut body = BytesMut::with_capacity(31);
+                let mut body = BytesMut::with_capacity(33);
                 serde_json::to_writer(Writer(&mut body), &row).unwrap();
                 Ok(HttpResponse::Ok()
                     .header(http::header::SERVER, "Actix")
@@ -110,7 +110,7 @@ fn fortune(
 }
 
 fn main() -> std::io::Result<()> {
-    let sys = actix_rt::System::new("techempower");
+    let sys = actix_rt::System::builder().stop_on_panic(false).build();
     let db_url = "postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world";
 
     // Start db executor actors

+ 2 - 2
frameworks/Rust/actix/src/main_pg.rs

@@ -28,7 +28,7 @@ fn world_row(
         .from_err()
         .and_then(move |res| match res {
             Ok(row) => {
-                let mut body = BytesMut::with_capacity(31);
+                let mut body = BytesMut::with_capacity(33);
                 serde_json::to_writer(Writer(&mut body), &row).unwrap();
                 let mut res =
                     HttpResponse::with_body(StatusCode::OK, Body::Bytes(body.freeze()));
@@ -123,7 +123,7 @@ fn fortune(
 }
 
 fn main() -> std::io::Result<()> {
-    let sys = actix_rt::System::new("techempower");
+    let sys = actix_rt::System::builder().stop_on_panic(false).build();
     const DB_URL: &str =
         "postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world";
 

+ 1 - 4
frameworks/Rust/actix/src/main_platform.rs

@@ -221,10 +221,7 @@ impl NewService<ServerConfig> for AppFactory {
 }
 
 fn main() -> std::io::Result<()> {
-    let sys = actix_rt::System::builder()
-        .name("techempower")
-        .stop_on_panic(false)
-        .build();
+    let sys = actix_rt::System::builder().stop_on_panic(false).build();
 
     // start http server
     Server::build()

+ 1 - 1
frameworks/Rust/actix/src/models.rs

@@ -4,7 +4,7 @@ pub struct Message {
 }
 
 #[allow(non_snake_case)]
-#[derive(Serialize, Queryable)]
+#[derive(Serialize, Queryable, Debug)]
 pub struct World {
     pub id: i32,
     pub randomnumber: i32,

+ 1 - 1
frameworks/Rust/actix/src/utils.rs

@@ -3,7 +3,7 @@ use std::{cmp, io};
 
 use bytes::{BufMut, BytesMut};
 
-pub const SIZE: usize = 31;
+pub const SIZE: usize = 27;
 
 #[derive(Serialize, Deserialize)]
 pub struct Message {