feat(node): add GetNodeCount to get node count and remove no need node update log, only log when node count changed
Build / ubuntu-latest (push) Failing after 3m17s
Build / windows-latest (push) Canceled after 8m6s

This commit is contained in:
2026-09-29 21:43:46 +08:00
parent c7642ecca5
commit aa7e7f87e1
6 changed files with 23 additions and 9 deletions
+5 -5
View File
@@ -46,7 +46,7 @@ var startupOnlySettings = []string{
"dbPath",
}
// RestartRequiredKeys lists the settings in patch that only take effect at
// IsRestartRequiredKeys lists the settings in patch that only take effect at
// startup, as dot-separated paths, in the order startupOnlySettings declares
// them. Only config.json carries such settings; an update to one of the other
// files always reports nothing.
@@ -54,7 +54,7 @@ var startupOnlySettings = []string{
// The write itself succeeds either way — this is advice for the user, not a
// rejection. The result is never nil, so a caller can put it straight into a
// JSON response and get [] rather than null.
func RestartRequiredKeys(settingsType string, patch map[string]interface{}) []string {
func IsRestartRequiredKeys(settingsType string, patch map[string]interface{}) []string {
keys := []string{}
if settingsType != SettingGlobal {
return keys
@@ -63,7 +63,7 @@ func RestartRequiredKeys(settingsType string, patch map[string]interface{}) []st
patched := patchPaths(patch)
for _, watched := range startupOnlySettings {
for _, path := range patched {
if pathsOverlap(path, watched) {
if isPathsOverlap(path, watched) {
keys = append(keys, watched)
break
}
@@ -96,12 +96,12 @@ func patchPaths(patch map[string]interface{}) []string {
return paths
}
// pathsOverlap reports whether a patched path and a watched setting can affect
// isPathsOverlap reports whether a patched path and a watched setting can affect
// each other: they are the same key, the patch names something inside the
// watched setting, or the patch names a section the watched setting lives in.
// The last case matters because a patch may replace a whole section, which
// changes every key under it.
func pathsOverlap(patched, watched string) bool {
func isPathsOverlap(patched, watched string) bool {
return patched == watched ||
strings.HasPrefix(patched, watched+".") ||
strings.HasPrefix(watched, patched+".")
+2 -2
View File
@@ -271,7 +271,7 @@ func TestRestartRequiredKeys(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got := RestartRequiredKeys(tc.settingsType, tc.patch)
got := IsRestartRequiredKeys(tc.settingsType, tc.patch)
if !reflect.DeepEqual(got, tc.want) {
t.Errorf("RestartRequiredKeys() = %v, want %v", got, tc.want)
}
@@ -287,7 +287,7 @@ func TestRestartRequiredKeys(t *testing.T) {
func TestRestartRequiredKeysIsAdvisory(t *testing.T) {
writeTempConfig(t, &global.ConfigPath.Global, `{"system":{"listenPort":"8080"}}`)
keys := RestartRequiredKeys(SettingGlobal, map[string]interface{}{
keys := IsRestartRequiredKeys(SettingGlobal, map[string]interface{}{
"system": map[string]interface{}{"listenPort": "9090"},
})
if len(keys) != 1 {