feat: enhance Safew watcher initialization and token management

- Added functionality to list and start Safew tokens in the main server function, ensuring proper initialization of the Safew watcher.
- Introduced `ensureSafewWatcher` method in the ChannelHandler to manage Safew tokens during channel creation and updates.
- Implemented `StartTokens` method in the Watcher to handle multiple tokens efficiently.
- Enhanced error handling and logging for Safew watcher operations to improve observability.
This commit is contained in:
2026-08-15 01:28:51 +08:00
parent 5e783adf7a
commit 2000908bac
4 changed files with 67 additions and 1 deletions
+6
View File
@@ -139,6 +139,12 @@ func main() {
}
safewWatcher := safew.NewWatcher(watcherStore, poller)
defer safewWatcher.Stop()
if tokens, err := st.ListSafewTokens(context.Background()); err != nil {
slog.Warn("list safew tokens", "error", err)
} else {
safewWatcher.StartTokens(tokens)
slog.Info("safew watchers ensured", "count", len(tokens))
}
channelH := handler.NewChannelHandler(st, redisCache, safewWatcher)
ruleH := handler.NewRuleHandler(st, redisCache)