Skip to content

Commit 1744452

Browse files
bump sib to v0.0.10 (#10011)
1 parent 89be83d commit 1744452

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

frameworks/Rust/sib/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ categories = ["development-tools"]
1212
readme = "README.md"
1313

1414
[dependencies]
15-
sib = { git = "https://github.com/PooyaEimandar/sib", default-features = false, features = [
15+
sib = { version = "0.0.10", default-features = false, features = [
1616
"net-h1-server",
1717
] }
1818
bytes = { version = "1.10.1", default-features = false }
1919
mimalloc = { version = "0.1.47", features = ["secure"] }
2020
num_cpus = { version = "1.17.0" }
2121
serde = { version = "1.0.219", default-features = false, features = ["derive"] }
22-
serde_json = { version = "1.0.140" }
22+
serde_json = { version = "1.0.141" }
2323

2424
[profile.release]
2525
opt-level = 3

frameworks/Rust/sib/benchmark_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"port": 8080,
99
"approach": "Realistic",
1010
"classification": "Fullstack",
11-
"framework": "may",
11+
"framework": "sib",
1212
"language": "Rust",
1313
"flavor": "None",
1414
"platform": "None",

frameworks/Rust/sib/src/main.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
use bytes::Bytes;
22
use sib::network::http::{
3-
h1::{H1Service, H1ServiceFactory},
4-
util::Status,
5-
session::Session,
3+
server::HFactory, session::{HService, Session}, util::Status
64
};
75
use std::{
8-
fs,
9-
io::{Read, Write},
6+
fs
107
};
118

129
#[global_allocator]
@@ -25,12 +22,10 @@ impl Default for JsonMessage<'_> {
2522
}
2623
}
2724

28-
struct H1Server<T>(pub T);
25+
struct Server;
2926

30-
struct HService;
31-
32-
impl H1Service for HService {
33-
fn call<S: Read + Write>(&mut self, session: &mut Session<S>) -> std::io::Result<()> {
27+
impl HService for Server {
28+
fn call<S: Session>(&mut self, session: &mut S) -> std::io::Result<()> {
3429
if session.req_path() == Some("/json") {
3530
// Respond with JSON
3631
let json = serde_json::to_vec(&JsonMessage::default())?;
@@ -52,11 +47,11 @@ impl H1Service for HService {
5247
}
5348
}
5449

55-
impl H1ServiceFactory for H1Server<HService> {
56-
type Service = HService;
50+
impl HFactory for Server{
51+
type Service = Server;
5752

58-
fn service(&self, _id: usize) -> HService {
59-
HService
53+
fn service(&self, _id: usize) -> Server {
54+
Server
6055
}
6156
}
6257

@@ -65,6 +60,8 @@ fn main() {
6560
let cpus = num_cpus::get();
6661
println!("CPU cores: {cpus}");
6762

63+
sib::set_num_workers(cpus);
64+
6865
// Print total RAM in MB
6966
if let Ok(meminfo) = fs::read_to_string("/proc/meminfo") {
7067
for line in meminfo.lines() {
@@ -89,8 +86,8 @@ fn main() {
8986
let handle = std::thread::spawn(move || {
9087
let id = std::thread::current().id();
9188
println!("Listening {addr} on thread: {id:?}");
92-
H1Server(HService)
93-
.start(addr, cpus, 0)
89+
Server
90+
.start_h1(addr, 0)
9491
.unwrap_or_else(|_| panic!("h1 server failed to start for thread {id:?}"))
9592
.join()
9693
.unwrap_or_else(|_| panic!("h1 server failed to joining thread {id:?}"));

0 commit comments

Comments
 (0)