浏览代码

bump sib to v0.0.10 (#10011)

Outer Heaven Legacy 1 月之前
父节点
当前提交
1744452b42
共有 3 个文件被更改,包括 16 次插入19 次删除
  1. 2 2
      frameworks/Rust/sib/Cargo.toml
  2. 1 1
      frameworks/Rust/sib/benchmark_config.json
  3. 13 16
      frameworks/Rust/sib/src/main.rs

+ 2 - 2
frameworks/Rust/sib/Cargo.toml

@@ -12,14 +12,14 @@ categories = ["development-tools"]
 readme = "README.md"
 
 [dependencies]
-sib = { git = "https://github.com/PooyaEimandar/sib", default-features = false, features = [
+sib = { version = "0.0.10", default-features = false, features = [
     "net-h1-server",
 ] }
 bytes = { version = "1.10.1", default-features = false }
 mimalloc = { version = "0.1.47", features = ["secure"] }
 num_cpus = { version = "1.17.0" }
 serde = { version = "1.0.219", default-features = false, features = ["derive"] }
-serde_json = { version = "1.0.140" }
+serde_json = { version = "1.0.141" }
 
 [profile.release]
 opt-level = 3

+ 1 - 1
frameworks/Rust/sib/benchmark_config.json

@@ -8,7 +8,7 @@
         "port": 8080,
         "approach": "Realistic",
         "classification": "Fullstack",
-        "framework": "may",
+        "framework": "sib",
         "language": "Rust",
         "flavor": "None",
         "platform": "None",

+ 13 - 16
frameworks/Rust/sib/src/main.rs

@@ -1,12 +1,9 @@
 use bytes::Bytes;
 use sib::network::http::{
-    h1::{H1Service, H1ServiceFactory},
-    util::Status,
-    session::Session,
+    server::HFactory, session::{HService, Session}, util::Status
 };
 use std::{
-    fs,
-    io::{Read, Write},
+    fs
 };
 
 #[global_allocator]
@@ -25,12 +22,10 @@ impl Default for JsonMessage<'_> {
     }
 }
 
-struct H1Server<T>(pub T);
+struct Server;
 
-struct HService;
-
-impl H1Service for HService {
-    fn call<S: Read + Write>(&mut self, session: &mut Session<S>) -> std::io::Result<()> {
+impl HService for Server {
+    fn call<S: Session>(&mut self, session: &mut S) -> std::io::Result<()> {
         if session.req_path() == Some("/json") {
             // Respond with JSON
             let json = serde_json::to_vec(&JsonMessage::default())?;
@@ -52,11 +47,11 @@ impl H1Service for HService {
     }
 }
 
-impl H1ServiceFactory for H1Server<HService> {
-    type Service = HService;
+impl HFactory for Server{
+    type Service = Server;
 
-    fn service(&self, _id: usize) -> HService {
-        HService
+    fn service(&self, _id: usize) -> Server {
+        Server
     }
 }
 
@@ -65,6 +60,8 @@ fn main() {
     let cpus = num_cpus::get();
     println!("CPU cores: {cpus}");
 
+    sib::set_num_workers(cpus);
+
     // Print total RAM in MB
     if let Ok(meminfo) = fs::read_to_string("/proc/meminfo") {
         for line in meminfo.lines() {
@@ -89,8 +86,8 @@ fn main() {
         let handle = std::thread::spawn(move || {
             let id = std::thread::current().id();
             println!("Listening {addr} on thread: {id:?}");
-            H1Server(HService)
-                .start(addr, cpus, 0)
+            Server
+                .start_h1(addr, 0)
                 .unwrap_or_else(|_| panic!("h1 server failed to start for thread {id:?}"))
                 .join()
                 .unwrap_or_else(|_| panic!("h1 server failed to joining thread {id:?}"));