refactor(tests): reformat code and update dependency management

- Reorganized import statements in adapter tests for better readability
- Replaced or_insert_with(Vec::new) with or_default() in test closures
- Updated Cargo.lock with new dependency versions and checksums
- Added TLS features to tonic dependency configuration
- Included sqlx, chrono, and uuid dependencies with specific features
- Added jsonwebtoken and arc-swap as project dependencies
- Reformatted assertion statements to comply with line length limits
- Adjusted base64 import order in engine codec module
- Updated protobuf include statement formatting
This commit is contained in:
zhenyi
2026-06-11 12:11:05 +08:00
parent 06e8ee96a5
commit 821537186e
111 changed files with 10458 additions and 385 deletions
+52 -8
View File
@@ -1,6 +1,6 @@
use std::sync::Arc;
use actix_web::{web, App, HttpServer};
use actix_web::{App, HttpRequest, HttpResponse, HttpServer, web};
use crate::engine::heartbeat::HeartbeatManager;
use crate::engine::packet::Packet;
@@ -31,6 +31,53 @@ pub struct EngineServer {
on_message: Arc<dyn Fn(String, Packet) + Send + Sync>,
}
#[derive(Debug, serde::Deserialize)]
pub struct EngineQuery {
#[serde(rename = "EIO")]
pub eio: Option<String>,
pub transport: Option<String>,
pub sid: Option<String>,
}
pub async fn engine_get(
req: HttpRequest,
body: web::Payload,
query: web::Query<EngineQuery>,
store: web::Data<SessionStore>,
config: web::Data<EngineConfig>,
on_message: web::Data<Arc<dyn Fn(String, Packet) + Send + Sync>>,
) -> Result<HttpResponse, actix_web::Error> {
match query.transport.as_deref() {
Some("websocket") => {
crate::engine::websocket::websocket_handler(
req,
body,
web::Query(crate::engine::websocket::WsQuery {
eio: query.eio.clone(),
transport: query.transport.clone(),
sid: query.sid.clone(),
}),
store,
config,
on_message,
)
.await
}
_ => Ok(crate::engine::polling::polling_get(
req,
web::Query(crate::engine::polling::PollingQuery {
eio: query.eio.clone(),
transport: query.transport.clone(),
sid: query.sid.clone(),
}),
store,
config,
on_message,
)
.await),
}
}
impl EngineServer {
pub fn new(
config: EngineConfig,
@@ -76,17 +123,14 @@ impl EngineServer {
.app_data(web::Data::new(config.clone()))
.app_data(web::Data::new(on_message.clone()))
.route(
"/engine.io/",
web::get().to(crate::engine::polling::polling_get),
"/health",
web::get().to(crate::engine::health::health_check),
)
.route("/engine.io/", web::get().to(engine_get))
.route(
"/engine.io/",
web::post().to(crate::engine::polling::polling_post),
)
.route(
"/engine.io/",
web::get().to(crate::engine::websocket::websocket_handler),
)
})
.bind(addr)?
.run()
@@ -101,7 +145,7 @@ impl EngineServer {
port: u16,
cert_path: &str,
key_path: &str,
) -> Result<(), Box<dyn std::error::Error>> {
) -> crate::ImksResult<()> {
crate::engine::webtransport::run_webtransport_server(
port,
cert_path,