setting

package
v1.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package setting — 系统设置 KV(settings 表)读写,带进程内缓存。

timezone.go — 调度使用明确的 IANA 时区,内嵌数据保证精简镜像也可用。

Index

Constants

View Source
const (
	KeySiteName = "site.name" // 站点品牌名
	KeySiteAbbr = "site.abbr" // 站点缩写(未命名 API Key 的默认名等)

	DefaultSiteName = "ClawProxyHub"
	DefaultSiteAbbr = "CPH"
)

站点品牌(登录页 / 侧栏展示;空 = 内置默认)。

View Source
const (
	KeyLuaEnabled    = "plugin.lua_enabled"     // 是否允许安装/运行 lua 插件(默认开)
	KeyLuaIsolation  = "plugin.lua_isolation"   // lua 运行态隔离(默认开;本版锁定为开)
	KeyLuaUpdateMode = "plugin.lua_update_mode" // luahost 更新方式:manual / online
)

插件(lua 运行时)设置。

View Source
const DefaultMarketplaceURL = "https://raw.githubusercontent.com/ShadowSmallBaby/ClawProxyHubPlugins/main/index.json"

DefaultMarketplaceURL 官方插件市场索引地址(初始化时写入设置)。

View Source
const DefaultTaskDailyJitter = 30

DefaultTaskDailyJitter daily 抖动默认窗口(分钟)。

View Source
const DefaultTimezone = "Asia/Shanghai"
View Source
const KeyBrowserUserAgent = "gateway.browser_user_agent"

KeyBrowserUserAgent 全局浏览器 UA(供插件登录 / 管理面等浏览器形态请求;空 = 插件用内置值)。

View Source
const KeyContextBytesPerToken = "gateway.context_bytes_per_token"

KeyContextBytesPerToken token 粗估系数:字节数 / 该值 ≈ token 数。

View Source
const KeyContextTruncateEnabled = "gateway.context_truncate_enabled"

KeyContextTruncateEnabled 输入超窗自动截断总开关(默认开)。

View Source
const KeyContextTruncateRatio = "gateway.context_truncate_ratio"

KeyContextTruncateRatio 触发截断的窗口占用阈值比例(估算 token / context_window 超过即截)。

View Source
const KeyFirstEventTimeout = "gateway.first_event_timeout"

KeyFirstEventTimeout 网关首帧超时(秒):等待上游第一个事件的上限(探测上游/代理挂死)。

View Source
const KeyFirstTokenTimeout = "gateway.first_token_timeout"

KeyFirstTokenTimeout 网关首字超时(秒):首事件 → 首个内容 token 的上限(容纳推理思考)。

View Source
const KeyGatewayUserAgent = "gateway.user_agent"

KeyGatewayUserAgent 网关全局 UA(对话请求;空 = 透传客户端 UA;路由级可覆盖)。

View Source
const KeyGitHubProxy = "network.github_proxy"

KeyGitHubProxy GitHub 代理前缀(ghproxy 风格,加速插件市场访问;空 = 直连)。

View Source
const KeyLogRetentionDays = "logs.retention_days"

KeyLogRetentionDays 调用日志保留天数(0 = 永久,不清理)。

View Source
const KeyMarketplaceURL = "network.marketplace_url"

KeyMarketplaceURL 旧版单一市场地址(v1.1 起改为 KeyPluginSources 源列表;仅用于首次迁移导入)。

View Source
const KeyMaxRetries = "gateway.max_retries"

KeyMaxRetries 单次请求的总上游尝试次数上限(含首发;恢复/降级共用此硬上限)。

View Source
const KeyPluginSources = "network.plugin_sources"

KeyPluginSources 插件源列表(JSON 数组,见 PluginSource)。

View Source
const KeyRunLevel = "logs.run_level"

KeyRunLevel 运行日志记录级别(error/warn/debug/info,递增包含;默认 error)。

View Source
const KeyTaskDailyJitter = "task.daily_jitter_minutes"

KeyTaskDailyJitter daily 任务触发的最大随机抖动分钟数(错开多账号同刻打上游;0 = 关闭偏移)。

View Source
const KeyTimezone = "system.timezone"
View Source
const OfficialSourceName = "official"

OfficialSourceName 官方源名:该源的插件安装在插件根目录,其他源按源名建命名空间目录。

Variables

This section is empty.

Functions

func ValidateTimezone added in v1.5.2

func ValidateTimezone(name string) error

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 New

func New(db *gorm.DB) *Store

func (*Store) BrowserUserAgent added in v1.1.0

func (s *Store) BrowserUserAgent() string

BrowserUserAgent 全局浏览器 UA(空 = 插件用内置值)。

