Browse Source

Update ntex versions (#5907)

* Update ntex version

* Update yarte at ntex
Juan Aguilar 5 years ago
parent
commit
8bb0c2e136

+ 3 - 3
frameworks/Rust/ntex/Cargo.toml

@@ -16,12 +16,12 @@ name = "ntex-raw"
 path = "src/main_raw.rs"
 
 [dependencies]
-ntex = "0.1.18"
+ntex = "0.1.21"
 snmalloc-rs = { version = "0.2.17", features = ["native-cpu"] }
-yarte = { version = "0.11", features = ["bytes-buf", "json"] }
+yarte = { version = "0.12", features = ["bytes-buf", "json"] }
 env_logger = "0.7"
 random-fast-rng = "0.1.1"
-bytes = "0.5.3"
+bytes = "0.5.6"
 atoi = "0.3.2"
 num_cpus = "1.0"
 futures = "0.3.4"

+ 1 - 1
frameworks/Rust/ntex/ntex-db.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.44
+FROM rust:1.45
 
 # Disable simd at jsonescape
 ENV CARGO_CFG_JSONESCAPE_DISABLE_AUTO_SIMD=

+ 1 - 1
frameworks/Rust/ntex/ntex-raw.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.44
+FROM rust:1.45
 
 # Disable simd at jsonescape
 ENV CARGO_CFG_JSONESCAPE_DISABLE_AUTO_SIMD=

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

@@ -1,4 +1,4 @@
-FROM rust:1.44
+FROM rust:1.45
 
 # Disable simd at jsonescape
 ENV CARGO_CFG_JSONESCAPE_DISABLE_AUTO_SIMD=

+ 7 - 10
frameworks/Rust/ntex/src/db.rs

@@ -3,7 +3,7 @@ use std::cell::RefCell;
 use std::fmt::Write as FmtWrite;
 use std::io;
 
-use bytes::Bytes;
+use bytes::{Bytes, BytesMut};
 use futures::stream::futures_unordered::FuturesUnordered;
 use futures::{Future, FutureExt, StreamExt, TryStreamExt};
 use ntex::web::Error;
@@ -11,7 +11,7 @@ use random_fast_rng::{FastRng, Random};
 use smallvec::SmallVec;
 use tokio_postgres::types::ToSql;
 use tokio_postgres::{connect, Client, NoTls, Statement};
-use yarte::{Serialize, TemplateBytes};
+use yarte::{ywrite_html, Serialize};
 
 #[derive(Serialize, Debug)]
 pub struct World {
@@ -25,12 +25,6 @@ pub struct Fortune {
     pub message: Cow<'static, str>,
 }
 
-#[derive(TemplateBytes)]
-#[template(path = "fortune")]
-pub struct FortunesTemplate {
-    pub fortunes: SmallVec<[Fortune; 32]>,
-}
-
 /// Postgres interface
 pub struct PgConnection {
     cl: Client,
@@ -92,7 +86,7 @@ impl PgConnection {
                 id: row.get(0),
                 randomnumber: row.get(1),
             }
-            .to_bytes(40))
+            .to_bytes::<BytesMut>(40))
         }
     }
 
@@ -194,7 +188,10 @@ impl PgConnection {
 
             fortunes.sort_by(|it, next| it.message.cmp(&next.message));
 
-            Ok(FortunesTemplate { fortunes }.ccall(2048))
+            let mut buf = BytesMut::with_capacity(2048);
+            ywrite_html!(buf, "{{> fortune }}");
+
+            Ok(buf.freeze())
         }
     }
 }

+ 2 - 2
frameworks/Rust/ntex/src/main.rs

@@ -1,7 +1,7 @@
 #[global_allocator]
 static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
 
-use bytes::Bytes;
+use bytes::{Bytes, BytesMut};
 use ntex::{http, web};
 use yarte::Serialize;
 
@@ -20,7 +20,7 @@ async fn json() -> web::HttpResponse {
             Message {
                 message: "Hello, World!",
             }
-            .to_bytes(SIZE),
+            .to_bytes::<BytesMut>(SIZE),
         ),
     );
     res.headers_mut().insert(

+ 3 - 2
frameworks/Rust/ntex/src/main_db.rs

@@ -5,6 +5,7 @@ use std::future::Future;
 use std::pin::Pin;
 use std::task::{Context, Poll};
 
+use bytes::BytesMut;
 use futures::future::ok;
 use ntex::http::body::Body;
 use ntex::http::header::{HeaderValue, CONTENT_TYPE, SERVER};
@@ -78,7 +79,7 @@ impl Service for App {
                     let size = 35 * worlds.len();
                     let mut res = Response::with_body(
                         StatusCode::OK,
-                        Body::Bytes(worlds.to_bytes(size)),
+                        Body::Bytes(worlds.to_bytes::<BytesMut>(size)),
                     );
                     let hdrs = res.headers_mut();
                     hdrs.insert(SERVER, h_srv);
@@ -97,7 +98,7 @@ impl Service for App {
                     let size = 35 * worlds.len();
                     let mut res = Response::with_body(
                         StatusCode::OK,
-                        Body::Bytes(worlds.to_bytes(size)),
+                        Body::Bytes(worlds.to_bytes::<BytesMut>(size)),
                     );
                     let hdrs = res.headers_mut();
                     hdrs.insert(SERVER, h_srv);