refactor: adopt PathRegistry in worker config
Update internal/worker/config.go to use centralized PathRegistry: Changes: - Initialize PathRegistry with config.FromEnv() in LoadConfig - Update BasePath default to use paths.ExperimentsDir() - Update DataDir default to use paths.DataDir() - Simplify DataDir logic by using PathRegistry directly Benefits: - Consistent directory locations via PathRegistry - Centralized path management across worker and api-server - Simpler configuration with fewer conditional branches
This commit is contained in:
parent
4bee42493b
commit
a5059c5231
1 changed files with 7 additions and 14 deletions
|
|
@ -147,6 +147,9 @@ func LoadConfig(path string) (*Config, error) {
|
|||
// Get smart defaults for current environment
|
||||
smart := config.GetSmartDefaults()
|
||||
|
||||
// Use PathRegistry for consistent path management
|
||||
paths := config.FromEnv()
|
||||
|
||||
if cfg.Port == 0 {
|
||||
cfg.Port = config.DefaultSSHPort
|
||||
}
|
||||
|
|
@ -158,11 +161,8 @@ func LoadConfig(path string) (*Config, error) {
|
|||
cfg.Host = host
|
||||
}
|
||||
if cfg.BasePath == "" {
|
||||
basePath, err := smart.BasePath()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get default base path: %w", err)
|
||||
}
|
||||
cfg.BasePath = basePath
|
||||
// Prefer PathRegistry over smart defaults for consistency
|
||||
cfg.BasePath = paths.ExperimentsDir()
|
||||
}
|
||||
if cfg.RedisAddr == "" {
|
||||
redisAddr, err := smart.RedisAddr()
|
||||
|
|
@ -203,15 +203,8 @@ func LoadConfig(path string) (*Config, error) {
|
|||
cfg.DataManagerPath = "./data_manager"
|
||||
}
|
||||
if cfg.DataDir == "" {
|
||||
if cfg.Host == "" || !cfg.AutoFetchData {
|
||||
cfg.DataDir = config.DefaultLocalDataDir
|
||||
} else {
|
||||
dataDir, err := smart.DataDir()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get default data directory: %w", err)
|
||||
}
|
||||
cfg.DataDir = dataDir
|
||||
}
|
||||
// Use PathRegistry for consistent data directory
|
||||
cfg.DataDir = paths.DataDir()
|
||||
}
|
||||
if cfg.SnapshotStore.Timeout == 0 {
|
||||
cfg.SnapshotStore.Timeout = 10 * time.Minute
|
||||
|
|
|
|||
Loading…
Reference in a new issue