Browse Source

update actix web to v3 (#6025)

Rob Ede 4 years ago
parent
commit
ed47cc2d34

+ 11 - 12
frameworks/Rust/actix/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "actix"
-version = "2.0.0"
+version = "3.0.0"
 edition = "2018"
 
 [[bin]]
@@ -24,34 +24,33 @@ name = "actix-raw"
 path = "src/main_raw.rs"
 
 [dependencies]
-actix = { version="0.9.0" }
-actix-web = { version="3.0.0-beta.1", default-features = false }
-actix-http = { version="2.0.0-beta.2", default-features = false }
+actix = "0.10.0"
+actix-web = { version = "3.0.0", default-features = false }
+actix-http = { version = "2.0.0", default-features = false }
 actix-rt = "1.1.1"
-actix-codec = "0.2.0"
-actix-server = "1.0.3"
-actix-service = "1.0.5"
+actix-codec = "0.3.0"
+actix-server = "1.0.4"
+actix-service = "1.0.6"
 snmalloc-rs = "0.2.6"
 askama = "0.8"
 markup = "0.4.1"
 yarte = "0.11"
-serde = "1.0"
+serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
-serde_derive = "1.0"
 env_logger = "0.7"
 rand = { version = "0.7", features = ["small_rng"] }
 bytes = "0.5.3"
-num_cpus = "1.0"
+num_cpus = "1.13.0"
 futures = "0.3.1"
 http = "0.2"
 simd-json = "0.3"
 simd-json-derive = "0.1.9"
 diesel = { version = "1.4.3", features = ["postgres"] }
-url = { version="1.7", features=["query_encoding"] }
+url = "2.1.1"
 log = { version = "0.4", features = ["release_max_level_debug"] }
 v_htmlescape = "0.10"
 tokio = "0.2"
-tokio-postgres = { git="https://github.com/fafhrd91/rust-postgres.git" }
+tokio-postgres = { git = "https://github.com/fafhrd91/rust-postgres.git" }
 
 [build-dependencies]
 askama = "0.8"

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

@@ -1,8 +1,8 @@
 //! Db executor actor
+
 use std::io;
 
 use actix::prelude::*;
-use diesel;
 use diesel::prelude::*;
 use diesel::result::Error;
 use rand::rngs::SmallRng;

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

@@ -1,9 +1,6 @@
 #[global_allocator]
 static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
 
-#[macro_use]
-extern crate serde_derive;
-
 use actix_http::{HttpService, KeepAlive};
 use actix_service::map_config;
 use actix_web::dev::{AppConfig, Body, Server};
@@ -48,7 +45,7 @@ async fn plaintext() -> HttpResponse {
     res
 }
 
-#[actix_rt::main]
+#[actix_web::main]
 async fn main() -> std::io::Result<()> {
     println!("Started http server: 127.0.0.1:8080");
 

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

@@ -1,8 +1,6 @@
 #[global_allocator]
 static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
 
-#[macro_use]
-extern crate serde_derive;
 #[macro_use]
 extern crate diesel;
 
@@ -16,6 +14,7 @@ mod db;
 mod models;
 mod schema;
 mod utils;
+
 use utils::Writer;
 
 async fn world_row(db: web::Data<Addr<db::DbExecutor>>) -> Result<HttpResponse, Error> {
@@ -111,7 +110,7 @@ async fn fortune(db: web::Data<Addr<db::DbExecutor>>) -> Result<HttpResponse, Er
     }
 }
 
-#[actix_rt::main]
+#[actix_web::main]
 async fn main() -> std::io::Result<()> {
     println!("Starting http server: 127.0.0.1:8080");
 

+ 1 - 6
frameworks/Rust/actix/src/main_pg.rs

@@ -1,11 +1,6 @@
 #[global_allocator]
 static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
 
-#[macro_use]
-extern crate serde_derive;
-#[macro_use]
-extern crate diesel;
-
 use std::io::Write;
 
 use actix::prelude::*;
@@ -123,7 +118,7 @@ async fn fortune(db: web::Data<Addr<PgConnection>>) -> Result<HttpResponse, Erro
     }
 }
 
-#[actix_rt::main]
+#[actix_web::main]
 async fn main() -> std::io::Result<()> {
     println!("Started http server: 127.0.0.1:8080");
 

+ 0 - 5
frameworks/Rust/actix/src/main_platform.rs

@@ -1,11 +1,6 @@
 #[global_allocator]
 static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
 
-#[macro_use]
-extern crate serde_derive;
-#[macro_use]
-extern crate diesel;
-
 use std::future::Future;
 use std::io::Write;
 use std::pin::Pin;

+ 2 - 7
frameworks/Rust/actix/src/main_raw.rs

@@ -1,11 +1,6 @@
 #[global_allocator]
 static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
 
-#[macro_use]
-extern crate serde_derive;
-#[macro_use]
-extern crate diesel;
-
 use std::future::Future;
 use std::io;
 use std::pin::Pin;
@@ -95,7 +90,7 @@ impl Future for App {
         }
 
         loop {
-            match this.codec.decode(&mut this.read_buf) {
+            match this.codec.decode(&mut Pin::new(&mut this.read_buf)) {
                 Ok(Some(h1::Message::Item(req))) => this.handle_request(req),
                 Ok(None) => break,
                 _ => return Poll::Ready(Err(())),
@@ -130,7 +125,7 @@ impl Future for App {
     }
 }
 
-#[actix_rt::main]
+#[actix_web::main]
 async fn main() -> io::Result<()> {
     println!("Started http server: 127.0.0.1:8080");
 

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

@@ -1,4 +1,5 @@
-#![allow(dead_code)]
+use diesel::Queryable;
+use serde::{Deserialize, Serialize};
 
 #[derive(Serialize, Deserialize)]
 pub struct Message {

+ 0 - 2
frameworks/Rust/actix/src/schema.rs

@@ -1,5 +1,3 @@
-#![allow(non_snake_case)]
-
 table! {
     world (id) {
         id -> Integer,

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

@@ -1,7 +1,9 @@
-#![allow(dead_code)]
+#![allow(dead_code, unused_braces)]
+
 use std::{cmp, io};
 
 use bytes::{BufMut, BytesMut};
+use serde::{Deserialize, Serialize};
 use yarte::Template;
 
 #[allow(non_snake_case)]