Documentation
¶
Overview ¶
Package setting — 系统设置 KV(settings 表)读写,带进程内缓存。
timezone.go — 调度使用明确的 IANA 时区,内嵌数据保证精简镜像也可用。
Index ¶
- Constants
- func ValidateTimezone(name string) error
- type PluginSource
- type Store
- func (s *Store) BrowserUserAgent() string
- func (s *Store) ContextBytesPerToken() float64
- func (s *Store) ContextTruncateEnabled() bool
- func (s *Store) ContextTruncateRatio() float64
- func (s *Store) DailyJitter() time.Duration
- func (s *Store) EnsureDefault(key, def string)
- func (s *Store) EnsurePluginSources(officialURL string)
- func (s *Store) FirstEventTimeout() time.Duration
- func (s *Store) FirstTokenTimeout() time.Duration
- func (s *Store) GatewayUserAgent() string
- func (s *Store) Get(key, def string) string
- func (s *Store) GitHubProxy() string
- func (s *Store) Location() *time.Location
- func (s *Store) LogRetentionDays() int
- func (s *Store) LuaEnabled() bool
- func (s *Store) LuaIsolation() bool
- func (s *Store) LuaUpdateMode() string
- func (s *Store) MaxRetries() int
- func (s *Store) PluginSources() []PluginSource
- func (s *Store) RetentionDays(key string) int
- func (s *Store) RunLevel() string
- func (s *Store) Set(key, value string) error
- func (s *Store) SetMany(values map[string]string) error
- func (s *Store) SetPluginSources(list []PluginSource)
- func (s *Store) SiteAbbr() string
- func (s *Store) SiteLogo() string
- func (s *Store) SiteName() string
- func (s *Store) Timezone() string
Constants ¶
const ( KeySiteName = "site.name" // 站点品牌名 KeySiteAbbr = "site.abbr" // 站点缩写(未命名 API Key 的默认名等) KeySiteLogo = "site.logo" // 站点 logo,data URL;空 = 内置 /logo.png DefaultSiteName = "ClawProxyHub" DefaultSiteAbbr = "CPH" )
站点品牌(登录页 / 侧栏展示;空 = 内置默认)。
const ( KeyLuaEnabled = "plugin.lua_enabled" // 是否允许安装/运行 lua 插件(默认开) KeyLuaIsolation = "plugin.lua_isolation" // lua 运行态隔离(默认开;本版锁定为开) KeyLuaUpdateMode = "plugin.lua_update_mode" // luahost 更新方式:manual / online )
插件(lua 运行时)设置。
const DefaultMarketplaceURL = "https://raw.githubusercontent.com/ShadowSmallBaby/ClawProxyHubPlugins/main/index.json"
DefaultMarketplaceURL 官方插件市场索引地址(初始化时写入设置)。
const DefaultTaskDailyJitter = 30
DefaultTaskDailyJitter daily 抖动默认窗口(分钟)。
const DefaultTimezone = "Asia/Shanghai"
const KeyBrowserUserAgent = "gateway.browser_user_agent"
KeyBrowserUserAgent 全局浏览器 UA(供插件登录 / 管理面等浏览器形态请求;空 = 插件用内置值)。
const KeyContextBytesPerToken = "gateway.context_bytes_per_token"
KeyContextBytesPerToken token 粗估系数:字节数 / 该值 ≈ token 数。
const KeyContextTruncateEnabled = "gateway.context_truncate_enabled"
KeyContextTruncateEnabled 输入超窗自动截断总开关(默认开)。
const KeyContextTruncateRatio = "gateway.context_truncate_ratio"
KeyContextTruncateRatio 触发截断的窗口占用阈值比例(估算 token / context_window 超过即截)。
const KeyFirstEventTimeout = "gateway.first_event_timeout"
KeyFirstEventTimeout 网关首帧超时(秒):等待上游第一个事件的上限(探测上游/代理挂死)。
const KeyFirstTokenTimeout = "gateway.first_token_timeout"
KeyFirstTokenTimeout 网关首字超时(秒):首事件 → 首个内容 token 的上限(容纳推理思考)。
const KeyGatewayUserAgent = "gateway.user_agent"
KeyGatewayUserAgent 网关全局 UA(对话请求;空 = 透传客户端 UA;路由级可覆盖)。
const KeyGitHubProxy = "network.github_proxy"
KeyGitHubProxy GitHub 代理前缀(ghproxy 风格,加速插件市场访问;空 = 直连)。
const KeyLogRetentionDays = "logs.retention_days"
KeyLogRetentionDays 调用日志保留天数(0 = 永久,不清理)。
const KeyMarketplaceURL = "network.marketplace_url"
KeyMarketplaceURL 旧版单一市场地址(v1.1 起改为 KeyPluginSources 源列表;仅用于首次迁移导入)。
const KeyMaxRetries = "gateway.max_retries"
KeyMaxRetries 单次请求的总上游尝试次数上限(含首发;恢复/降级共用此硬上限)。
const KeyPluginSources = "network.plugin_sources"
KeyPluginSources 插件源列表(JSON 数组,见 PluginSource)。
const KeyRunLevel = "logs.run_level"
KeyRunLevel 运行日志记录级别(error/warn/debug/info,递增包含;默认 error)。
const KeyTaskDailyJitter = "task.daily_jitter_minutes"
KeyTaskDailyJitter daily 任务触发的最大随机抖动分钟数(错开多账号同刻打上游;0 = 关闭偏移)。
const KeyTimezone = "system.timezone"
const OfficialSourceName = "official"
OfficialSourceName 官方源名:该源的插件安装在插件根目录,其他源按源名建命名空间目录。
Variables ¶
This section is empty.
Functions ¶
func ValidateTimezone ¶ added in v1.5.2
Types ¶
type PluginSource ¶ added in v1.1.0
type PluginSource struct {
Name string `json:"name"`
URL string `json:"url"`
Enabled bool `json:"enabled"`
}
PluginSource 一个插件市场源(index.json 地址)。
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store 设置存储。
func (*Store) BrowserUserAgent ¶ added in v1.1.0
BrowserUserAgent 全局浏览器 UA(空 = 插件用内置值)。
func (*Store) ContextBytesPerToken ¶ added in v1.2.0
ContextBytesPerToken token 粗估系数;非法或过小回退默认。
func (*Store) ContextTruncateEnabled ¶ added in v1.2.0
ContextTruncateEnabled 输入超窗自动截断开关;缺省开。
func (*Store) ContextTruncateRatio ¶ added in v1.2.0
ContextTruncateRatio 截断触发比例;非法或越界回退默认,限定 (0,1]。
func (*Store) DailyJitter ¶ added in v1.1.5
DailyJitter daily 任务触发的最大随机抖动窗口;空/非法回退默认,0 = 关闭偏移。
func (*Store) EnsureDefault ¶
EnsureDefault key 尚未写入时落默认值(仅初始化场景使用,不覆盖已有配置)。
func (*Store) EnsurePluginSources ¶ added in v1.1.0
EnsurePluginSources 首次迁移:源列表缺失时用官方地址(config 默认)建 official 源; 旧版 marketplace_url 若为用户自建地址,一并导入为 custom 源。
func (*Store) FirstEventTimeout ¶
FirstEventTimeout 网关首帧超时;非法值回退默认。
func (*Store) FirstTokenTimeout ¶ added in v1.2.0
FirstTokenTimeout 网关首字超时;非法值回退默认。
func (*Store) GatewayUserAgent ¶ added in v1.1.0
GatewayUserAgent 网关全局 UA(空 = 透传客户端)。
func (*Store) GitHubProxy ¶
GitHubProxy GitHub 代理前缀(以 / 结尾与否均可;空 = 直连)。
func (*Store) LogRetentionDays ¶ added in v1.1.0
LogRetentionDays 日志保留天数;非法值按永久(0)。
func (*Store) LuaEnabled ¶ added in v1.2.0
LuaEnabled 是否允许安装/运行 lua 插件;缺省开。
func (*Store) LuaIsolation ¶ added in v1.2.0
LuaIsolation lua 运行态隔离(每插件一份运行态);缺省开。本版锁定为开,仅持久化+展示。
func (*Store) LuaUpdateMode ¶ added in v1.2.0
LuaUpdateMode luahost 更新方式:manual(手动上传)/ online(在线,占位);非法回退 manual。
func (*Store) MaxRetries ¶ added in v1.2.0
MaxRetries 单次请求总上游尝试次数上限;非法值回退默认,下限 1。
func (*Store) PluginSources ¶ added in v1.1.0
func (s *Store) PluginSources() []PluginSource
PluginSources 插件源列表(解析失败返回空)。
func (*Store) RetentionDays ¶ added in v1.5.2
RetentionDays 运行和任务日志使用独立保留期,默认 30 天;0 表示永久。
func (*Store) SetPluginSources ¶ added in v1.1.0
func (s *Store) SetPluginSources(list []PluginSource)
SetPluginSources 写插件源列表。