DCTS/crates/mq/README.md

27 lines
818 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# mq
> 基于 SQLite 构建的高可靠并发分布式任务队列引擎。
---
## 📦 模块概览
`mq` 为 DCTS 提供轻量级且具备强一致性保证的任务队列服务。
- **`sqlite_queue.rs`**`SqliteTaskQueue` 结构体,实现基于 SQLite 事务的任务 Push、Claim、Report、Stale Requeue 以及清理重试。
### 特性亮点
1. **原子 Claim 事务**:保证并发 Claim 时单任务仅被成功分配给一个 Worker。
2. **超时自动重派 (Requeue)**:在设定秒数内未汇报结果的任务会被自动放回队列重新为 `pending`
3. **WAL 高并发模式**:支持多连接并发读写而不阻塞写事务。
---
## 🛠️ Usage & Setup
### 单元测试
```bash
cargo test -p mq
```
测试包含并发 Claim 竞态检验与超时自动 Requeue 逻辑校验。