Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ideal-world/bios
Browse files Browse the repository at this point in the history
  • Loading branch information
gudaoxuri committed Apr 26, 2024
2 parents a578704 + 2d2cfeb commit 732bf23
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/middlewares/event/src/api/event_listener_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ 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<EventListenerRegisterReq>) -> TardisApiResult<EventListenerRegisterResp> {
let funs = get_tardis_inst();
let resp = event_listener_serv::register(listener.0, &funs).await?;
TardisResp::ok(resp)
}

/// Remove event listener
/// 移除事件监听器
#[oai(path = "/:listener_code", method = "delete")]
async fn remove(&self, listener_code: Path<String>, token: Query<String>) -> TardisApiResult<Void> {
let funs = get_tardis_inst();
Expand Down
4 changes: 4 additions & 0 deletions backend/middlewares/event/src/api/event_proc_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, token: Query<String>, websocket: WebSocket) -> BoxWebSocketUpgraded {
let funs = get_tardis_inst();
Expand Down
5 changes: 5 additions & 0 deletions backend/middlewares/event/src/api/event_topic_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<EventTopicAddOrModifyReq>, ctx: TardisContextExtractor) -> TardisApiResult<String> {
let funs = get_tardis_inst();
Expand All @@ -24,6 +26,7 @@ impl EventTopicApi {
}

/// Modify Event Definition
/// 修改事件主题
#[oai(path = "/:id", method = "put")]
async fn modify(&self, id: Path<String>, mut add_or_modify_req: Json<EventTopicAddOrModifyReq>, ctx: TardisContextExtractor) -> TardisApiResult<Void> {
let funs = get_tardis_inst();
Expand All @@ -32,6 +35,7 @@ impl EventTopicApi {
}

/// Delete Event Definition
/// 删除事件主题
#[oai(path = "/:id", method = "delete")]
async fn delete(&self, id: Path<String>, ctx: TardisContextExtractor) -> TardisApiResult<Void> {
let funs = get_tardis_inst();
Expand All @@ -40,6 +44,7 @@ impl EventTopicApi {
}

/// Find Event Definitions
/// 查找事件主题
#[oai(path = "/", method = "get")]
async fn paginate(
&self,
Expand Down
10 changes: 10 additions & 0 deletions backend/middlewares/event/src/domain/event_topic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 732bf23

Please sign in to comment.