File Event Handler & Trigger Matcher #67

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

Tasks

  • Create internal/watcher/matcher.go
  • Implement HandleFileEvent(ctx context.Context, event FileEvent):
    1. Query DB: ListTriggersByDir(event.DirPath) — get all enabled triggers for this directory
    2. For each trigger: run filepath.Match(trigger.GlobPattern, event.Filename)
    3. For each match: call runService.TriggerRun(ctx, trigger.JobID, "file_trigger", nil)
    4. Persist uploaded_files record linking file to trigger and resulting run ID
  • Runs are dispatched asynchronously (non-blocking) so file events are processed quickly
  • Log all matches and non-matches at DEBUG level
  • Write unit tests using table-driven tests for glob pattern matching logic

Acceptance Criteria

  • A file matching a trigger's glob pattern causes the associated job to run
  • A file that doesn't match any trigger is silently ignored
  • Multiple triggers matching the same file dispatch multiple independent runs
  • Glob pattern matching unit tests pass
### Tasks - [ ] Create `internal/watcher/matcher.go` - [ ] Implement `HandleFileEvent(ctx context.Context, event FileEvent)`: 1. Query DB: `ListTriggersByDir(event.DirPath)` — get all enabled triggers for this directory 2. For each trigger: run `filepath.Match(trigger.GlobPattern, event.Filename)` 3. For each match: call `runService.TriggerRun(ctx, trigger.JobID, "file_trigger", nil)` 4. Persist `uploaded_files` record linking file to trigger and resulting run ID - [ ] Runs are dispatched asynchronously (non-blocking) so file events are processed quickly - [ ] Log all matches and non-matches at DEBUG level - [ ] Write unit tests using table-driven tests for glob pattern matching logic ### Acceptance Criteria - [ ] A file matching a trigger's glob pattern causes the associated job to run - [ ] A file that doesn't match any trigger is silently ignored - [ ] Multiple triggers matching the same file dispatch multiple independent runs - [ ] Glob pattern matching unit tests pass
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#67
No description provided.