cocoon/cocoon.json
xfy911 dc765854a1 feat(proxy): 平滑加权轮询负载均衡
- proxy.h: 后端添加 weight / current_weight 字段
- proxy.c: 实现平滑加权轮询算法(Nginx SWW),按权重比例分配请求
- proxy.c: 健康后端优先选择, unhealthy fallback 机制保留
- config.c: JSON 解析器新增 weight 字段解析
- cocoon.h: 代理配置结构添加 weight 字段
- server.c: 加载代理规则时传入 weight
- cocoon.json: 示例配置展示多后端权重 3:1
- tests: 新增加权轮询集成测试(3项),验证配置加载与多后端分布
- 142 单元测试 + 93 集成测试全部通过
- 编译零警告
2026-06-09 06:07:06 +08:00

19 lines
581 B
JSON

{
"root_dir": "./examples/www",
"port": 8080,
"threaded": true,
"num_workers": 4,
"max_connections": 10000,
"timeout_ms": 30000,
"log_level": "info",
"gzip_enabled": true,
"brotli_enabled": true,
"plugins": ["plugins/hello.so"],
"access_log": "-",
"proxies": [
{"prefix": "/api", "target": "http://localhost:3000", "pool_size": 8, "weight": 3},
{"prefix": "/api", "target": "http://localhost:3001", "weight": 1},
{"prefix": "/backend", "target": "https://localhost:8443", "pool_size": 4, "weight": 1}
]
}