Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

配置参考

ScootGate 使用 TOML 配置,并对所有结构启用未知字段拒绝。拼写错误、未知引用、 非法 URL 或越界参数会使进程启动失败,不会静默采用近似配置。

完整可运行结构:

顶层

字段必填说明
instance_id节点稳定标识,不能为空
server客户端 API listener
health独立健康 listener
auth授权快照控制面
egress唯一 Provider 出口代理
apiAPI 大小与超时边界
routing负载与熔断参数
routing_sourcestaticsnapshot
credentials视模式Provider 凭据引用
backends / modelsstatic 必填本地路由数据
usage非权威磁盘 outbox
mqtt用量和快照通知
shutdown有界停机
logJSON 日志级别

[server][server.tls]

字段默认值约束
listen必填 IP:port
max_concurrent_requests10241..=16384
request_head_timeout_ms50001..=60000,同时约束 TLS 握手
tls.certPEM 证书链路径
tls.keyPEM 私钥路径

生产 API listener 必须配置 TLS。未配置时为明文开发模式。

[health]

字段默认值约束
listen127.0.0.1:9091必须与 API listener 不同
max_concurrent_requests641..=16384
request_head_timeout_ms50001..=60000

[auth]

字段默认值说明
snapshot_url必填完整 URL;ScootGate 追加 since
token必填控制面 Bearer token
cache_path./data/scootgate-auth-snapshot.json摘要快照缓存
poll_interval_secs30必须大于 0

配置文件包含 auth.token,生产应由 secret manager 渲染到 0600 文件。

[egress]

字段默认值说明
kindhttp_connectsocks5
addr必填 host:port
username必填专用服务账号
password必填密码
tlsfalse是否验证 TLS 并加密到代理
connect_timeout_ms100001..=60000

没有“direct”类型,也没有代理失败后的直连回落。

[api]

字段默认值约束
max_request_body_bytes10485761..=67108864
response_head_timeout_ms300001..=300000;选择、连接、TLS、写入和响应头共享
stream_idle_timeout_ms3000001..=3600000

[routing]

字段默认值约束
max_pre_send_attempts21..=2;包含首次尝试

[routing.load_balancing]

字段默认值约束
algorithmweighted_p2cweighted_p2cweighted_random
ewma_alpha0.2(0, 1]
initial_first_byte_ms10001..=600000
slow_start_secs300..=3600

[routing.circuit_breaker]

字段默认值约束
failure_threshold31..=1000
failure_window_secs301..=3600
cooldown_secs301..=3600
half_open_max_requests1固定为 1
throttle_cooldown_secs100..=3600

[routing_source]

默认:

[routing_source]
mode = "static"

Snapshot 模式字段:

字段默认值说明
modestatic设为 snapshot
snapshot_urlsnapshot 模式必填
token_env保存控制面 token 的环境变量名
cache_path./data/scootgate-routing-snapshot.json最后有效快照
poll_interval_secs30大于 0
max_stale_secs300不小于 poll interval

Static 模式禁止设置 snapshot_url / token_env;snapshot 模式禁止本地 [backends] / [models]

[credentials.<id>]

每项必须且只能设置一个来源:

[credentials.provider-a]
env = "PROVIDER_A_API_KEY"

或:

[credentials.provider-a]
file = "/run/secrets/provider-a-api-key"

环境变量缺失、文件不可读或值为空会启动失败。secret 不会序列化到路由快照。

[backends.<id>]

字段默认值说明
protocolopenai_compatibleanthropic_messages
upstream只有 scheme/host/port 的 origin
credential_ref必须引用本地 credential
max_inflight_per_node641..=65536
enabledtrue是否参与选择

生产 upstream 必须为 HTTPS;HTTP 只允许 loopback。URL 不得包含 path、 query、fragment、userinfo 或内嵌凭据。

[models.<public-name>] 与 targets

[models.chat-fast]
protocol = "openai_compatible"
enabled = true

[[models.chat-fast.targets]]
backend = "provider-a"
model = "real-model-a"
weight = 100
supports_stream = true
supports_tools = true
supports_json_schema = true
target 字段默认值说明
backend必须存在且协议匹配
model转发时写入的真实模型名
weight1001..=1000000
supports_streamtrue是否支持流式响应
supports_toolstrue是否支持 tools
supports_json_schematrue是否支持 JSON schema

所有 ID 长度为 1..=128,字符限于 A-Z a-z 0-9 . _ : -

[usage]

字段默认值约束
schema2固定 2
deliverymqtt_outbox固定值
authoritativefalse固定 false
outbox_path./data/usage-outbox非空持久目录
max_outbox_bytes1073741824大于 0
flush_interval_ms5001..=60000
on_fulldrop_newest固定值

[mqtt]

字段默认值说明
broker必填,无 path
username可选;设置 password 时必须非空
password可选
topic_prefixscootgate不允许通配符或空白
client_idscootgate-{instance_id}可覆盖
queue_capacity1024大于 0

Broker scheme 支持 mqtt / tcp(默认端口 1883)与 mqtts / ssl / tls / tcps(默认端口 8883)。

[shutdown][log]

字段默认值说明
shutdown.grace_period_secs30必须大于 0
log.levelinfotracing filter level

日志为 JSON。若设置 RUST_LOG,它会覆盖由 log.level 构造的默认过滤器。