发布管理:状态卡 + 一个主按钮,准备动作与检查项分层次收纳,去掉重复入口。 系统设置:F02 停滞阈值接入活动配置;F03 分区保存边界;F05/F06 生产绑定分层与凭据说明; F07 备份未接主机/未知证据如实显示;F09 分区独立加载与保存后重探;F10 文案精简;F11 重置密码对话框。
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@@ -561,6 +562,11 @@ func workerHandlers(store *postgresstore.Store, config appconfig.Config) (map[st
|
||||
Client: client,
|
||||
PollDelay: config.TestWeKnoraPollInitial,
|
||||
StallAfter: config.TestWeKnoraStalledAfter,
|
||||
// 页面保存的停滞阈值在这里生效;每 60 秒重读一次活动配置,
|
||||
// 读失败保留上一次值,再失败才回落到启动参数。
|
||||
StallAfterSource: func() time.Duration {
|
||||
return activeStalledAfter(context.Background(), store, config.TestWeKnoraStalledAfter)
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("create test poll handler: %w", err)
|
||||
@@ -592,3 +598,29 @@ func workerHandlers(store *postgresstore.Store, config appconfig.Config) (map[st
|
||||
handlers["test.remove"] = remove.Handle
|
||||
return handlers, nil
|
||||
}
|
||||
|
||||
// activeStalledAfter 读取活动 UI 配置里的解析停滞阈值(带 60 秒缓存)。
|
||||
// 页面保存后无需重启 worker 即可生效;“保存即生效”不是文案,而是这里的读取。
|
||||
var stalledAfterCache struct {
|
||||
mu sync.Mutex
|
||||
value time.Duration
|
||||
fetchedAt time.Time
|
||||
}
|
||||
|
||||
func activeStalledAfter(ctx context.Context, store *postgresstore.Store, fallback time.Duration) time.Duration {
|
||||
stalledAfterCache.mu.Lock()
|
||||
defer stalledAfterCache.mu.Unlock()
|
||||
if time.Since(stalledAfterCache.fetchedAt) < time.Minute && stalledAfterCache.value > 0 {
|
||||
return stalledAfterCache.value
|
||||
}
|
||||
settings, err := store.GetActiveUISettings(ctx)
|
||||
if err != nil || settings.StalledAfterSeconds <= 0 {
|
||||
if stalledAfterCache.value > 0 {
|
||||
return stalledAfterCache.value
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
stalledAfterCache.value = time.Duration(settings.StalledAfterSeconds) * time.Second
|
||||
stalledAfterCache.fetchedAt = time.Now()
|
||||
return stalledAfterCache.value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user