Skip to content

Commit db91cc9

Browse files
authored
[ISSUE #5895]📝Update overview.md with contributing guidelines in Chinese, enhancing clarity for new contributors (#5896)
1 parent 5af8217 commit db91cc9

File tree

1 file changed

+311
-3
lines changed
  • rocketmq-website/i18n/zh-CN/docusaurus-plugin-content-docs/current/contributing

1 file changed

+311
-3
lines changed
Lines changed: 311 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,316 @@
11
---
2-
title: Contributing
32
sidebar_position: 1
3+
title: 概述
44
---
55

6-
# Contributing
6+
# 贡献指南概述
77

8-
此页面正在翻译中...
8+
欢迎来到 RocketMQ-Rust 社区!🎉
9+
10+
感谢你对 RocketMQ-Rust 项目的贡献兴趣。无论是修复 bug、添加新功能还是改进文档,每一个贡献都很重要。本指南将帮助你开始贡献之旅。
11+
12+
## 贡献方式
13+
14+
有很多种方式可以为 RocketMQ-Rust 做出贡献:
15+
16+
### 代码贡献
17+
18+
- **Bug 修复**:修复已报告的问题
19+
- **新功能**:添加新功能
20+
- **性能改进**:优化现有代码
21+
- **文档**:改进代码文档
22+
- **测试**:添加单元测试和集成测试
23+
24+
### 非代码贡献
25+
26+
- **Bug 报告**:报告 bug 和问题
27+
- **功能请求**:建议新功能
28+
- **文档**:改进用户文档
29+
- **代码审查**:审查拉取请求
30+
- **社区支持**:帮助其他用户
31+
32+
## 开始贡献
33+
34+
### 1. Fork 和克隆
35+
36+
```bash
37+
# 在 GitHub 上 Fork 仓库
38+
# 克隆你的 fork
39+
git clone https://github.com/YOUR_USERNAME/rocketmq-rust.git
40+
cd rocketmq-rust
41+
42+
# 添加 upstream 远程仓库
43+
git remote add upstream https://github.com/mxsm/rocketmq-rust.git
44+
```
45+
46+
### 2. 设置开发环境
47+
48+
```bash
49+
# 安装 Rust nightly 工具链
50+
rustup toolchain install nightly
51+
rustup default nightly
52+
53+
# 安装开发工具
54+
rustup component add rustfmt clippy
55+
56+
# 构建项目
57+
cargo build
58+
```
59+
60+
### 3. 创建分支
61+
62+
```bash
63+
# 与 upstream 同步
64+
git fetch upstream
65+
git checkout main
66+
git merge upstream/main
67+
68+
# 创建功能分支
69+
git checkout -b feature/your-feature-name
70+
```
71+
72+
## 开发工作流
73+
74+
### 进行更改
75+
76+
1. **编写代码**:遵循编码标准
77+
2. **添加测试**:确保测试覆盖率
78+
3. **格式化代码**:使用 rustfmt
79+
```bash
80+
cargo fmt
81+
```
82+
4. **运行 linter**:使用 clippy
83+
```bash
84+
cargo clippy -- -D warnings
85+
```
86+
5. **运行测试**:确保所有测试通过
87+
```bash
88+
cargo test --all
89+
```
90+
91+
### 提交更改
92+
93+
使用清晰的提交信息:
94+
95+
```
96+
feat: 添加事务消息支持
97+
98+
- 实现 TransactionProducer
99+
- 添加事务监听器 trait
100+
- 为事务消息添加单元测试
101+
102+
Closes #123
103+
```
104+
105+
提交信息格式:
106+
- `feat:` 新功能
107+
- `fix:` Bug 修复
108+
- `docs:` 文档更改
109+
- `test:` 测试更改
110+
- `refactor:` 代码重构
111+
- `perf:` 性能改进
112+
- `chore:` 构建过程或工具
113+
114+
### 提交拉取请求
115+
116+
1. **推送到你的 fork**
117+
```bash
118+
git push origin feature/your-feature-name
119+
```
120+
121+
2. **创建拉取请求**:在 GitHub 上
122+
123+
3. **填写 PR 模板**
124+
- 描述你的更改
125+
- 引用相关问题
126+
- 如果适用,添加截图
127+
128+
4. **等待审查**:维护者将审查你的 PR
129+
130+
## 代码审查流程
131+
132+
### 预期情况
133+
134+
我们的审查流程旨在保持代码质量,同时对贡献者友好:
135+
136+
1. **自动检查**(1-5 分钟):CI 运行测试、linting 和格式检查
137+
2. **人工审查**(1-3 天):维护者审查你的代码质量和设计
138+
3. **反馈讨论**:协作讨论以改进代码
139+
4. **批准和合并**:一旦批准,你的 PR 将被合并!🎉
140+
141+
### 处理反馈
142+
143+
代码审查是对话,而非批评。当你收到反馈时:
144+
145+
- 回应所有审查意见(即使是确认收到)
146+
- 如果有不清楚的地方,请提问
147+
- 做出请求的更改并推送到同一分支
148+
- 准备好后请求重新审查
149+
- 不要犹豫讨论替代方案
150+
151+
**注意**:CodeRabbit 的建议是有帮助的参考,但最终决定由维护者在代码审查期间做出。
152+
153+
## 编码标准
154+
155+
详见 [编码标准](./coding-standards) 获取详细指南。
156+
157+
### 核心原则
158+
159+
1. **遵循 Rust 惯用语**:编写地道的 Rust 代码
160+
2. **错误处理**:正确使用 `Result` 类型
161+
3. **文档**:为公共 API 添加文档注释
162+
4. **测试**:编写全面的测试
163+
5. **性能**:考虑性能影响
164+
165+
### 示例
166+
167+
```rust
168+
//! 向 RocketMQ broker 发送消息的生产者模块。
169+
170+
use crate::error::{Error, Result};
171+
use crate::model::Message;
172+
173+
/// 用于发送消息的 RocketMQ 生产者。
174+
///
175+
/// # 示例
176+
///
177+
/// ```rust
178+
/// use rocketmq::producer::Producer;
179+
///
180+
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
181+
/// let producer = Producer::new();
182+
/// producer.start().await?;
183+
/// # Ok(())
184+
/// # }
185+
/// ```
186+
pub struct Producer {
187+
// 实现
188+
}
189+
190+
impl Producer {
191+
/// 创建新的生产者实例。
192+
pub fn new() -> Self {
193+
Self { /* ... */ }
194+
}
195+
196+
/// 向 broker 发送消息。
197+
///
198+
/// # 错误
199+
///
200+
/// 以下情况将返回错误:
201+
/// - broker 不可用
202+
/// - 消息超过最大大小
203+
/// - 发生网络超时
204+
pub async fn send(&self, message: Message) -> Result<SendResult> {
205+
// 实现
206+
}
207+
}
208+
```
209+
210+
## 开发指南
211+
212+
详见 [开发指南](./development-guide) 获取详细信息。
213+
214+
## 测试
215+
216+
### 运行测试
217+
218+
```bash
219+
# 运行所有测试
220+
cargo test --all
221+
222+
# 运行特定测试
223+
cargo test test_send_message
224+
225+
# 带输出运行测试
226+
cargo test -- --nocapture
227+
228+
# 并行运行测试
229+
cargo test --all -- --test-threads=4
230+
```
231+
232+
### 编写测试
233+
234+
```rust
235+
#[cfg(test)]
236+
mod tests {
237+
use super::*;
238+
239+
#[tokio::test]
240+
async fn test_send_message() {
241+
let producer = Producer::new();
242+
producer.start().await.unwrap();
243+
244+
let message = Message::new("TestTopic".to_string(), b"Test".to_vec());
245+
let result = producer.send(message).await;
246+
247+
assert!(result.is_ok());
248+
}
249+
}
250+
```
251+
252+
## 文档
253+
254+
### 构建文档
255+
256+
```bash
257+
# 构建文档
258+
cargo doc --no-deps --open
259+
```
260+
261+
### 编写文档
262+
263+
```rust
264+
/// 简要说明(一句话)
265+
///
266+
/// 更详细的解释。
267+
///
268+
/// # 示例
269+
///
270+
/// ```
271+
/// use rocketmq::producer::Producer;
272+
///
273+
/// let producer = Producer::new();
274+
/// ```
275+
///
276+
/// # 错误
277+
///
278+
/// 以下情况此函数将返回错误...
279+
///
280+
/// # Panics
281+
///
282+
/// 以下情况此函数将 panic...
283+
pub fn public_function() -> Result<()> {
284+
// 实现
285+
}
286+
```
287+
288+
## 获取帮助
289+
290+
我们随时提供帮助!请通过以下方式联系:
291+
292+
- **GitHub Issues**[报告 bug 或请求功能](https://github.com/mxsm/rocketmq-rust/issues)
293+
- **GitHub Discussions**[提问和分享想法](https://github.com/mxsm/rocketmq-rust/discussions)
294+
- **邮件**[mxsm@apache.org](mailto:mxsm@apache.org)
295+
296+
## 许可证
297+
298+
RocketMQ-Rust 采用 [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) 许可。通过贡献,你同意你的贡献将使用相同的许可证。
299+
300+
## 行为准则
301+
302+
我们致力于为每个人提供一个友好和包容的环境。请:
303+
304+
- 在交流中保持尊重和体贴
305+
- 欢迎新来者并帮助他们入门
306+
- 专注于建设性反馈
307+
- 假设良好的意图
308+
- 开放协作并分享知识
309+
310+
我们都在这里一起构建优秀的软件!🚀
311+
312+
## 后续步骤
313+
314+
- [开发指南](./development-guide) - 详细的开发信息
315+
- [编码标准](./coding-standards) - 代码风格指南
316+
- [报告问题](https://github.com/mxsm/rocketmq-rust/issues) - 提交 bug 或功能请求

0 commit comments

Comments
 (0)