Skip to content

Commit

Permalink
feat:v2.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ltpp-universe committed Jan 6, 2025
1 parent a2dfe17 commit b78be02
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 13 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hyperlane"
version = "2.30.0"
version = "2.31.0"
edition = "2021"
authors = ["ltpp-universe <root@ltpp.vip>"]
license = "MIT"
Expand All @@ -17,9 +17,9 @@ exclude = [

[dependencies]
color-output = "6.1.4"
http-request = "8.26.0"
http-type = "2.20.0"
hyperlane-log = "0.15.0"
http-request = "8.29.0"
http-type = "2.21.0"
hyperlane-log = "0.16.0"
hyperlane-time = "0.0.1"
lombok-macros = "1.5.0"
std-macro-extensions = "0.17.6"
Expand Down
1 change: 1 addition & 0 deletions src/server/config/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use super::r#type::ServerConfig;
use crate::*;

impl<'a> Default for ServerConfig<'a> {
#[inline]
fn default() -> Self {
Self {
host: DEFAULT_HOST,
Expand Down
1 change: 1 addition & 0 deletions src/server/controller_data/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use http_type::{Request, Response};
use hyperlane_log::*;

impl ControllerData {
#[inline]
pub fn new() -> Self {
ControllerData {
stream: None,
Expand Down
1 change: 1 addition & 0 deletions src/server/error/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{
impl StdError for Error {}

impl Display for Error {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::TcpBindError(data) => write!(f, "Tcp bind error{}{}", COLON_SPACE, data),
Expand Down
13 changes: 13 additions & 0 deletions src/server/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use hyperlane_time::*;
use std_macro_extensions::*;

impl Default for Server {
#[inline]
fn default() -> Self {
Self {
cfg: Arc::new(RwLock::new(ServerConfig::default())),
Expand All @@ -25,10 +26,12 @@ impl Default for Server {
}

impl Server {
#[inline]
pub fn new() -> Self {
Self::default()
}

#[inline]
pub fn host(&mut self, host: &'static str) -> &mut Self {
let _ = self.get_cfg().write().and_then(|mut cfg| {
cfg.set_host(host);
Expand All @@ -37,6 +40,7 @@ impl Server {
self
}

#[inline]
pub fn port(&mut self, port: usize) -> &mut Self {
let _ = self.get_cfg().write().and_then(|mut cfg| {
cfg.set_port(port);
Expand All @@ -45,6 +49,7 @@ impl Server {
self
}

#[inline]
pub fn thread_pool_size(&mut self, thread_pool_size: usize) -> &mut Self {
let _ = self.get_cfg().write().and_then(|mut cfg| {
cfg.set_thread_pool_size(thread_pool_size);
Expand All @@ -53,6 +58,7 @@ impl Server {
self
}

#[inline]
pub fn log_dir(&mut self, log_dir: &'static str) -> &mut Self {
let _ = self.get_cfg().write().and_then(|mut cfg| {
cfg.set_log_dir(log_dir);
Expand All @@ -65,6 +71,7 @@ impl Server {
self
}

#[inline]
pub fn log_size(&mut self, log_size: usize) -> &mut Self {
let _ = self.get_cfg().write().and_then(|mut cfg| {
cfg.set_log_size(log_size);
Expand All @@ -77,6 +84,7 @@ impl Server {
self
}

#[inline]
pub fn router<F>(&mut self, route: &'static str, func: F) -> &mut Self
where
F: 'static + Send + Sync + Fn(&mut ControllerData),
Expand All @@ -87,6 +95,7 @@ impl Server {
self
}

#[inline]
pub fn middleware<F>(&mut self, func: F) -> &mut Self
where
F: 'static + Send + Sync + Fn(&mut ControllerData),
Expand All @@ -97,10 +106,12 @@ impl Server {
self
}

#[inline]
fn common_log(data: &String) -> String {
format!("{}: {}{}", current_time(), data.to_string(), HTTP_BR)
}

#[inline]
pub fn listen(&mut self) -> &mut Self {
self.init();
let mut host: &str = EMPTY_STR;
Expand Down Expand Up @@ -194,13 +205,15 @@ impl Server {
self
}

#[inline]
fn init_log(&self) {
let _ = self.get_tmp().read().and_then(|tmp| {
log_run(tmp.get_log());
Ok(())
});
}

#[inline]
fn init(&self) {
self.init_log();
}
Expand Down
2 changes: 2 additions & 0 deletions src/server/thread_pool/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::*;
use std::sync::mpsc::{self, Receiver};

impl ThreadPool {
#[inline]
pub fn new(size: usize) -> ThreadPool {
let (sender, receiver) = mpsc::channel();
let receiver: ArcMutex<Receiver<Box<dyn FnOnce() + Send>>> = Arc::new(Mutex::new(receiver));
Expand All @@ -14,6 +15,7 @@ impl ThreadPool {
ThreadPool { workers, sender }
}

#[inline]
pub fn execute<F>(&self, job: F)
where
F: FnOnce() + Send + 'static,
Expand Down
3 changes: 3 additions & 0 deletions src/server/tmp/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use super::r#type::Tmp;
use crate::*;

impl Default for Tmp {
#[inline]
fn default() -> Self {
Self {
running_thread_num: Arc::new(Mutex::new(0)),
Expand All @@ -11,6 +12,7 @@ impl Default for Tmp {
}

impl Tmp {
#[inline]
pub fn add_thread_num(&mut self) {
let _ = self
.running_thread_num
Expand All @@ -21,6 +23,7 @@ impl Tmp {
});
}

#[inline]
pub fn sub_thread_num(&mut self) {
let _ = self
.running_thread_num
Expand Down
1 change: 1 addition & 0 deletions src/server/worker/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::*;
use std::{sync::mpsc::Receiver, thread::spawn};

impl Worker {
#[inline]
pub fn new(id: usize, receiver: ArcMutex<Receiver<Job>>) -> Worker {
let thread = spawn(move || loop {
let job = receiver.lock().unwrap().recv().unwrap();
Expand Down
1 change: 1 addition & 0 deletions src/utils/thread.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[inline]
pub fn get_thread_count() -> usize {
match std::thread::available_parallelism() {
Ok(count) => count.get(),
Expand Down

0 comments on commit b78be02

Please sign in to comment.