# 05-chat **Repository Path**: czlan91/05-chat ## Basic Information - **Project Name**: 05-chat - **Description**: rust 第五周 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-05-30 - **Last Updated**: 2024-07-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Geektime Rust 语言训练营 rust 第五周 ## 作业 1. utoipa 剩下的代码支持, multipart 无法实现 swagger-ui 2. notify-serverbug:如果用户退出SSE 连接,Dashmap 里还有这个用户的sender(已经不能工作), 请帮忙fix- 如果用户退出,则删除Dashmap 里对应的 entry 1. 在前端调用 close的 时候,调用后端接口,删除 该user的 tx。 2. 只有在发送的时候,判断channel 是否关闭了,如果关闭了,就删除user的tx。 3. chat service 里未完成的API,请帮忙完成 4. 拓展notify service,使其能够通知: a) chat name update, 只有 members 改变的时候,才会通知。 5.本周涉及到的所有的第三方crate,请至少完成阅读其文档和 examples. ## 安装 sqlx-cli ```shell cargo install sqlx-cli --no-default-features --features postgres --features rustls ``` 创建 initial 文件 ```shell sqlx migrate add initial ``` 创建.env ```shell cat .env DATABASE_URL=postgres://postgres:postgres@localhost/chat ``` 运行 migrate, 会自动执行 migrate目录下的所有sql文件,根据时间大小 ```shell sqlx migrate run ``` ## wsl上使用 ```shell sudo apt-get -y install gcc sudo apt-get -y install cmake sudo apt-get -y install g++ sudo apt-get -y install libclang-dev ``` ## utoipa 编写步骤 1. 修改openapi.rS 2. 在相应接口上 配置 `#[utoipa::path(...)]` 3. 参数上有struct 的话,struct 需要实现 IntoParams 4. 所有在 openapi.rs中定义的 model ,都需要实现 ToSchema