You've already forked agentic-coding-workflow
feat(config,workspace,user): jobs/notify config + workspace fetch repo + user ListAdmins
This commit is contained in:
@@ -39,6 +39,8 @@ type Config struct {
|
||||
Git Git `mapstructure:"git"`
|
||||
Chat Chat `mapstructure:"chat"`
|
||||
Storage Storage `mapstructure:"storage"`
|
||||
Jobs JobsConfig `mapstructure:"jobs"`
|
||||
Notify NotifyConfig `mapstructure:"notify"`
|
||||
}
|
||||
|
||||
// HTTPConfig 描述 HTTP 服务监听参数。
|
||||
@@ -107,6 +109,62 @@ type StorageLocalFS struct {
|
||||
BasePath string `mapstructure:"base_path"`
|
||||
}
|
||||
|
||||
// JobsConfig 控制后台 job runner 的总开关、worker 池与各定时任务参数。
|
||||
type JobsConfig struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Workers int `mapstructure:"workers"`
|
||||
ShutdownGrace time.Duration `mapstructure:"shutdown_grace"`
|
||||
WorkspaceFetch RunnerCfg `mapstructure:"workspace_fetch"`
|
||||
WorktreePrune WorktreePruneCfg `mapstructure:"worktree_prune"`
|
||||
AttachmentCleanup AttachmentCleanupCfg `mapstructure:"attachment_cleanup"`
|
||||
JobReaper JobReaperCfg `mapstructure:"job_reaper"`
|
||||
JobPurge JobPurgeCfg `mapstructure:"job_purge"`
|
||||
}
|
||||
|
||||
type RunnerCfg struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Interval time.Duration `mapstructure:"interval"`
|
||||
}
|
||||
|
||||
type WorktreePruneCfg struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Interval time.Duration `mapstructure:"interval"`
|
||||
IdleThreshold time.Duration `mapstructure:"idle_threshold"`
|
||||
WarningLead time.Duration `mapstructure:"warning_lead"`
|
||||
}
|
||||
|
||||
type AttachmentCleanupCfg struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Interval time.Duration `mapstructure:"interval"`
|
||||
Retention time.Duration `mapstructure:"retention"`
|
||||
}
|
||||
|
||||
type JobReaperCfg struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Interval time.Duration `mapstructure:"interval"`
|
||||
LeaseTimeout time.Duration `mapstructure:"lease_timeout"`
|
||||
}
|
||||
|
||||
type JobPurgeCfg struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Interval time.Duration `mapstructure:"interval"`
|
||||
CompletedRetention time.Duration `mapstructure:"completed_retention"`
|
||||
}
|
||||
|
||||
// NotifyConfig 是 notify 模块的可选外发通道配置。当前仅 webhook。
|
||||
type NotifyConfig struct {
|
||||
Webhook WebhookCfg `mapstructure:"webhook"`
|
||||
}
|
||||
|
||||
// WebhookCfg 是 webhook 通道的配置。enabled=false 时上层 dispatcher 仍会丢弃所有 webhook 消息。
|
||||
type WebhookCfg struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
URL string `mapstructure:"url"`
|
||||
Secret string `mapstructure:"secret"`
|
||||
Timeout time.Duration `mapstructure:"timeout"`
|
||||
Topics []string `mapstructure:"topics"`
|
||||
}
|
||||
|
||||
// Load 从(按优先级递增)默认值 → 配置文件(如有)→ 环境变量 加载配置。
|
||||
// configFile 可为空字符串,仅用环境变量。
|
||||
func Load(configFile string) (*Config, error) {
|
||||
@@ -132,6 +190,26 @@ func Load(configFile string) (*Config, error) {
|
||||
v.SetDefault("chat.history.safety_margin_pct", 5.0)
|
||||
v.SetDefault("storage.driver", "localfs")
|
||||
v.SetDefault("storage.localfs.base_path", "./data/uploads")
|
||||
v.SetDefault("jobs.enabled", true)
|
||||
v.SetDefault("jobs.workers", 2)
|
||||
v.SetDefault("jobs.shutdown_grace", "30s")
|
||||
v.SetDefault("jobs.workspace_fetch.enabled", true)
|
||||
v.SetDefault("jobs.workspace_fetch.interval", "5m")
|
||||
v.SetDefault("jobs.worktree_prune.enabled", true)
|
||||
v.SetDefault("jobs.worktree_prune.interval", "24h")
|
||||
v.SetDefault("jobs.worktree_prune.idle_threshold", "720h")
|
||||
v.SetDefault("jobs.worktree_prune.warning_lead", "72h")
|
||||
v.SetDefault("jobs.attachment_cleanup.enabled", true)
|
||||
v.SetDefault("jobs.attachment_cleanup.interval", "24h")
|
||||
v.SetDefault("jobs.attachment_cleanup.retention", "720h")
|
||||
v.SetDefault("jobs.job_reaper.enabled", true)
|
||||
v.SetDefault("jobs.job_reaper.interval", "1m")
|
||||
v.SetDefault("jobs.job_reaper.lease_timeout", "5m")
|
||||
v.SetDefault("jobs.job_purge.enabled", true)
|
||||
v.SetDefault("jobs.job_purge.interval", "24h")
|
||||
v.SetDefault("jobs.job_purge.completed_retention", "168h")
|
||||
v.SetDefault("notify.webhook.enabled", false)
|
||||
v.SetDefault("notify.webhook.timeout", "10s")
|
||||
|
||||
if configFile != "" {
|
||||
v.SetConfigFile(configFile)
|
||||
|
||||
Reference in New Issue
Block a user