From 2d2cfebe2e085e056ad09253e0d91721ff702300 Mon Sep 17 00:00:00 2001 From: ljl <17743125563@163.com> Date: Fri, 26 Apr 2024 14:47:48 +0800 Subject: [PATCH] event partial annotation. --- .../middlewares/event/src/api/event_listener_api.rs | 6 ++++++ backend/middlewares/event/src/api/event_proc_api.rs | 4 ++++ backend/middlewares/event/src/api/event_topic_api.rs | 5 +++++ backend/middlewares/event/src/domain/event_topic.rs | 10 ++++++++++ 4 files changed, 25 insertions(+) diff --git a/backend/middlewares/event/src/api/event_listener_api.rs b/backend/middlewares/event/src/api/event_listener_api.rs index 5c37d1210..e680af42b 100644 --- a/backend/middlewares/event/src/api/event_listener_api.rs +++ b/backend/middlewares/event/src/api/event_listener_api.rs @@ -10,8 +10,12 @@ use crate::serv::event_listener_serv; pub struct EventListenerApi; /// Event Listener API +/// 事件监听器API #[poem_openapi::OpenApi(prefix_path = "/listener")] impl EventListenerApi { + + /// Register event listener + /// 注册事件监听器 #[oai(path = "/", method = "post")] async fn register(&self, listener: Json) -> TardisApiResult { let funs = get_tardis_inst(); @@ -19,6 +23,8 @@ impl EventListenerApi { TardisResp::ok(resp) } + /// Remove event listener + /// 移除事件监听器 #[oai(path = "/:listener_code", method = "delete")] async fn remove(&self, listener_code: Path, token: Query) -> TardisApiResult { let funs = get_tardis_inst(); diff --git a/backend/middlewares/event/src/api/event_proc_api.rs b/backend/middlewares/event/src/api/event_proc_api.rs index c30d6778c..58c7aed94 100644 --- a/backend/middlewares/event/src/api/event_proc_api.rs +++ b/backend/middlewares/event/src/api/event_proc_api.rs @@ -8,8 +8,12 @@ use crate::serv::event_proc_serv; pub struct EventProcApi; /// Event Process API +/// 事件处理API #[poem_openapi::OpenApi(prefix_path = "/proc")] impl EventProcApi { + + /// Process event + /// 处理事件 #[oai(path = "/:listener_code", method = "get")] async fn ws_process(&self, listener_code: Path, token: Query, websocket: WebSocket) -> BoxWebSocketUpgraded { let funs = get_tardis_inst(); diff --git a/backend/middlewares/event/src/api/event_topic_api.rs b/backend/middlewares/event/src/api/event_topic_api.rs index b707a33d0..cb8870b4d 100644 --- a/backend/middlewares/event/src/api/event_topic_api.rs +++ b/backend/middlewares/event/src/api/event_topic_api.rs @@ -13,9 +13,11 @@ use crate::serv::event_topic_serv::EventDefServ; pub struct EventTopicApi; /// Event Topic API +/// 事件主题API #[poem_openapi::OpenApi(prefix_path = "/topic")] impl EventTopicApi { /// Add Event Definition + /// 添加事件主题 #[oai(path = "/", method = "post")] async fn add(&self, mut add_or_modify_req: Json, ctx: TardisContextExtractor) -> TardisApiResult { let funs = get_tardis_inst(); @@ -24,6 +26,7 @@ impl EventTopicApi { } /// Modify Event Definition + /// 修改事件主题 #[oai(path = "/:id", method = "put")] async fn modify(&self, id: Path, mut add_or_modify_req: Json, ctx: TardisContextExtractor) -> TardisApiResult { let funs = get_tardis_inst(); @@ -32,6 +35,7 @@ impl EventTopicApi { } /// Delete Event Definition + /// 删除事件主题 #[oai(path = "/:id", method = "delete")] async fn delete(&self, id: Path, ctx: TardisContextExtractor) -> TardisApiResult { let funs = get_tardis_inst(); @@ -40,6 +44,7 @@ impl EventTopicApi { } /// Find Event Definitions + /// 查找事件主题 #[oai(path = "/", method = "get")] async fn paginate( &self, diff --git a/backend/middlewares/event/src/domain/event_topic.rs b/backend/middlewares/event/src/domain/event_topic.rs index c40f3fcf6..63ba782ed 100644 --- a/backend/middlewares/event/src/domain/event_topic.rs +++ b/backend/middlewares/event/src/domain/event_topic.rs @@ -4,15 +4,25 @@ use tardis::db::sea_orm; use tardis::db::sea_orm::sea_query::{ColumnDef, IndexCreateStatement, Table, TableCreateStatement}; use tardis::db::sea_orm::*; +/// Event Topic model +/// 事件主题模型 #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "event_topic")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, + /// 是否保存消息 + /// Whether to save messages pub save_message: bool, + /// 是否需要管理节点 + /// Whether a management node is required pub need_mgr: bool, pub queue_size: i32, + /// 如果 need_mgr 为 false,则在注册时使用该sk + /// If need_mgr is false, this field is used when registering pub use_sk: String, + /// 如果 need_mgr 为 true,则在注册时使用该sk + /// If need_mgr is true, this field is used when registering pub mgr_sk: String, pub own_paths: String,