add README.md 文档
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# chongming-worker
|
||||
|
||||
通用 Worker 框架,提供 Zenoh RPC 端点的装饰器定义、生命周期管理和配置解析。
|
||||
|
||||
## 功能
|
||||
|
||||
- `@rpc_method` 装饰器:将普通函数注册为 Zenoh Queryable 端点
|
||||
- 自动参数解析与 Pydantic 模型绑定(支持 `gen_models` 生成的模型)
|
||||
- 运行时 `create_worker` / `create_workers` 工厂函数
|
||||
- 配置加载:`load_worker_config` 读取 `config/workers/<name>/*.toml`
|
||||
|
||||
## 使用示例
|
||||
|
||||
```python
|
||||
from chongming_worker import rpc_method
|
||||
from .models.pydantic import AddGetRequest, AddGetResponse
|
||||
|
||||
@rpc_method(subject="example.add", method="GET", response_model=AddGetResponse)
|
||||
async def add(req: AddGetRequest) -> AddGetResponse:
|
||||
return AddGetResponse(result=req.a + req.b)
|
||||
```
|
||||
|
||||
## 工厂函数
|
||||
|
||||
插件需提供 `create_workers(session, config, count, worker_manager)` 异步函数,返回任务列表。
|
||||
|
||||
Reference in New Issue
Block a user