refactor: adopt PathRegistry in queue filesystem_queue.go
Update internal/queue/filesystem_queue.go to use centralized PathRegistry: Changes: - Add import for internal/config package - Update NewFilesystemQueue to use config.FromEnv() for directory creation - Replace os.MkdirAll with paths.EnsureDir() for all queue directories: - pending/entries - running - finished - failed Benefits: - Consistent directory creation via PathRegistry - Centralized path management for queue storage - Better error handling for directory creation
This commit is contained in:
parent
f7afb36a7c
commit
d9ed8f4ffa
1 changed files with 7 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jfraeys/fetch_ml/internal/config"
|
||||
"github.com/jfraeys/fetch_ml/internal/domain"
|
||||
)
|
||||
|
||||
|
|
@ -38,11 +39,15 @@ func NewFilesystemQueue(root string) (*FilesystemQueue, error) {
|
|||
return nil, fmt.Errorf("filesystem queue root is required")
|
||||
}
|
||||
root = filepath.Clean(root)
|
||||
if err := os.MkdirAll(filepath.Join(root, "pending", "entries"), 0750); err != nil {
|
||||
|
||||
// Use PathRegistry for consistent directory creation
|
||||
paths := config.FromEnv()
|
||||
|
||||
if err := paths.EnsureDir(filepath.Join(root, "pending", "entries")); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, d := range []string{"running", "finished", "failed"} {
|
||||
if err := os.MkdirAll(filepath.Join(root, d), 0750); err != nil {
|
||||
if err := paths.EnsureDir(filepath.Join(root, d)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue