瀏覽代碼

:pencil: update rust toolchain (#5489)

Xudong Huang 5 年之前
父節點
當前提交
40a51a5b99
共有 2 個文件被更改,包括 15 次插入8 次删除
  1. 1 1
      frameworks/Rust/may-minihttp/may-minihttp.dockerfile
  2. 14 7
      frameworks/Rust/may-minihttp/src/main.rs

+ 1 - 1
frameworks/Rust/may-minihttp/may-minihttp.dockerfile

@@ -1,4 +1,4 @@
-FROM rust:1.40
+FROM rust:1.41
 
 RUN apt update -yqq && apt install -yqq cmake
 

+ 14 - 7
frameworks/Rust/may-minihttp/src/main.rs

@@ -13,7 +13,7 @@ use serde::Serialize;
 use smallvec::SmallVec;
 
 mod utils {
-    use may_postgres::ToSql;
+    use may_postgres::types::ToSql;
     use std::cmp;
 
     pub fn get_query_param(query: &str) -> u16 {
@@ -120,11 +120,16 @@ impl PgConnection {
     }
 
     fn get_world(&self, random_id: i32) -> Result<WorldRow, may_postgres::Error> {
-        let row = self.client.query_one(&self.world, &[&random_id])?;
-        Ok(WorldRow {
-            id: row.get(0),
-            randomnumber: row.get(1),
-        })
+        let mut q = self
+            .client
+            .query_raw(&self.world, utils::slice_iter(&[&random_id]))?;
+        match q.next().transpose()? {
+            Some(row) => Ok(WorldRow {
+                id: row.get(0),
+                randomnumber: row.get(1),
+            }),
+            None => unreachable!(),
+        }
     }
 
     fn get_worlds(
@@ -281,7 +286,9 @@ impl HttpServiceFactory for HttpServer {
 }
 
 fn main() {
-    may::config().set_pool_capacity(10000);
+    may::config()
+        .set_pool_capacity(10000)
+        .set_stack_size(0x1000);
     let server = HttpServer {
         db_pool: PgConnectionPool::new(
             "postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world",