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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user