mesh/delivery merged: source.main moved to novox/mesh-catalog@6d000647de2d
mesh/check being carried to cff1005422c1 on 6d000647de2d | from f9dcbc295723
The one bundle that did everything becomes the manager bundle, which runs long and answers the seat's ten verbs and the three acting tools, and a tools bundle of its own that answers the four reading tools and writes nothing, so they answer while the manager fails to load or stops. Both import the module's one package for the layouts of the kept data and the log entries, the key form, the entries' names and the settings with their validity; the settings file and the account with its directory stay as they are. Builds: design 39 parts §1, §2, §3, §4, §5, §6, §7, §8
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package main
|
|
|
|
// The manager's settings (design 39 §8, design 39 bus-and-switch §33): today's five and the six of the switch, each
|
|
// declared in the manifest's `config` with its default and bound, set through mesh-config and written into the
|
|
// settings file. They are read again at every reading, so a change takes effect at the next one, and each change of a
|
|
// value read is written in the audit under `settings`.
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"reflect"
|
|
|
|
. "claude-licence-manager/internal/licences"
|
|
)
|
|
|
|
// settings are those in force.
|
|
func (m *Manager) settings() Settings {
|
|
m.settingsMu.RLock()
|
|
defer m.settingsMu.RUnlock()
|
|
return m.Settings
|
|
}
|
|
|
|
// ReadSettings reads the settings file again, at every reading (§33): each value that changed is written in the audit
|
|
// under `settings`, its value before and now, and the settings read are those in force from then on.
|
|
func (m *Manager) ReadSettings(ctx context.Context) error {
|
|
if m.SettingsFile == "" {
|
|
return nil
|
|
}
|
|
next := SettingsFrom(m.SettingsFile)
|
|
m.settingsMu.Lock()
|
|
before := m.Settings
|
|
m.Settings = next
|
|
m.settingsMu.Unlock()
|
|
was, now := before.Values(), next.Values()
|
|
changed := map[string]any{}
|
|
for k, v := range now {
|
|
if !reflect.DeepEqual(was[k], v) {
|
|
changed[k] = map[string]any{"from": was[k], "to": v}
|
|
}
|
|
}
|
|
if len(changed) == 0 {
|
|
return nil
|
|
}
|
|
return m.record(ctx, "settings", fmt.Sprintf("%d setting(s) changed: %v", len(changed), changed), changed)
|
|
}
|