Watcher Service #68

Open
opened 2026-02-23 10:03:53 +00:00 by ottomata · 0 comments
Owner

Tasks

  • Create internal/services/watcher_service.go:
func (s *WatcherService) AddWatchedDir(ctx, path string, createdBy uuid.UUID) (*domain.WatchedDir, error)
func (s *WatcherService) RemoveWatchedDir(ctx, id uuid.UUID) error
func (s *WatcherService) ListWatchedDirs(ctx) ([]*domain.WatchedDir, error)
func (s *WatcherService) CreateTrigger(ctx, jobID, watchedDirID uuid.UUID, glob string) (*domain.Trigger, error)
func (s *WatcherService) DeleteTrigger(ctx, id uuid.UUID) error
func (s *WatcherService) ToggleTrigger(ctx, id uuid.UUID, enabled bool) error
  • AddWatchedDir: validate path exists on disk, insert to DB, call watcher.Watch(path)
  • RemoveWatchedDir: call watcher.Unwatch(path), delete from DB (cascade deletes triggers)
  • CreateTrigger: validate glob pattern is non-empty and syntactically valid (filepath.Match test)

Acceptance Criteria

  • Adding a watched dir immediately starts watching it (no restart)
  • Removing a watched dir immediately stops watching it
  • Invalid glob patterns are rejected with 400
  • Path validation rejects non-existent directories
### Tasks - [ ] Create `internal/services/watcher_service.go`: ```go func (s *WatcherService) AddWatchedDir(ctx, path string, createdBy uuid.UUID) (*domain.WatchedDir, error) func (s *WatcherService) RemoveWatchedDir(ctx, id uuid.UUID) error func (s *WatcherService) ListWatchedDirs(ctx) ([]*domain.WatchedDir, error) func (s *WatcherService) CreateTrigger(ctx, jobID, watchedDirID uuid.UUID, glob string) (*domain.Trigger, error) func (s *WatcherService) DeleteTrigger(ctx, id uuid.UUID) error func (s *WatcherService) ToggleTrigger(ctx, id uuid.UUID, enabled bool) error ``` - [ ] `AddWatchedDir`: validate path exists on disk, insert to DB, call `watcher.Watch(path)` - [ ] `RemoveWatchedDir`: call `watcher.Unwatch(path)`, delete from DB (cascade deletes triggers) - [ ] `CreateTrigger`: validate glob pattern is non-empty and syntactically valid (`filepath.Match` test) ### Acceptance Criteria - [ ] Adding a watched dir immediately starts watching it (no restart) - [ ] Removing a watched dir immediately stops watching it - [ ] Invalid glob patterns are rejected with `400` - [ ] Path validation rejects non-existent directories
ottomata added this to the Phase 7 project 2026-02-23 10:09:05 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ottomata/acsm#68
No description provided.