func (*Store) ContextBytesPerToken added in v1.2.0

func (s *Store) ContextBytesPerToken() float64

ContextBytesPerToken token 粗估系数;非法或过小回退默认。

func (*Store) ContextTruncateEnabled added in v1.2.0

func (s *Store) ContextTruncateEnabled() bool

ContextTruncateEnabled 输入超窗自动截断开关;缺省开。

func (*Store) ContextTruncateRatio added in v1.2.0

func (s *Store) ContextTruncateRatio() float64

ContextTruncateRatio 截断触发比例;非法或越界回退默认,限定 (0,1]。

func (*Store) DailyJitter added in v1.1.5

func (s *Store) DailyJitter() time.Duration

DailyJitter daily 任务触发的最大随机抖动窗口;空/非法回退默认,0 = 关闭偏移。

func (*Store) EnsureDefault

func (s *Store) EnsureDefault(key, def string)

EnsureDefault key 尚未写入时落默认值(仅初始化场景使用,不覆盖已有配置)。

func (*Store) EnsurePluginSources added in v1.1.0

func (s *Store) EnsurePluginSources(officialURL string)

EnsurePluginSources 首次迁移:源列表缺失时用官方地址(config 默认)建 official 源; 旧版 marketplace_url 若为用户自建地址,一并导入为 custom 源。

func (*Store) FirstEventTimeout

func (s *Store) FirstEventTimeout() time.Duration

FirstEventTimeout 网关首帧超时;非法值回退默认。

func (*Store) FirstTokenTimeout added in v1.2.0

func (s *Store) FirstTokenTimeout() time.Duration

FirstTokenTimeout 网关首字超时;非法值回退默认。

func (*Store) GatewayUserAgent added in v1.1.0

func (s *Store) GatewayUserAgent() string

GatewayUserAgent 网关全局 UA(空 = 透传客户端)。

func (*Store) Get

func (s *Store) Get(key, def string) string

Get 读设置,缺省返回 def。

func (*Store) GitHubProxy

func (s *Store) GitHubProxy() string

GitHubProxy GitHub 代理前缀(以 / 结尾与否均可;空 = 直连)。

func (*Store) Location added in v1.5.2

func (s *Store) Location() *time.Location

func (*Store) LogRetentionDays added in v1.1.0

func (s *Store) LogRetentionDays() int

LogRetentionDays 日志保留天数;非法值按永久(0)。

func (*Store) LuaEnabled added in v1.2.0

func (s *Store) LuaEnabled() bool

LuaEnabled 是否允许安装/运行 lua 插件;缺省开。

func (*Store) LuaIsolation added in v1.2.0

func (s *Store) LuaIsolation() bool

LuaIsolation lua 运行态隔离(每插件一份运行态);缺省开。本版锁定为开,仅持久化+展示。

func (*Store) LuaUpdateMode added in v1.2.0

func (s *Store) LuaUpdateMode() string

LuaUpdateMode luahost 更新方式:manual(手动上传)/ online(在线,占位);非法回退 manual。

func (*Store) MaxRetries added in v1.2.0

func (s *Store) MaxRetries() int

MaxRetries 单次请求总上游尝试次数上限;非法值回退默认,下限 1。

func (*Store) PluginSources added in v1.1.0

func (s *Store) PluginSources() []PluginSource

PluginSources 插件源列表(解析失败返回空)。

func (*Store) RetentionDays added in v1.5.2

func (s *Store) RetentionDays(key string) int

RetentionDays 运行和任务日志使用独立保留期,默认 30 天;0 表示永久。

func (*Store) RunLevel added in v1.1.5

func (s *Store) RunLevel() string

RunLevel 运行日志记录级别;非法值回退 error。

func (*Store) Set

func (s *Store) Set(key, value string) error

Set 写成功后才更新缓存。

func (*Store) SetMany added in v1.5.2

func (s *Store) SetMany(values map[string]string) error

SetMany 原子保存一组设置,失败时缓存与数据库均不变。

func (*Store) SetPluginSources added in v1.1.0

func (s *Store) SetPluginSources(list []PluginSource)

SetPluginSources 写插件源列表。

func (*Store) SiteAbbr added in v1.1.0

func (s *Store) SiteAbbr() string

SiteAbbr 站点缩写(空回退默认)。

func (s *Store) SiteLogo() string

SiteLogo 自定义 logo data URL(空 = 用内置)。

func (*Store) SiteName added in v1.1.0

func (s *Store) SiteName() string

SiteName 站点品牌名(空回退默认)。

func (*Store) Timezone added in v1.5.2

func (s *Store) Timezone() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL