modify: rust worker
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# ====== 插件注册信息(Rust 参考插件 rsdemo) ======
|
||||
# 与 Python SDK 共用同一套 TOML 端点定义格式(docs/plugin-wire-protocol.md §2),
|
||||
# 由 chongming-worker-rs 解析并发布路由描述符。
|
||||
[workers]
|
||||
type = "rsdemo"
|
||||
module = "rsdemo" # Rust 插件无 Python 模块概念,字段保留用于记录
|
||||
factory = "create_workers"
|
||||
cleanup = "cleanup"
|
||||
count = 2
|
||||
load_mode = "external" # 独立进程运行,经 Zenoh 注册路由
|
||||
|
||||
[worker]
|
||||
name = "rsdemo"
|
||||
version = "0.1.0"
|
||||
description = "进程插件 Rust 参考实现(多语言演进规划阶段 1)"
|
||||
config_version = "1.0"
|
||||
defaults = { method = "GET", timeout = 30.0, auth_required = false, cacheable = false, internal = false }
|
||||
|
||||
[worker.registration]
|
||||
router_prefix = "/rsdemo"
|
||||
tags = ["rsdemo", "process-plugin", "rust"]
|
||||
|
||||
# ====== Worker 运行时配置(由 Rust SDK 展平后传给 handler) ======
|
||||
[workers.config]
|
||||
greeting_prefix = "Hello"
|
||||
@@ -0,0 +1,11 @@
|
||||
# rsdemo.echo —— POST 端点,演示 user_info 信封透传
|
||||
[POST]
|
||||
summary = "Rust 参考插件:回声(透传网关认证用户信息)"
|
||||
params = ["msg: str"]
|
||||
auth_required = true
|
||||
|
||||
[POST.response_model]
|
||||
echo = { type = "str", required = true }
|
||||
user_info = { type = "any", required = false }
|
||||
worker_id = { type = "str", required = false, default = "" }
|
||||
timestamp = { type = "float", required = true }
|
||||
@@ -0,0 +1,5 @@
|
||||
# rsdemo.error —— 恒抛业务异常,演示非流式错误回复格式
|
||||
# ({"result":0.0,"operation":"error","error":...,"worker":...})
|
||||
[GET]
|
||||
summary = "Rust 参考插件:模拟业务异常"
|
||||
auth_required = false
|
||||
@@ -0,0 +1,10 @@
|
||||
# rsdemo.hello —— 普通 GET 端点(对位 Python demo.hello)
|
||||
[GET]
|
||||
summary = "Rust 参考插件:问候"
|
||||
params = ["name: str"]
|
||||
auth_required = false
|
||||
|
||||
[GET.response_model]
|
||||
greeting = { type = "str", required = true }
|
||||
worker_id = { type = "str", required = false, default = "" }
|
||||
timestamp = { type = "float", required = true }
|
||||
@@ -0,0 +1,13 @@
|
||||
# rsdemo.stream —— 流式端点(SSE,逐块多回复)
|
||||
[POST]
|
||||
summary = "Rust 参考插件:模拟 AI 流式输出(SSE,逐 token)"
|
||||
docstring = "流式端点:Rust handler 返回流,逐块多回复推送,网关以 text/event-stream 转发。tokens > 50 时第 26 块抛错,演示 {\"error\": ...} 收尾块。"
|
||||
auth_required = false
|
||||
stream = true
|
||||
# 流式超时模型: timeout = 流总寿命上限(zenoh query deadline)
|
||||
timeout = 300.0
|
||||
stream_idle_timeout = 10.0
|
||||
params = [
|
||||
"prompt: str",
|
||||
"tokens: int"
|
||||
]
|
||||
Reference in New Issue
Block a user