refactor
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Config 对应 config.json 结构
|
||||
type Config struct {
|
||||
SecretToken string `json:"secret_token"`
|
||||
Projects map[string]map[string]string `json:"projects"`
|
||||
DeviceKeys []string `json:"device_keys"`
|
||||
}
|
||||
|
||||
var (
|
||||
globalConfig Config
|
||||
// pendingDebounceMap 防抖窗口内的待执行任务,key: "repoName:ref", value: *debounceEntry
|
||||
pendingDebounceMap sync.Map
|
||||
// 防抖冷却时间限制:5 分钟
|
||||
debounceDuration = 5 * time.Minute
|
||||
// bark 推送消息
|
||||
pushURL = "https://bark.maimaicuizhiji.top/push"
|
||||
)
|
||||
|
||||
func loadConfig(path string) error {
|
||||
file, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(file, &globalConfig)
|
||||
}
|
||||
Reference in New Issue
Block a user