fix: resolve critical bugs and refactor code structure
P0 Fixes: - Fix potential panic in factory.go due to unsafe type assertion - Fix VIP CIDR mask being lost during parsing (was hardcoded to /32) P1 Fixes: - Fix go.mod incorrect indirect dependency markers - Fix receiveLoop blocking issue preventing graceful shutdown Refactoring: - Split state.go into state.go, timer.go, priority.go, history.go - Split monitor.go into monitor.go and manager.go - Add IncreasePriority() method for complete priority adjustment - Fix go vet format string warning in test.go 🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
@@ -8,9 +8,13 @@ import (
|
||||
)
|
||||
|
||||
func CreateChecker(cfg *config.HealthChecker) (Checker, error) {
|
||||
if cfg.Config == nil {
|
||||
return nil, fmt.Errorf("missing config for checker %s", cfg.Name)
|
||||
}
|
||||
|
||||
configMap, ok := cfg.Config.(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid config for checker %s", cfg.Name)
|
||||
return nil, fmt.Errorf("invalid config type for checker %s: expected map[string]interface{}", cfg.Name)
|
||||
}
|
||||
|
||||
switch cfg.Type {
|
||||
@@ -36,6 +40,7 @@ func LoadFromConfig(cfg *config.Config, log *logger.Logger) (*Manager, error) {
|
||||
return nil, fmt.Errorf("failed to create checker %s: %w", healthCfg.Name, err)
|
||||
}
|
||||
|
||||
configMap, _ := healthCfg.Config.(map[string]interface{})
|
||||
monitorCfg := &CheckerConfig{
|
||||
Name: healthCfg.Name,
|
||||
Type: healthCfg.Type,
|
||||
@@ -43,7 +48,7 @@ func LoadFromConfig(cfg *config.Config, log *logger.Logger) (*Manager, error) {
|
||||
Timeout: healthCfg.Timeout,
|
||||
Rise: healthCfg.Rise,
|
||||
Fall: healthCfg.Fall,
|
||||
Config: healthCfg.Config.(map[string]interface{}),
|
||||
Config: configMap,
|
||||
}
|
||||
|
||||
monitor := NewMonitor(checker, monitorCfg, log)
|
||||
|
||||
Reference in New Issue
Block a user